Skip to main content
Glama

health_check

Monitor server health, verify tool availability, and assess environment status for mobile development workflows.

Instructions

Check server health, tool availability and environment status

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
verboseNoInclude detailed tool analysis and recommendations

Implementation Reference

  • The core handler function for the 'health_check' tool. It validates the environment, maps tool availability, generates a health report using generateHealthCheckReport, and optionally provides detailed analysis of working/broken tools.
    handler: async (args: any) => { const env = await validateEnvironment(); const verbose = args?.verbose || false; // Convert env.availableTools to match RequiredTool enum format const toolAvailability: Record<string, boolean> = {}; for (const [toolName, isAvailable] of Object.entries(env.availableTools)) { // Map common tool names to RequiredTool enum values const mappedToolName = toolName === 'native-run' ? RequiredTool.NATIVE_RUN : toolName === 'adb' ? RequiredTool.ADB : toolName === 'flutter' ? RequiredTool.FLUTTER : toolName === 'xcrun' ? RequiredTool.XCRUN : toolName === 'xcodebuild' ? RequiredTool.XCODEBUILD : toolName as RequiredTool; toolAvailability[mappedToolName] = isAvailable as boolean; } const healthReport = generateHealthCheckReport(toolAvailability); const baseHealth = { success: true, data: { server: 'mcp-mobile-server', version: '1.0.0', status: 'healthy', timestamp: new Date().toISOString(), registeredTools: tools.size, environment: env, toolHealth: { totalAvailable: healthReport.totalTools, expectedWorking: healthReport.expectedWorkingTools, safeForTesting: healthReport.safeForTesting, byCategory: healthReport.categoryCounts, byPlatform: healthReport.platformCounts, }, activeProcesses: Array.from(globalProcessMap.entries()).map(([key, pid]) => ({ key, pid })) } }; if (verbose) { // Add detailed analysis const workingTools = Object.entries(TOOL_REGISTRY).filter(([_, toolInfo]) => { return toolInfo.requiredTools.every(req => toolAvailability[req]); }); const brokenTools = Object.entries(TOOL_REGISTRY).filter(([_, toolInfo]) => { return !toolInfo.requiredTools.every(req => toolAvailability[req]); }); (baseHealth.data as any).detailedAnalysis = { workingTools: workingTools.map(([name, info]) => ({ name, category: info.category, platform: info.platform, description: info.description, safeForTesting: info.safeForTesting })), brokenTools: brokenTools.map(([name, info]) => ({ name, category: info.category, platform: info.platform, description: info.description, missingRequirements: info.requiredTools.filter(req => !toolAvailability[req]) })), recommendations: await fallbackManager.generateFallbackRecommendations() }; } return baseHealth; }
  • Input schema for the health_check tool, defining an optional 'verbose' boolean parameter.
    inputSchema: { type: 'object', properties: { verbose: { type: 'boolean', description: 'Include detailed tool analysis and recommendations' } }, required: [] },
  • src/server.ts:73-160 (registration)
    Registration of the 'health_check' tool in the MCP tools Map, including name, description, schema, and handler.
    // Register health check tool tools.set('health_check', { name: 'health_check', description: 'Check server health, tool availability and environment status', inputSchema: { type: 'object', properties: { verbose: { type: 'boolean', description: 'Include detailed tool analysis and recommendations' } }, required: [] }, handler: async (args: any) => { const env = await validateEnvironment(); const verbose = args?.verbose || false; // Convert env.availableTools to match RequiredTool enum format const toolAvailability: Record<string, boolean> = {}; for (const [toolName, isAvailable] of Object.entries(env.availableTools)) { // Map common tool names to RequiredTool enum values const mappedToolName = toolName === 'native-run' ? RequiredTool.NATIVE_RUN : toolName === 'adb' ? RequiredTool.ADB : toolName === 'flutter' ? RequiredTool.FLUTTER : toolName === 'xcrun' ? RequiredTool.XCRUN : toolName === 'xcodebuild' ? RequiredTool.XCODEBUILD : toolName as RequiredTool; toolAvailability[mappedToolName] = isAvailable as boolean; } const healthReport = generateHealthCheckReport(toolAvailability); const baseHealth = { success: true, data: { server: 'mcp-mobile-server', version: '1.0.0', status: 'healthy', timestamp: new Date().toISOString(), registeredTools: tools.size, environment: env, toolHealth: { totalAvailable: healthReport.totalTools, expectedWorking: healthReport.expectedWorkingTools, safeForTesting: healthReport.safeForTesting, byCategory: healthReport.categoryCounts, byPlatform: healthReport.platformCounts, }, activeProcesses: Array.from(globalProcessMap.entries()).map(([key, pid]) => ({ key, pid })) } }; if (verbose) { // Add detailed analysis const workingTools = Object.entries(TOOL_REGISTRY).filter(([_, toolInfo]) => { return toolInfo.requiredTools.every(req => toolAvailability[req]); }); const brokenTools = Object.entries(TOOL_REGISTRY).filter(([_, toolInfo]) => { return !toolInfo.requiredTools.every(req => toolAvailability[req]); }); (baseHealth.data as any).detailedAnalysis = { workingTools: workingTools.map(([name, info]) => ({ name, category: info.category, platform: info.platform, description: info.description, safeForTesting: info.safeForTesting })), brokenTools: brokenTools.map(([name, info]) => ({ name, category: info.category, platform: info.platform, description: info.description, missingRequirements: info.requiredTools.filter(req => !toolAvailability[req]) })), recommendations: await fallbackManager.generateFallbackRecommendations() }; } return baseHealth; } });
  • TOOL_REGISTRY entry defining metadata for the 'health_check' tool, such as category, platform, requirements, and performance expectations.
    'health_check': { name: 'health_check', category: ToolCategory.ESSENTIAL, platform: 'cross-platform', requiredTools: [], description: 'Check server health and tool availability', safeForTesting: true, performance: { expectedDuration: 1000, timeout: 10000 } },
  • Helper function that generates a detailed health check report based on available tools, counting by category, platform, requirements, safe testing tools, and expected working tools. Used by the health_check handler.
    export function generateHealthCheckReport(availableTools: Record<string, boolean>): HealthCheckReport { const allTools = Object.values(TOOL_REGISTRY); const categoryCounts = { [ToolCategory.ESSENTIAL]: 0, [ToolCategory.DEPENDENT]: 0, [ToolCategory.OPTIONAL]: 0, }; const platformCounts: Record<string, number> = {}; const requirementCounts: Partial<Record<RequiredTool, number>> = {}; let safeForTesting = 0; let expectedWorkingTools = 0; allTools.forEach(tool => { // Count by category categoryCounts[tool.category]++; // Count by platform platformCounts[tool.platform] = (platformCounts[tool.platform] || 0) + 1; // Count by requirements tool.requiredTools.forEach(req => { requirementCounts[req] = (requirementCounts[req] || 0) + 1; }); // Count safe for testing if (tool.safeForTesting) { safeForTesting++; } // Check if tool should work with available system tools const hasAllRequiredTools = tool.requiredTools.every(req => availableTools[req]); if (hasAllRequiredTools) { expectedWorkingTools++; } }); return { totalTools: allTools.length, categoryCounts, platformCounts, requirementCounts, safeForTesting, expectedWorkingTools, }; }

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/cristianoaredes/mcp-mobile-server'

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