get_health_status
Retrieve the health status of the npm-dev-mcp server to monitor its operations and check detailed system reports for troubleshooting and maintenance.
Instructions
MCPサーバーのヘルス状態を取得
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| detailed | No | 詳細なヘルスレポートを取得するかどうか(デフォルト: false) |
Implementation Reference
- src/tools/getHealthStatus.ts:21-75 (handler)The main handler function that executes the tool logic. Performs health checks using HealthChecker instance, handles detailed or basic reports, logs activities, and returns JSON-formatted status.export async function getHealthStatus(args: { detailed?: boolean } = {}): Promise<string> { const logger = Logger.getInstance(); const healthChecker = HealthChecker.getInstance(); try { logger.info('Getting health status', { detailed: args.detailed }); if (args.detailed) { // 詳細なヘルスレポートを取得 const report = await healthChecker.generateHealthReport(); logger.info('Generated detailed health report'); return JSON.stringify({ success: true, message: 'MCPサーバーの詳細ヘルス状態を取得しました', report: JSON.parse(report) }); } else { // 基本的なヘルス状態を取得 const status = await healthChecker.performHealthCheck(); logger.info('Health status retrieved', { isHealthy: status.isHealthy, devServerStatus: status.devServerStatus }); return JSON.stringify({ success: true, message: `MCPサーバーは${status.isHealthy ? '正常' : '異常'}状態です`, health: { isHealthy: status.isHealthy, uptime: Math.floor(status.uptime / 1000), devServerStatus: status.devServerStatus, memoryUsage: { heapUsed: Math.floor(status.memoryUsage.heapUsed / 1024 / 1024), rss: Math.floor(status.memoryUsage.rss / 1024 / 1024) }, checks: status.checks, lastError: status.lastError, timestamp: status.timestamp } }); } } catch (error) { logger.error('Failed to get health status', { error }); return JSON.stringify({ success: false, message: `ヘルス状態の取得に失敗しました: ${error}`, error: String(error) }); } }
- src/tools/getHealthStatus.ts:5-19 (schema)Defines the tool schema including name, description, and input schema with optional 'detailed' boolean parameter.export const getHealthStatusSchema: Tool = { name: 'get_health_status', description: 'MCPサーバーのヘルス状態を取得', inputSchema: { type: 'object', properties: { detailed: { type: 'boolean', description: '詳細なヘルスレポートを取得するかどうか(デフォルト: false)', default: false } }, additionalProperties: false } };
- src/index.ts:55-65 (registration)Registers the tool schema in the list of available tools for ListToolsRequestHandler.const tools = [ scanProjectDirsSchema, startDevServerSchema, getDevStatusSchema, getDevLogsSchema, stopDevServerSchema, restartDevServerSchema, getHealthStatusSchema, recoverFromStateSchema, autoRecoverSchema, ];
- src/index.ts:187-195 (registration)Dispatches tool calls to the getHealthStatus handler function in the CallToolRequestHandler switch statement.case 'get_health_status': return { content: [ { type: 'text', text: await getHealthStatus(args as { detailed?: boolean }), }, ], };
- src/initialization/MCPServerInitializer.ts:13-23 (registration)Defines service dependencies for the get_health_status tool, requiring 'healthChecker' service.export const SERVICE_DEPENDENCIES = { 'scan_project_dirs': ['projectContext'], 'start_dev_server': ['stateManager'], 'get_dev_status': ['stateManager'], 'get_dev_logs': ['stateManager'], 'stop_dev_server': ['stateManager'], 'restart_dev_server': ['stateManager'], 'get_health_status': ['healthChecker'], 'recover_from_state': ['stateManager'], 'auto_recover': ['stateManager', 'healthChecker'] } as const;