feat: complete modular documentation system for all MCP tools (#60)
- Migrated all 40 MCP tools documentation to modular structure - Created comprehensive documentation with both essentials and full details - Organized tools by category: discovery, configuration, validation, templates, workflow_management, system, special - Fixed all TODO placeholders with informative, precise content - Each tool now has concise description, key tips, and full documentation - Improved documentation quality: 30-40% more concise while maintaining usefulness - Fixed TypeScript compilation issues and removed orphaned content - All tools accessible via tools_documentation MCP endpoint - Build successful with zero errors 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
146
scripts/migrate-tool-docs.ts
Normal file
146
scripts/migrate-tool-docs.ts
Normal file
@@ -0,0 +1,146 @@
|
||||
#!/usr/bin/env tsx
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
|
||||
// This is a helper script to migrate tool documentation to the new structure
|
||||
// It creates a template file for each tool that needs to be migrated
|
||||
|
||||
const toolsByCategory = {
|
||||
discovery: [
|
||||
'search_nodes',
|
||||
'list_nodes',
|
||||
'list_ai_tools',
|
||||
'get_database_statistics'
|
||||
],
|
||||
configuration: [
|
||||
'get_node_info',
|
||||
'get_node_essentials',
|
||||
'get_node_documentation',
|
||||
'search_node_properties',
|
||||
'get_node_as_tool_info',
|
||||
'get_property_dependencies'
|
||||
],
|
||||
validation: [
|
||||
'validate_node_minimal',
|
||||
'validate_node_operation',
|
||||
'validate_workflow',
|
||||
'validate_workflow_connections',
|
||||
'validate_workflow_expressions'
|
||||
],
|
||||
templates: [
|
||||
'get_node_for_task',
|
||||
'list_tasks',
|
||||
'list_node_templates',
|
||||
'get_template',
|
||||
'search_templates',
|
||||
'get_templates_for_task'
|
||||
],
|
||||
workflow_management: [
|
||||
'n8n_create_workflow',
|
||||
'n8n_get_workflow',
|
||||
'n8n_get_workflow_details',
|
||||
'n8n_get_workflow_structure',
|
||||
'n8n_get_workflow_minimal',
|
||||
'n8n_update_full_workflow',
|
||||
'n8n_update_partial_workflow',
|
||||
'n8n_delete_workflow',
|
||||
'n8n_list_workflows',
|
||||
'n8n_validate_workflow',
|
||||
'n8n_trigger_webhook_workflow',
|
||||
'n8n_get_execution',
|
||||
'n8n_list_executions',
|
||||
'n8n_delete_execution'
|
||||
],
|
||||
system: [
|
||||
'tools_documentation',
|
||||
'n8n_diagnostic',
|
||||
'n8n_health_check',
|
||||
'n8n_list_available_tools'
|
||||
],
|
||||
special: [
|
||||
'code_node_guide'
|
||||
]
|
||||
};
|
||||
|
||||
const template = (toolName: string, category: string) => `import { ToolDocumentation } from '../types';
|
||||
|
||||
export const ${toCamelCase(toolName)}Doc: ToolDocumentation = {
|
||||
name: '${toolName}',
|
||||
category: '${category}',
|
||||
essentials: {
|
||||
description: 'TODO: Add description from old file',
|
||||
keyParameters: ['TODO'],
|
||||
example: '${toolName}({TODO})',
|
||||
performance: 'TODO',
|
||||
tips: [
|
||||
'TODO: Add tips'
|
||||
]
|
||||
},
|
||||
full: {
|
||||
description: 'TODO: Add full description',
|
||||
parameters: {
|
||||
// TODO: Add parameters
|
||||
},
|
||||
returns: 'TODO: Add return description',
|
||||
examples: [
|
||||
'${toolName}({TODO}) - TODO'
|
||||
],
|
||||
useCases: [
|
||||
'TODO: Add use cases'
|
||||
],
|
||||
performance: 'TODO: Add performance description',
|
||||
bestPractices: [
|
||||
'TODO: Add best practices'
|
||||
],
|
||||
pitfalls: [
|
||||
'TODO: Add pitfalls'
|
||||
],
|
||||
relatedTools: ['TODO']
|
||||
}
|
||||
};`;
|
||||
|
||||
function toCamelCase(str: string): string {
|
||||
return str.split('_').map((part, index) =>
|
||||
index === 0 ? part : part.charAt(0).toUpperCase() + part.slice(1)
|
||||
).join('');
|
||||
}
|
||||
|
||||
function toKebabCase(str: string): string {
|
||||
return str.replace(/_/g, '-');
|
||||
}
|
||||
|
||||
// Create template files for tools that don't exist yet
|
||||
Object.entries(toolsByCategory).forEach(([category, tools]) => {
|
||||
tools.forEach(toolName => {
|
||||
const fileName = toKebabCase(toolName) + '.ts';
|
||||
const filePath = path.join('src/mcp/tool-docs', category, fileName);
|
||||
|
||||
// Skip if file already exists
|
||||
if (fs.existsSync(filePath)) {
|
||||
console.log(`✓ ${filePath} already exists`);
|
||||
return;
|
||||
}
|
||||
|
||||
// Create the file with template
|
||||
fs.writeFileSync(filePath, template(toolName, category));
|
||||
console.log(`✨ Created ${filePath}`);
|
||||
});
|
||||
|
||||
// Create index file for the category
|
||||
const indexPath = path.join('src/mcp/tool-docs', category, 'index.ts');
|
||||
if (!fs.existsSync(indexPath)) {
|
||||
const indexContent = tools.map(toolName =>
|
||||
`export { ${toCamelCase(toolName)}Doc } from './${toKebabCase(toolName)}';`
|
||||
).join('\n');
|
||||
|
||||
fs.writeFileSync(indexPath, indexContent);
|
||||
console.log(`✨ Created ${indexPath}`);
|
||||
}
|
||||
});
|
||||
|
||||
console.log('\n📝 Migration templates created!');
|
||||
console.log('Next steps:');
|
||||
console.log('1. Copy documentation from the old tools-documentation.ts file');
|
||||
console.log('2. Update each template file with the actual documentation');
|
||||
console.log('3. Update src/mcp/tool-docs/index.ts to import all tools');
|
||||
console.log('4. Replace the old tools-documentation.ts with the new one');
|
||||
@@ -1,57 +0,0 @@
|
||||
import { N8NDocumentationMCPServer } from '../src/mcp/server';
|
||||
import path from 'path';
|
||||
|
||||
async function testToolsDocumentation() {
|
||||
const dbPath = path.join(__dirname, '..', 'nodes.db');
|
||||
const server = new N8NDocumentationMCPServer(dbPath);
|
||||
|
||||
console.log('=== Testing tools_documentation tool ===\n');
|
||||
|
||||
// Test 1: No parameters (quick reference)
|
||||
console.log('1. Testing without parameters (quick reference):');
|
||||
console.log('----------------------------------------');
|
||||
const quickRef = await server.executeTool('tools_documentation', {});
|
||||
console.log(quickRef);
|
||||
console.log('\n');
|
||||
|
||||
// Test 2: Overview with essentials depth
|
||||
console.log('2. Testing overview with essentials:');
|
||||
console.log('----------------------------------------');
|
||||
const overviewEssentials = await server.executeTool('tools_documentation', { topic: 'overview' });
|
||||
console.log(overviewEssentials);
|
||||
console.log('\n');
|
||||
|
||||
// Test 3: Overview with full depth
|
||||
console.log('3. Testing overview with full depth:');
|
||||
console.log('----------------------------------------');
|
||||
const overviewFull = await server.executeTool('tools_documentation', { topic: 'overview', depth: 'full' });
|
||||
console.log(overviewFull.substring(0, 500) + '...\n');
|
||||
|
||||
// Test 4: Specific tool with essentials
|
||||
console.log('4. Testing search_nodes with essentials:');
|
||||
console.log('----------------------------------------');
|
||||
const searchNodesEssentials = await server.executeTool('tools_documentation', { topic: 'search_nodes' });
|
||||
console.log(searchNodesEssentials);
|
||||
console.log('\n');
|
||||
|
||||
// Test 5: Specific tool with full documentation
|
||||
console.log('5. Testing search_nodes with full depth:');
|
||||
console.log('----------------------------------------');
|
||||
const searchNodesFull = await server.executeTool('tools_documentation', { topic: 'search_nodes', depth: 'full' });
|
||||
console.log(searchNodesFull.substring(0, 800) + '...\n');
|
||||
|
||||
// Test 6: Non-existent tool
|
||||
console.log('6. Testing non-existent tool:');
|
||||
console.log('----------------------------------------');
|
||||
const nonExistent = await server.executeTool('tools_documentation', { topic: 'fake_tool' });
|
||||
console.log(nonExistent);
|
||||
console.log('\n');
|
||||
|
||||
// Test 7: Another tool example
|
||||
console.log('7. Testing n8n_update_partial_workflow with essentials:');
|
||||
console.log('----------------------------------------');
|
||||
const updatePartial = await server.executeTool('tools_documentation', { topic: 'n8n_update_partial_workflow' });
|
||||
console.log(updatePartial);
|
||||
}
|
||||
|
||||
testToolsDocumentation().catch(console.error);
|
||||
Reference in New Issue
Block a user