Repository navigation
feat(mcp): retry unhealthy servers and restore tools on recovery (#1655) - #1668
Conversation
nc-review: comments — 1 important@rishu685 — a few things worth a look, none blocking. PR #1668 implements MCP server recovery after unhealthy pings by re-polling at the configured interval, treating JSON-RPC 🟠 important · Issue #1655's proposed solution opens with 'Keep pinging unhealthy servers, with exponential backoff.' The diff removes the early-return guard so unhealthy servers are now polled, but it keeps the same 🔴 blocking · 🟠 a reviewer would ask for a change · ⚪ optional Automated code review — correctness, security, design, tests, plus duplicates and scope. A human still decides; this is not a substitute for review and is not exhaustive. The required status checks separately cover lint, formatting, types, unused dependencies, the test suite and the build. This bot never merges. Maintainers can rerun with |
|
Updated the implementation to include exponential backoff for retrying unhealthy MCP servers:
|
|
Thanks for the PR @rishu685 |
Fixes #1655
Continuous Health Checks on Unhealthy Servers (
source/mcp/mcp-client.ts):startHealthChecksso servers markedunhealthycontinue to be polled periodically on their configuredhealthCheckInterval.isLivenessResponseto treat JSON-RPC error responses (e.g.-32601 Method not found) as proof that the server process is alive.Automatic Tool Restoration on Recovery (
source/mcp/mcp-client.ts):restoreServerHealthto re-discover tools, resources, and prompts from the server when a ping succeeds, invalidate tool mapping cache, and transition health back toconnected.getToolEntries(forServerName?: string)to allow retrieving tool definitions for a specific server.Re-register Tools in ToolManager (
source/tools/tool-manager.ts):{ status: 'connected', serverName }health events inToolManagerto re-register restored tools in the activeToolRegistry.Documentation & Changeset:
docs/configuration/mcp-configuration.mdto reflect that unhealthy servers continue to be checked and restore their tools automatically upon response..changeset/mcp-retry-unhealthy-servers.md.Tests:
source/mcp/mcp-client.spec.tsandsource/tools/tool-manager.spec.tscovering unhealthy retry, tool restoration,-32601liveness handling, and tool re-registration inToolManager.Verification
pnpm test:ava source/mcp/mcp-client.spec.ts source/tools/tool-manager.spec.ts(all 165 tests passed)pnpm test:types(0 errors)biome check(0 errors)pnpm test:knip(0 issues)