Skip to main content
Glama
TheAlchemist6

CodeCompass MCP

health_check

Monitor server health, performance, and operational metrics to identify issues and ensure system reliability through real-time insights.

Instructions

🏥 System Health Check - Monitor server health, performance, and operational metrics. Provides comprehensive monitoring dashboard with real-time insights.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
checksNoTypes of health checks to perform
optionsNo

Implementation Reference

  • The primary handler function for the 'health_check' tool. It performs system health checks including monitoring status, API limits via githubService, configuration validation, and optional metrics, insights, and logs.
    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);
      }
    }
  • The tool definition object including name, description, and inputSchema for the 'health_check' tool, used for registration and validation.
    {
      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: [],
      },
    },
  • src/index.ts:290-292 (registration)
    The switch case registration in the main CallToolRequestSchema handler that routes 'health_check' calls to the handleHealthCheck function.
    case 'health_check':
      result = await handleHealthCheck(args);
      break;

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/TheAlchemist6/codecompass-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server