n8n-mcp
Version:
Integration between n8n workflow automation and Model Context Protocol (MCP)
74 lines (66 loc) • 2.81 kB
JavaScript
#!/usr/bin/env node
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const child_process_1 = require("child_process");
const fs_1 = require("fs");
const path_1 = require("path");
const testScript = `
import { isN8nApiConfigured, getN8nApiConfig } from '../config/n8n-api';
import { n8nDocumentationToolsFinal } from '../mcp/tools';
import { n8nManagementTools } from '../mcp/tools-n8n-manager';
console.log('\\n=== Simulating Docker Container Startup ===\\n');
// Simulate initial module load (before env vars are available)
console.log('1. Initial module load (no env vars):');
console.log(' Is configured:', isN8nApiConfigured());
console.log(' Config:', getN8nApiConfig());
// Simulate environment variables becoming available later
// (This happens in Docker when env vars are injected after module load)
console.log('\\n2. Setting environment variables (simulating Docker env injection):');
process.env.N8N_API_URL = 'https://docker-test.n8n.cloud';
process.env.N8N_API_KEY = 'docker-test-api-key';
// Wait a bit then check again
setTimeout(() => {
console.log('\\n3. After env vars are set (with cache expired):');
console.log(' Is configured:', isN8nApiConfigured());
const config = getN8nApiConfig();
console.log(' Config URL:', config?.baseUrl || 'null');
// Simulate MCP tool listing
console.log('\\n4. Tool registration check:');
const tools = [...n8nDocumentationToolsFinal];
if (isN8nApiConfigured()) {
tools.push(...n8nManagementTools);
console.log(' ✓ Management tools would be registered');
} else {
console.log(' ✗ Management tools would NOT be registered');
}
console.log(' Total tools available:', tools.length);
console.log(' Documentation tools:', n8nDocumentationToolsFinal.length);
console.log(' Management tools:', isN8nApiConfigured() ? n8nManagementTools.length : 0);
console.log('\\n=== Test Complete ===\\n');
process.exit(0);
}, 5500); // Wait longer than cache duration
`;
const testFilePath = (0, path_1.join)(__dirname, 'temp-docker-test.js');
(0, fs_1.writeFileSync)(testFilePath, testScript);
console.log('Running Docker configuration simulation...');
console.log('This test runs in a clean environment without pre-existing env vars.\n');
const child = (0, child_process_1.spawn)('node', [testFilePath], {
cwd: (0, path_1.join)(__dirname, '..', '..', 'dist', 'scripts'),
env: {
PATH: process.env.PATH,
NODE_ENV: 'test'
},
stdio: 'inherit'
});
child.on('exit', (code) => {
try {
(0, fs_1.unlinkSync)(testFilePath);
}
catch (e) {
}
if (code !== 0) {
console.error(`Test failed with exit code ${code}`);
process.exit(code);
}
});
//# sourceMappingURL=test-docker-config-simulation.js.map