server_health
Monitor database connection health across multiple database types to ensure reliable data access and identify connectivity issues.
Instructions
Check health status of all database connections
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/server/McpServer.ts:132-157 (handler)The handler function for the 'server_health' tool. It creates a health report including server status, timestamp, and health checks for each registered database adapter by calling adapter.getHealth(). Errors are caught and reported. Returns JSON-formatted text content.async () => { const health: Record<string, unknown> = { server: 'healthy', timestamp: new Date().toISOString(), adapters: {} }; for (const [id, adapter] of this.adapters) { try { const adapterHealth = await adapter.getHealth(); (health['adapters'] as Record<string, unknown>)[id] = adapterHealth; } catch (error) { (health['adapters'] as Record<string, unknown>)[id] = { connected: false, error: error instanceof Error ? error.message : 'Unknown error' }; } } return { content: [{ type: 'text' as const, text: JSON.stringify(health, null, 2) }] }; }
- src/server/McpServer.ts:128-158 (registration)Registration of the 'server_health' tool using the deprecated this.server.tool() method. Includes tool name, description, empty input schema ({}), and inline async handler function.this.server.tool( 'server_health', 'Check health status of all database connections', {}, async () => { const health: Record<string, unknown> = { server: 'healthy', timestamp: new Date().toISOString(), adapters: {} }; for (const [id, adapter] of this.adapters) { try { const adapterHealth = await adapter.getHealth(); (health['adapters'] as Record<string, unknown>)[id] = adapterHealth; } catch (error) { (health['adapters'] as Record<string, unknown>)[id] = { connected: false, error: error instanceof Error ? error.message : 'Unknown error' }; } } return { content: [{ type: 'text' as const, text: JSON.stringify(health, null, 2) }] }; } );