Repository navigation
Description
Summary
A vMCP gateway aggregating a stdio backend oscillates between the Modern and Legacy MCP revisions, failing roughly every other health check. The backend is repeatedly marked degraded and the gateway alternates between Ready and Failed with No routable backends.
The user-visible symptom is the same as #5890 — a stdio backend degrading the whole gateway — but the cause is different and unrelated. #5890 is a duplicate-initialize failure that only occurs on vMCP v0.40.1; this one only occurs from v0.41.0 onwards, where the dual-era revision probing was introduced.
Reproduction
- vMCP v0.41.0 (or
main), CLI mode - One stdio backend:
thv run github→ghcr.io/github/github-mcp-server:v1.6.0,transport: stdio healthCheckInterval: 10s
Observed over a ~4 minute run with a valid GitHub token:
18 failed to modern discover
14 health check succeeded
12 health check failed
The failures alternate with the successes. Each failing cycle logs:
DEBUG health check failed for backend
error="backend unavailable: failed to modern discover for backend gh-vmcp:
backend returned a Legacy-shaped body (no resultType); it may have executed"
WARN backend MCP revision reclassified after mismatch old=2026-07-28 new=2025-11-25
DEBUG status update phase=Failed message="No routable backends (1 degraded, 0 unhealthy, 0 unknown)"
Note old=2026-07-28 on every failing cycle: the cached revision is back to Modern each time, despite having been reclassified to Legacy on the previous one.
Mechanism
Two behaviours that are each correct in isolation form a closed loop:
-
Cache says Modern.
modernDiscoverruns.github-mcp-serveranswersserver/discoverwith a body that has noresultType, so the client raiseserrLegacyResponseBody.dispatch(pkg/vmcp/client/client.go:1548) reclassifies the backend to Legacy but deliberately does not retry, because a Legacy-shaped success body means the backend may already have executed the request. The health check fails. -
Cache says Legacy.
legacyListCapabilities→legacyInitsucceeds.legacyInitthen reads the negotiated protocol version off theInitializeResultand, when it is Modern, flips the cache straight back to Modern (pkg/vmcp/client/client.go,if negotiatedVersion == mcpparser.MCPVersionModern { h.setRevision(backendID, mcpparser.RevisionModern) }). The health check succeeds.
Step 2 undoes step 1's correction, so the next cycle re-enters step 1. The revision never settles and the backend never stays healthy.
The trigger is a backend that negotiates 2026-07-28 on the Legacy initialize handshake while not returning a spec-shaped server/discover result. github-mcp-server v1.6.0 (go-sdk v1.7) appears to do exactly that.
Impact
- Roughly 50% of health checks fail against an affected stdio backend.
- With
unhealthyThreshold: 2the backend flaps in and out of degraded, and the gateway flaps betweenReadyandFailed. - Every other capability the gateway aggregates is dragged down with it whenever the gateway reports
Failed. - Affects v0.41.0 and
main. Not present in v0.40.1, which has no revision probing.
Not verified
I inferred that the Legacy handshake negotiates 2026-07-28 from the old=2026-07-28 value in the reclassification warning rather than by capturing the InitializeResult directly. That single link in the chain is worth confirming before settling on a fix.
Possible directions
- Do not let
legacyInitpromote a backend to Modern when the cached revision was reclassified away from Modern by a discover mismatch — that reclassification is the more authoritative signal, since it came from an actualserver/discoverround trip. - Or treat a
server/discoverresult that fails Modern shape validation as a sticky "not Modern" fact for the backend, rather than something a later negotiated version can override. - Either way the oscillation, not just the individual failure, is the thing to fix.
Activity
amirejaz commentedon Jul 31, 2026
Correcting the mechanism in the description — I had it wrong. The oscillation is real and the symptoms above are accurate, but the cause is one level deeper and now fully traced.
Actual root cause
mcpcompat/client.Initializesilently drops the caller's requested protocol version.initializeClient(pkg/vmcp/client/client.go:849) asks formcp.LATEST_PROTOCOL_VERSION, which is2025-11-25:But
toolhive-core/mcpcompat/client/client.gocontains zero references toProtocolVersion— it convertsClientInfoandClientCapabilitiesinto go-sdk types and never plumbs the version through. go-sdk's client therefore handshakes with its own default,latestProtocolVersion = protocolVersion20260728(go-sdk/mcp/shared.go:50), i.e.2026-07-28.github-mcp-serverv1.6.0 is dual-era and supports that version, so per the MCP lifecycle spec it echoes it back. Verified against a virgin backend:2025-11-252025-11-252026-07-282026-07-28So the vMCP handshake negotiates
2026-07-28even though the code asked for2025-11-25.The loop
probeRevisionrunsserver/discover. GitHub's response hassupportedVersionsincluding2026-07-28but noresultType, somodernCallraiseserrLegacyResponseBodyand the probe correctly caches Legacy.legacyInitthen succeeds and reads the negotiated version —2026-07-28— and promotes the cache to Modern (client.go:1483). This is the step that undoes the probe's authoritative answer.modernDiscoverhits the sameresultType-less body,errLegacyResponseBodyfires, anddispatchdeliberately does not retry. Health check fails.reclassifyre-probes back to Legacy.Chronological trace, 10s interval:
What this means for the fix
The negotiated version on a Legacy
initializeis not proof that the backend serves the Modern wire shape.github-mcp-serverdemonstrates the two can disagree: it negotiates2026-07-28over the Legacy handshake while itsserver/discoverresponse is not a valid Modern envelope.server/discoveris the authoritative signal; the negotiated version is at best a hint.Suggested fix, minimal and preserving the original intent of the promotion:
legacyInitshould only promote a backend to Modern when there is no cached revision — that is, whenprobeRevisionnever ran or was inconclusive. When a probe has authoritatively classified the backend, its answer must not be overridden by a handshake hint.This keeps the self-healing case the promotion was written for (
dispatchfalls back to Legacy uncached when a probe errors, and the next successful handshake can still correct it) while removing the contradiction that drives the oscillation.Separately, and independently worth fixing upstream in
toolhive-core:mcpcompat/client.Initializeshould honour the requestedProtocolVersionrather than silently dropping it. Right now no caller can control the version it negotiates.Confirm Modern promotion with a discover probe (stacklok#6158)
Expire the refuted-Modern-hint memory after a TTL (#6185)