refactor: clean up file names and fix version management
- Renamed files to remove unnecessary suffixes: - tools-update.ts → tools.ts - server-update.ts → server.ts - http-server-fixed.ts → http-server.ts - Created version utility to read from package.json as single source of truth - Updated all imports across 21+ files - Removed legacy files: - src/http-server.ts (legacy HTTP server with known issues) - src/utils/n8n-client.ts (unused legacy API client) - Added n8n_diagnostic tool to help troubleshoot management tools visibility - Added script to sync package.runtime.json version - Fixed version mismatch issue (was hardcoded 2.4.1, now reads 2.7.0 from package.json) This addresses GitHub issue #5 regarding version mismatch and provides better diagnostics for users. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -831,4 +831,108 @@ export async function handleListAvailableTools(): Promise<McpToolResponse> {
|
||||
]
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// Handler: n8n_diagnostic
|
||||
export async function handleDiagnostic(request: any): Promise<McpToolResponse> {
|
||||
const verbose = request.params?.arguments?.verbose || false;
|
||||
|
||||
// Check environment variables
|
||||
const envVars = {
|
||||
N8N_API_URL: process.env.N8N_API_URL || null,
|
||||
N8N_API_KEY: process.env.N8N_API_KEY ? '***configured***' : null,
|
||||
NODE_ENV: process.env.NODE_ENV || 'production',
|
||||
MCP_MODE: process.env.MCP_MODE || 'stdio'
|
||||
};
|
||||
|
||||
// Check API configuration
|
||||
const apiConfigured = n8nApiConfig !== null;
|
||||
const apiClient = getN8nApiClient();
|
||||
|
||||
// Test API connectivity if configured
|
||||
let apiStatus = {
|
||||
configured: apiConfigured,
|
||||
connected: false,
|
||||
error: null as string | null,
|
||||
version: null as string | null
|
||||
};
|
||||
|
||||
if (apiClient) {
|
||||
try {
|
||||
const health = await apiClient.healthCheck();
|
||||
apiStatus.connected = true;
|
||||
apiStatus.version = health.n8nVersion || 'unknown';
|
||||
} catch (error) {
|
||||
apiStatus.error = error instanceof Error ? error.message : 'Unknown error';
|
||||
}
|
||||
}
|
||||
|
||||
// Check which tools are available
|
||||
const documentationTools = 22; // Base documentation tools
|
||||
const managementTools = apiConfigured ? 16 : 0;
|
||||
const totalTools = documentationTools + managementTools;
|
||||
|
||||
// Build diagnostic report
|
||||
const diagnostic: any = {
|
||||
timestamp: new Date().toISOString(),
|
||||
environment: envVars,
|
||||
apiConfiguration: {
|
||||
configured: apiConfigured,
|
||||
status: apiStatus,
|
||||
config: apiConfigured && n8nApiConfig ? {
|
||||
baseUrl: n8nApiConfig.baseUrl,
|
||||
timeout: n8nApiConfig.timeout,
|
||||
maxRetries: n8nApiConfig.maxRetries
|
||||
} : null
|
||||
},
|
||||
toolsAvailability: {
|
||||
documentationTools: {
|
||||
count: documentationTools,
|
||||
enabled: true,
|
||||
description: 'Always available - node info, search, validation, etc.'
|
||||
},
|
||||
managementTools: {
|
||||
count: managementTools,
|
||||
enabled: apiConfigured,
|
||||
description: apiConfigured ?
|
||||
'Management tools are ENABLED - create, update, execute workflows' :
|
||||
'Management tools are DISABLED - configure N8N_API_URL and N8N_API_KEY to enable'
|
||||
},
|
||||
totalAvailable: totalTools
|
||||
},
|
||||
troubleshooting: {
|
||||
steps: apiConfigured ? [
|
||||
'API is configured and should work',
|
||||
'If tools are not showing in Claude Desktop:',
|
||||
'1. Restart Claude Desktop completely',
|
||||
'2. Check if using latest Docker image',
|
||||
'3. Verify environment variables are passed correctly',
|
||||
'4. Try running n8n_health_check to test connectivity'
|
||||
] : [
|
||||
'To enable management tools:',
|
||||
'1. Set N8N_API_URL environment variable (e.g., https://your-n8n-instance.com)',
|
||||
'2. Set N8N_API_KEY environment variable (get from n8n API settings)',
|
||||
'3. Restart the MCP server',
|
||||
'4. Management tools will automatically appear'
|
||||
],
|
||||
documentation: 'For detailed setup instructions, see: https://github.com/czlonkowski/n8n-mcp#n8n-management-tools-new-v260---requires-api-configuration'
|
||||
}
|
||||
};
|
||||
|
||||
// Add verbose debug info if requested
|
||||
if (verbose) {
|
||||
diagnostic['debug'] = {
|
||||
processEnv: Object.keys(process.env).filter(key =>
|
||||
key.startsWith('N8N_') || key.startsWith('MCP_')
|
||||
),
|
||||
nodeVersion: process.version,
|
||||
platform: process.platform,
|
||||
workingDirectory: process.cwd()
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
success: true,
|
||||
data: diagnostic
|
||||
};
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import { N8NDocumentationMCPServer } from './server-update';
|
||||
import { N8NDocumentationMCPServer } from './server';
|
||||
import { logger } from '../utils/logger';
|
||||
|
||||
// Add error details to stderr for Claude Desktop debugging
|
||||
@@ -35,7 +35,7 @@ async function main() {
|
||||
// Check if we should use the fixed implementation
|
||||
if (process.env.USE_FIXED_HTTP === 'true') {
|
||||
// Use the fixed HTTP implementation that bypasses StreamableHTTPServerTransport issues
|
||||
const { startFixedHTTPServer } = await import('../http-server-fixed');
|
||||
const { startFixedHTTPServer } = await import('../http-server');
|
||||
await startFixedHTTPServer();
|
||||
} else {
|
||||
// HTTP mode - for remote deployment with single-session architecture
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
} from '@modelcontextprotocol/sdk/types.js';
|
||||
import { existsSync } from 'fs';
|
||||
import path from 'path';
|
||||
import { n8nDocumentationToolsFinal } from './tools-update';
|
||||
import { n8nDocumentationToolsFinal } from './tools';
|
||||
import { n8nManagementTools } from './tools-n8n-manager';
|
||||
import { logger } from '../utils/logger';
|
||||
import { NodeRepository } from '../database/node-repository';
|
||||
@@ -24,6 +24,7 @@ import { WorkflowValidator } from '../services/workflow-validator';
|
||||
import { isN8nApiConfigured } from '../config/n8n-api';
|
||||
import * as n8nHandlers from './handlers-n8n-manager';
|
||||
import { handleUpdatePartialWorkflow } from './handlers-workflow-diff';
|
||||
import { PROJECT_VERSION } from '../utils/version';
|
||||
|
||||
interface NodeRow {
|
||||
node_type: string;
|
||||
@@ -121,7 +122,7 @@ export class N8NDocumentationMCPServer {
|
||||
},
|
||||
serverInfo: {
|
||||
name: 'n8n-documentation-mcp',
|
||||
version: '2.4.1',
|
||||
version: PROJECT_VERSION,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -261,6 +262,8 @@ export class N8NDocumentationMCPServer {
|
||||
return n8nHandlers.handleHealthCheck();
|
||||
case 'n8n_list_available_tools':
|
||||
return n8nHandlers.handleListAvailableTools();
|
||||
case 'n8n_diagnostic':
|
||||
return n8nHandlers.handleDiagnostic({ params: { arguments: args } });
|
||||
|
||||
default:
|
||||
throw new Error(`Unknown tool: ${name}`);
|
||||
@@ -40,7 +40,7 @@ console.count = () => {};
|
||||
console.countReset = () => {};
|
||||
|
||||
// Import and run the server AFTER suppressing output
|
||||
import { N8NDocumentationMCPServer } from './server-update';
|
||||
import { N8NDocumentationMCPServer } from './server';
|
||||
|
||||
async function main() {
|
||||
try {
|
||||
|
||||
@@ -484,5 +484,18 @@ Validation example:
|
||||
type: 'object',
|
||||
properties: {}
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'n8n_diagnostic',
|
||||
description: `Diagnose n8n API configuration and management tools availability. Shows current configuration status, which tools are enabled/disabled, and helps troubleshoot why management tools might not be appearing. Returns detailed diagnostic information including environment variables, API connectivity, and tool registration status.`,
|
||||
inputSchema: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
verbose: {
|
||||
type: 'boolean',
|
||||
description: 'Include detailed debug information (default: false)'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
];
|
||||
Reference in New Issue
Block a user