get_connection_health
Check SQL Server connection pool health metrics and diagnose connectivity issues to maintain database reliability and performance.
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)Primary handler method for the 'get_connection_health' MCP tool. Retrieves connection health metrics from ConnectionManager and pool stats from PerformanceMonitor, formats as structured JSON response for MCP protocol.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 (registration)Tool registration in the central tool registry. Defines the tool name, description, and empty input schema. Included in PERFORMANCE_TOOLS array and exported via getAllTools() for MCP list_tools requests.{ name: 'get_connection_health', description: 'Get connection pool health metrics and diagnostics', inputSchema: { type: 'object', properties: {} } }
- Core helper function providing detailed connection pool health metrics: connection status, pool statistics (size, available, pending, borrowed), and optional SSL information.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; }
- index.js:323-326 (handler)MCP tool dispatcher switch case that routes 'get_connection_health' tool calls to the main getConnectionHealth() handler method.case 'get_connection_health': return { content: this.getConnectionHealth() };