health_check
Monitor server health, performance, and operational metrics in real-time using a comprehensive dashboard. Perform checks on API limits, system health, dependencies, and configurations for actionable insights.
Instructions
🏥 System Health Check - Monitor server health, performance, and operational metrics. Provides comprehensive monitoring dashboard with real-time insights.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| checks | No | Types of health checks to perform | |
| options | No |
Implementation Reference
- src/index.ts:711-786 (handler)The handler function that implements the core logic of the 'health_check' tool. It performs various health checks including API limits, system monitoring, dependencies, and configuration status, and returns formatted health metrics.async function handleHealthCheck(args: any) { try { const { checks = ['api-limits', 'system-health', 'monitoring'], options = {} } = args; // Get comprehensive health status from monitoring system const monitoringHealth = monitoring.getHealthStatus(); const serverMetrics = monitoring.getMetrics(); const health: any = { status: monitoringHealth.status, timestamp: new Date().toISOString(), checks: { ...monitoringHealth.checks }, metrics: options.include_metrics ? { uptime: serverMetrics.uptime, memory: serverMetrics.memory, version: '1.0.0', requestCount: serverMetrics.requestCount, errorCount: serverMetrics.errorCount, averageResponseTime: serverMetrics.responseTime.average, toolUsage: serverMetrics.toolUsage, } : undefined, }; // Add additional checks based on requested types for (const check of checks) { switch (check) { case 'api-limits': try { health.checks[check] = await githubService.checkApiLimits(); } catch (error: any) { health.checks[check] = { status: 'error', error: error.message }; } break; case 'monitoring': health.checks[check] = { status: 'healthy', totalRequests: serverMetrics.requestCount, errorRate: serverMetrics.requestCount > 0 ? Math.round((serverMetrics.errorCount / serverMetrics.requestCount) * 100) : 0, uptime: serverMetrics.uptime, memoryUsage: Math.round((serverMetrics.memory.heapUsed / serverMetrics.memory.heapTotal) * 100), }; break; case 'dependencies': health.checks[check] = { status: 'healthy' }; break; case 'configuration': health.checks[check] = { status: 'healthy', hasGitHubToken: !!config.github.token, hasOpenRouterKey: !!config.openrouter.apiKey, logLevel: config.logging.level, maxResponseTokens: config.response.maxTokens, }; break; } } // Add performance insights if requested if (options.include_insights) { const insights = monitoring.getPerformanceInsights(); health.insights = insights; } // Add recent logs if requested if (options.include_logs) { const logBuffer = log.getLogBuffer(); health.recentLogs = logBuffer.slice(-10); } const response = createResponse(health); return formatToolResponse(response); } catch (error) { const response = createResponse(null, error); return formatToolResponse(response); } }
- src/index.ts:290-292 (registration)The switch case in the CallToolRequestSchema handler that registers and dispatches the 'health_check' tool to its handler function.case 'health_check': result = await handleHealthCheck(args); break;
- src/tools/consolidated.ts:597-640 (schema)The tool definition in consolidatedTools array, including name, description, and inputSchema for validation, used for tool registration and listing.{ name: 'health_check', description: '🏥 System Health Check - Monitor server health, performance, and operational metrics. Provides comprehensive monitoring dashboard with real-time insights.', inputSchema: { type: 'object', properties: { checks: { type: 'array', items: { type: 'string', enum: ['api-limits', 'system-health', 'monitoring', 'dependencies', 'configuration'], }, description: 'Types of health checks to perform', default: ['api-limits', 'system-health', 'monitoring'], }, options: { type: 'object', properties: { include_metrics: { type: 'boolean', description: 'Include comprehensive system metrics in response', default: false, }, include_insights: { type: 'boolean', description: 'Include performance insights and recommendations', default: false, }, include_logs: { type: 'boolean', description: 'Include recent log entries', default: false, }, include_diagnostics: { type: 'boolean', description: 'Include diagnostic information', default: false, }, }, }, }, required: [], }, },