Refactor to focused n8n node documentation MCP server

Major refactoring to align with actual requirements:
- Purpose: Serve n8n node code/documentation to AI agents only
- No workflow execution or management features
- Complete node information including source code, docs, and examples

New features:
- Node documentation service with SQLite FTS5 search
- Documentation fetcher from n8n-docs repository
- Example workflow generator for each node type
- Simplified MCP tools focused on node information
- Complete database rebuild with all node data

MCP Tools:
- list_nodes: List available nodes
- get_node_info: Get complete node information
- search_nodes: Full-text search across nodes
- get_node_example: Get usage examples
- get_node_source_code: Get source code only
- get_node_documentation: Get documentation only
- rebuild_database: Rebuild entire database
- get_database_statistics: Database stats

Database schema includes:
- Node source code and metadata
- Official documentation from n8n-docs
- Generated usage examples
- Full-text search capabilities
- Category and type filtering

Updated README with:
- Clear purpose statement
- Claude Desktop installation instructions
- Complete tool documentation
- Troubleshooting guide

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
czlonkowski
2025-06-07 22:11:30 +00:00
parent 96809d0c9f
commit d32af279c0
17 changed files with 2484 additions and 359 deletions

View File

@@ -0,0 +1,88 @@
#!/usr/bin/env node
const { NodeDocumentationService } = require('../dist/services/node-documentation-service');
async function testService() {
console.log('=== Testing Node Documentation Service ===\n');
// Use a separate database for v2
const service = new NodeDocumentationService('./data/nodes-v2.db');
try {
// Test 1: List nodes
console.log('1⃣ Testing list nodes...');
const nodes = await service.listNodes();
console.log(` Found ${nodes.length} nodes in database`);
if (nodes.length === 0) {
console.log('\n⚠ No nodes found. Running rebuild...');
const stats = await service.rebuildDatabase();
console.log(` Rebuild complete: ${stats.successful} nodes stored`);
}
// Test 2: Get specific node info (IF node)
console.log('\n2⃣ Testing get node info for "If" node...');
const ifNode = await service.getNodeInfo('n8n-nodes-base.if');
if (ifNode) {
console.log(' ✅ Found IF node:');
console.log(` Name: ${ifNode.displayName}`);
console.log(` Description: ${ifNode.description}`);
console.log(` Has source code: ${!!ifNode.sourceCode}`);
console.log(` Source code length: ${ifNode.sourceCode?.length || 0} bytes`);
console.log(` Has documentation: ${!!ifNode.documentation}`);
console.log(` Has example: ${!!ifNode.exampleWorkflow}`);
if (ifNode.exampleWorkflow) {
console.log('\n 📋 Example workflow:');
console.log(JSON.stringify(ifNode.exampleWorkflow, null, 2).substring(0, 500) + '...');
}
} else {
console.log(' ❌ IF node not found');
}
// Test 3: Search nodes
console.log('\n3⃣ Testing search functionality...');
// Search for webhook nodes
const webhookNodes = await service.searchNodes({ query: 'webhook' });
console.log(`\n 🔍 Search for "webhook": ${webhookNodes.length} results`);
webhookNodes.slice(0, 3).forEach(node => {
console.log(` - ${node.displayName} (${node.nodeType})`);
});
// Search for HTTP nodes
const httpNodes = await service.searchNodes({ query: 'http' });
console.log(`\n 🔍 Search for "http": ${httpNodes.length} results`);
httpNodes.slice(0, 3).forEach(node => {
console.log(` - ${node.displayName} (${node.nodeType})`);
});
// Test 4: Get statistics
console.log('\n4⃣ Testing database statistics...');
const stats = service.getStatistics();
console.log(' 📊 Database stats:');
console.log(` Total nodes: ${stats.totalNodes}`);
console.log(` Nodes with docs: ${stats.nodesWithDocs}`);
console.log(` Nodes with examples: ${stats.nodesWithExamples}`);
console.log(` Trigger nodes: ${stats.triggerNodes}`);
console.log(` Webhook nodes: ${stats.webhookNodes}`);
console.log(` Total packages: ${stats.totalPackages}`);
// Test 5: Category filtering
console.log('\n5⃣ Testing category filtering...');
const coreNodes = await service.searchNodes({ category: 'Core Nodes' });
console.log(` Found ${coreNodes.length} core nodes`);
console.log('\n✅ All tests completed!');
} catch (error) {
console.error('\n❌ Test failed:', error);
process.exit(1);
} finally {
service.close();
}
}
// Run tests
testService().catch(console.error);

26
tests/test-node-list.js Normal file
View File

@@ -0,0 +1,26 @@
#!/usr/bin/env node
const { NodeSourceExtractor } = require('../dist/utils/node-source-extractor');
async function testNodeList() {
console.log('Testing node list...\n');
const extractor = new NodeSourceExtractor();
try {
const nodes = await extractor.listAvailableNodes();
console.log(`Total nodes found: ${nodes.length}`);
// Show first 5 nodes
console.log('\nFirst 5 nodes:');
nodes.slice(0, 5).forEach((node, index) => {
console.log(`${index + 1}. Node:`, JSON.stringify(node, null, 2));
});
} catch (error) {
console.error('Error:', error);
}
}
testNodeList();

View File

@@ -0,0 +1,62 @@
#!/usr/bin/env node
const { NodeDocumentationService } = require('../dist/services/node-documentation-service');
async function testSmallRebuild() {
console.log('Testing small rebuild...\n');
const service = new NodeDocumentationService('./data/nodes-v2-test.db');
try {
// First, let's just try the IF node specifically
const extractor = service.extractor;
console.log('1⃣ Testing extraction of IF node...');
try {
const ifNodeData = await extractor.extractNodeSource('n8n-nodes-base.If');
console.log(' ✅ Successfully extracted IF node');
console.log(' Source code length:', ifNodeData.sourceCode.length);
console.log(' Has credentials:', !!ifNodeData.credentialCode);
} catch (error) {
console.log(' ❌ Failed to extract IF node:', error.message);
}
// Try the Webhook node
console.log('\n2⃣ Testing extraction of Webhook node...');
try {
const webhookNodeData = await extractor.extractNodeSource('n8n-nodes-base.Webhook');
console.log(' ✅ Successfully extracted Webhook node');
console.log(' Source code length:', webhookNodeData.sourceCode.length);
} catch (error) {
console.log(' ❌ Failed to extract Webhook node:', error.message);
}
// Now try storing just these nodes
console.log('\n3⃣ Testing storage of a single node...');
const nodeInfo = {
nodeType: 'n8n-nodes-base.If',
name: 'If',
displayName: 'If',
description: 'Route items based on comparison operations',
sourceCode: 'test source code',
packageName: 'n8n-nodes-base',
hasCredentials: false,
isTrigger: false,
isWebhook: false
};
await service.storeNode(nodeInfo);
console.log(' ✅ Successfully stored test node');
// Check if it was stored
const retrievedNode = await service.getNodeInfo('n8n-nodes-base.If');
console.log(' Retrieved node:', retrievedNode ? 'Found' : 'Not found');
} catch (error) {
console.error('❌ Test failed:', error);
} finally {
service.close();
}
}
testSmallRebuild();