UNPKG

n8n-mcp

Version:

Integration between n8n workflow automation and Model Context Protocol (MCP)

112 lines 4.21 kB
#!/usr/bin/env tsx "use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const path_1 = require("path"); const mcp_engine_1 = __importDefault(require("../mcp-engine")); console.log('Testing Issue #74 - Format variations for Chat Trigger node\n'); async function testNodeFormat(engine, format, shouldWork) { console.log(`Testing format: "${format}"`); try { const essentialsResult = await engine.callTool('get_node_essentials', { nodeType: format }); if (essentialsResult.error) { if (shouldWork) { console.log(` ❌ FAILED: ${essentialsResult.error.message}`); return false; } else { console.log(` ✅ Expected failure: ${essentialsResult.error.message}`); return true; } } const validateResult = await engine.callTool('validate_node_operation', { nodeType: format, config: { public: true } }); if (validateResult.error) { if (shouldWork) { console.log(` ❌ FAILED validation: ${validateResult.error.message}`); return false; } else { console.log(` ✅ Expected validation failure: ${validateResult.error.message}`); return true; } } if (shouldWork) { console.log(` ✅ SUCCESS: Found ${essentialsResult.result.displayName}`); console.log(` - Category: ${essentialsResult.result.category}`); console.log(` - Package: ${essentialsResult.result.metadata.package}`); return true; } else { console.log(` ❌ UNEXPECTED SUCCESS: Should have failed but found node`); return false; } } catch (error) { if (shouldWork) { console.log(` ❌ ERROR: ${error}`); return false; } else { console.log(` ✅ Expected error: ${error}`); return true; } } } async function main() { const dbPath = (0, path_1.join)(__dirname, '../../data/nodes.db'); const engine = new mcp_engine_1.default(dbPath); try { await engine.initialize(); console.log('MCP Engine initialized\n'); const testCases = [ { format: 'nodes-langchain.chatTrigger', shouldWork: true }, { format: 'n8n-nodes-langchain.chatTrigger', shouldWork: true }, { format: 'n8n-nodes-langchain.chattrigger', shouldWork: true }, { format: 'nodes-langchain.chattrigger', shouldWork: true }, { format: '@n8n/n8n-nodes-langchain.chatTrigger', shouldWork: true }, { format: '@n8n/n8n-nodes-langchain.chattrigger', shouldWork: true }, { format: 'invalid.chatTrigger', shouldWork: false }, { format: 'chatTrigger', shouldWork: false }, ]; console.log('Running tests...\n'); let passed = 0; let failed = 0; for (const testCase of testCases) { const result = await testNodeFormat(engine, testCase.format, testCase.shouldWork); if (result) { passed++; } else { failed++; } console.log(''); } console.log(`\nTest Summary:`); console.log(` ✅ Passed: ${passed}`); console.log(` ❌ Failed: ${failed}`); console.log(` Total: ${testCases.length}`); if (failed > 0) { console.log('\n⚠️ Some tests failed. The issue may not be fully resolved.'); process.exit(1); } else { console.log('\n🎉 All tests passed! Issue #74 is fully resolved.'); } } catch (error) { console.error('Failed to initialize MCP Engine:', error); process.exit(1); } finally { await engine.close(); } } main().catch(console.error); //# sourceMappingURL=test-issue-74.js.map