refactor: reorganize documentation and configuration files for improved clarity

This commit is contained in:
czlonkowski
2025-06-12 15:03:12 +02:00
parent 8bf670c31e
commit f831b02415
21 changed files with 1094 additions and 1841 deletions

View File

@@ -3,12 +3,45 @@
import { N8NDocumentationMCPServer } from './server-update';
import { logger } from '../utils/logger';
// Add error details to stderr for Claude Desktop debugging
process.on('uncaughtException', (error) => {
console.error('Uncaught Exception:', error);
logger.error('Uncaught Exception:', error);
process.exit(1);
});
process.on('unhandledRejection', (reason, promise) => {
console.error('Unhandled Rejection at:', promise, 'reason:', reason);
logger.error('Unhandled Rejection:', reason);
process.exit(1);
});
async function main() {
try {
console.error('Starting n8n Documentation MCP Server...');
console.error('Current directory:', process.cwd());
console.error('Script directory:', __dirname);
console.error('Node version:', process.version);
const server = new N8NDocumentationMCPServer();
await server.run();
} catch (error) {
console.error('Failed to start MCP server:', error);
logger.error('Failed to start MCP server', error);
// Provide helpful error messages
if (error instanceof Error && error.message.includes('nodes.db not found')) {
console.error('\nTo fix this issue:');
console.error('1. cd to the n8n-mcp directory');
console.error('2. Run: npm run build');
console.error('3. Run: npm run rebuild');
} else if (error instanceof Error && error.message.includes('NODE_MODULE_VERSION')) {
console.error('\nTo fix this Node.js version mismatch:');
console.error('1. cd to the n8n-mcp directory');
console.error('2. Run: npm rebuild better-sqlite3');
console.error('3. If that doesn\'t work, try: rm -rf node_modules && npm install');
}
process.exit(1);
}
}

View File

@@ -5,6 +5,8 @@ import {
ListToolsRequestSchema,
} from '@modelcontextprotocol/sdk/types.js';
import Database from 'better-sqlite3';
import { existsSync } from 'fs';
import path from 'path';
import { n8nDocumentationTools } from './tools-update';
import { logger } from '../utils/logger';
@@ -31,7 +33,34 @@ export class N8NDocumentationMCPServer {
private db: Database.Database;
constructor() {
this.db = new Database('./data/nodes.db');
// Try multiple database paths
const possiblePaths = [
path.join(process.cwd(), 'data', 'nodes.db'),
path.join(__dirname, '../../data', 'nodes.db'),
'./data/nodes.db'
];
let dbPath: string | null = null;
for (const p of possiblePaths) {
if (existsSync(p)) {
dbPath = p;
break;
}
}
if (!dbPath) {
logger.error('Database not found in any of the expected locations:', possiblePaths);
throw new Error('Database nodes.db not found. Please run npm run rebuild first.');
}
try {
this.db = new Database(dbPath);
logger.info(`Initialized database from: ${dbPath}`);
} catch (error) {
logger.error('Failed to initialize database:', error);
throw new Error(`Failed to open database: ${error instanceof Error ? error.message : 'Unknown error'}`);
}
logger.info('Initializing n8n Documentation MCP server');
this.server = new Server(