n8n_health_check
Verify connection and API credentials for n8n instance to ensure proper integration with workflow automation tools.
Instructions
Check the connection to the n8n instance and verify API credentials.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/server.ts:139-174 (handler)Handler function that executes the n8n_health_check tool. Initializes API client, calls healthCheck, formats success/error response as MCP ToolResult.private async handleHealthCheck(): Promise<ToolResult> { try { const client = this.initializeApiClient(); const result = await client.healthCheck(); return { content: [ { type: 'text' as const, text: JSON.stringify({ status: result.status, apiUrl: process.env.N8N_API_URL, message: result.status === 'connected' ? 'Successfully connected to n8n instance' : `Connection failed: ${result.version}`, }, null, 2), }, ], }; } catch (error) { const errorMessage = error instanceof Error ? error.message : 'Unknown error'; return { content: [ { type: 'text' as const, text: JSON.stringify({ status: 'error', apiUrl: process.env.N8N_API_URL || 'Not configured', message: errorMessage, }, null, 2), }, ], isError: true, }; } }
- Core health check implementation in N8nApiClient. Verifies connection by attempting to list workflows via API; returns status.async healthCheck(): Promise<{ status: string; version?: string }> { try { // Try to list workflows with limit 1 to verify connection await this.request<N8nListResponse<N8nWorkflow>>('/workflows?limit=1'); return { status: 'connected' }; } catch (error) { return { status: 'error', version: error instanceof Error ? error.message : 'Unknown error' }; } }
- src/tools/execution-tools.ts:99-106 (schema)Tool schema definition: name, description, and empty inputSchema (no parameters required). Included in executionTools array for registration.{ name: 'n8n_health_check', description: 'Check the connection to the n8n instance and verify API credentials.', inputSchema: { type: 'object', properties: {}, }, },
- src/tools/index.ts:12-116 (registration)Aggregates all tool definitions including executionTools (which contains n8n_health_check) into allTools, used by server for ListTools.export const allTools: ToolDefinition[] = [ ...documentationTools, // Documentation first for discoverability ...workflowTools, ...executionTools, ]; // Re-export handlers export { workflowToolHandlers } from './workflow-tools'; export { executionToolHandlers } from './execution-tools'; export { documentationToolHandlers } from './documentation-tools'; // Combined handlers type export type AllToolHandlers = typeof workflowToolHandlers & typeof executionToolHandlers & typeof documentationToolHandlers;
- src/server.ts:114-116 (handler)Dispatch logic in handleToolCall that routes 'n8n_health_check' calls to the dedicated handler.if (name === 'n8n_health_check') { return this.handleHealthCheck(); }