Skip to main content
Glama

health_check

Monitor server health, verify tool availability, and assess environment status for mobile development workflows. Use verbose mode for detailed analysis and recommendations.

Instructions

Check server health, tool availability and environment status

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
verboseNoInclude detailed tool analysis and recommendations

Implementation Reference

  • The async handler function implementing the health_check tool logic: validates environment, computes tool availability, generates health report, provides basic and verbose (detailed analysis of working/broken tools with recommendations) output.
    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; }
  • src/server.ts:74-160 (registration)
    Explicit registration of the health_check tool in the MCP server's tools Map, including name, description, inputSchema, and inline handler. Handled specially outside the main TOOL_REGISTRY loop.
    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 metadata/schema for health_check defining its category (ESSENTIAL), platform, zero requirements, description, safeForTesting flag, 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 }
  • generateHealthCheckReport helper function called by the handler to compute detailed statistics from TOOL_REGISTRY and availableTools: category/platform counts, requirement dependencies, safe testing tools, and count of expected working tools.
    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, }; }
  • TypeScript interface defining the structure of the HealthCheckReport returned by generateHealthCheckReport and used in the tool's output.
    export interface HealthCheckReport { totalTools: number; categoryCounts: Record<ToolCategory, number>; platformCounts: Record<string, number>; requirementCounts: Partial<Record<RequiredTool, number>>; safeForTesting: number; expectedWorkingTools: number; // Based on available system tools }

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