Enhance the HealthService with transparent caching and update the MCP server
startup to handle unhealthy states gracefully.
Acceptance Criteria
HealthService Changes:
- Add private caching fields:
#cachedHealth, #lastCheckTime, #cacheDuration
- Refactor current
healthcheck() logic into #performHealthCheck()
- Update
healthcheck() to use cache (5 min TTL) before calling #performHealthCheck()
- Add
ensureHealthy() method that throws if status is 'unhealthy'
- No changes to OpenAPI spec (caching is transparent)
MCP Server Changes:
Update mcp-stdio.mjs startup:
- Call
healthcheck() on startup
- If unhealthy: log warnings but don't abort
- Inform user server will continue but tools may fail
Update tool call handler:
- Call
HealthService.ensureHealthy() before callTool()
- Catch and return error to agent if unhealthy
- Use cached result (minimal overhead)
Benefits
- Performance: Avoids redundant health checks
- Resilience: Server doesn't crash on startup if
gh missing
- Recovery: User can run
gh auth login and tools will work
- UX: Clear errors guide users to fix issues
Enhance the HealthService with transparent caching and update the MCP server startup to handle unhealthy states gracefully.
Acceptance Criteria
HealthService Changes:
#cachedHealth,#lastCheckTime,#cacheDurationhealthcheck()logic into#performHealthCheck()healthcheck()to use cache (5 min TTL) before calling#performHealthCheck()ensureHealthy()method that throws if status is 'unhealthy'MCP Server Changes:
Update
mcp-stdio.mjsstartup:healthcheck()on startupUpdate tool call handler:
HealthService.ensureHealthy()beforecallTool()Benefits
ghmissinggh auth loginand tools will work