Skip to main content
Glama

health_check

Verify the operational status of the Android MCP Server and ADB connectivity by checking server uptime, device connections, and configuration details.

Instructions

Check the health status of the MCP server and ADB connectivity. Returns server uptime, ADB availability, connected device count, and configuration summary.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The async handler function that performs the health check logic, gathering ADB status, device info, and system metrics.
      async () => {
        return wrapHandler(async () => {
          const config = getConfig();
          const startTime = Date.now();
    
          // Check ADB is available
          let adbAvailable = false;
          let adbVersion = 'unknown';
          try {
            const versionResult = await adbExec(['version']);
            adbAvailable = versionResult.exitCode === 0;
            const versionMatch = versionResult.stdout.match(/Android Debug Bridge version ([\d.]+)/);
            if (versionMatch) adbVersion = versionMatch[1];
          } catch {
            adbAvailable = false;
          }
    
          // Count connected devices
          let deviceCount = 0;
          let devices: Array<{ id: string; status: string }> = [];
          try {
            const deviceList = await deviceManager.listDevices();
            devices = deviceList.map(d => ({ id: d.id, status: d.status }));
            deviceCount = deviceList.filter(d => d.status === 'device').length;
          } catch {
            // ADB may not be available
          }
    
          const toolMetrics = metrics.getToolMetrics();
          const totalCalls = Object.values(toolMetrics).reduce((sum, m) => sum + m.totalCalls, 0);
          const totalFailures = Object.values(toolMetrics).reduce((sum, m) => sum + m.failureCount, 0);
    
          return {
            content: [{
              type: 'text' as const,
              text: JSON.stringify({
                success: true,
                health: {
                  status: adbAvailable && deviceCount > 0 ? 'healthy' : adbAvailable ? 'degraded' : 'unhealthy',
                  adb: {
                    available: adbAvailable,
                    version: adbVersion,
                    path: config.adbPath,
                  },
                  devices: {
                    connected: deviceCount,
                    list: devices,
                  },
                  server: {
                    version: '1.0.0',
                    checkDurationMs: Date.now() - startTime,
                  },
                  config: {
                    maxActionsPerMinute: config.maxActionsPerMinute,
                    commandTimeoutMs: config.commandTimeoutMs,
                    maxRetries: config.maxRetries,
                    allowDestructiveOps: config.allowDestructiveOps,
                    allowedDeviceCount: config.allowedDevices.length,
                  },
                  metrics: {
                    totalToolCalls: totalCalls,
                    totalFailures: totalFailures,
                    successRate: totalCalls > 0 ? `${Math.round(((totalCalls - totalFailures) / totalCalls) * 100)}%` : 'N/A',
                  },
                },
              }, null, 2),
            }],
          };
        });
      }
    );
  • The MCP server tool registration for 'health_check'.
    server.registerTool(
      'health_check',
      {
        description: 'Check the health status of the MCP server and ADB connectivity. Returns server uptime, ADB availability, connected device count, and configuration summary.',
        inputSchema: {},
      },

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/divineDev-dotcom/android_mcp'

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