get_connection_health
Check SQL Server connection pool health metrics and diagnose connectivity issues to ensure reliable database operations.
Instructions
Get connection pool health metrics and diagnostics
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- index.js:612-634 (handler)MCP tool handler method that retrieves connection health from ConnectionManager, adds pool stats from PerformanceMonitor, and formats as JSON response.getConnectionHealth() { const poolStats = this.performanceMonitor.getPoolStats(); const connectionHealth = this.connectionManager.getConnectionHealth ? this.connectionManager.getConnectionHealth() : { connected: true, status: 'Connected' }; return [ { type: 'text', text: JSON.stringify( { success: true, data: { connection: connectionHealth, pool: poolStats } }, null, 2 ) } ]; }
- lib/tools/tool-registry.js:136-140 (schema)Tool schema definition including name, description, and empty input schema (no parameters required). Used for MCP tool listing and validation.{ name: 'get_connection_health', description: 'Get connection pool health metrics and diagnostics', inputSchema: { type: 'object', properties: {} } }
- index.js:241-243 (registration)Registers the ListTools handler which returns all tools including get_connection_health via getAllTools() from tool-registry.this.server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: getAllTools() }));
- Core helper method that inspects the SQL Server connection pool and returns detailed health metrics including connection status, pool stats, and optional SSL info.getConnectionHealth() { if (!this.pool) { return { connected: false, status: 'No connection pool' }; } const health = { connected: this.pool.connected, connecting: this.pool.connecting, healthy: this.pool.healthy, status: this.pool.connected ? 'Connected' : 'Disconnected', pool: { size: this.pool.size, available: this.pool.available, pending: this.pool.pending, borrowed: this.pool.borrowed } }; // Try to extract SSL/TLS certificate information if encryption is enabled if (this.pool.connected && process.env.SQL_SERVER_ENCRYPT === 'true') { health.ssl = this._extractSSLInfo(); } return health; }