Skip to content

vMCP oscillates between Modern and Legacy revision, failing every other health check #6154

Closed

Description

@amirejaz

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:

  1. Cache says Modern. modernDiscover runs. github-mcp-server answers server/discover with a body that has no resultType, so the client raises errLegacyResponseBody. 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.

  2. Cache says Legacy. legacyListCapabilities → legacyInit succeeds. legacyInit then reads the negotiated protocol version off the InitializeResult and, 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: 2 the backend flaps in and out of degraded, and the gateway flaps between Ready and Failed.
  • 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 legacyInit promote 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 actual server/discover round trip.
  • Or treat a server/discover result 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

  1. added
    bug
    vmcp
    on Jul 31, 2026
  2. added
    needs-triage
    on Jul 31, 2026
  3. removed
    needs-triage
    on Jul 31, 2026
  4. amirejaz commented on Jul 31, 2026

    @amirejaz
    ContributorAuthor

    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.Initialize silently drops the caller's requested protocol version.

    initializeClient (pkg/vmcp/client/client.go:849) asks for mcp.LATEST_PROTOCOL_VERSION, which is 2025-11-25:

    result, err := c.Initialize(ctx, mcp.InitializeRequest{
        Params: mcp.InitializeParams{
            ProtocolVersion: mcp.LATEST_PROTOCOL_VERSION,   // "2025-11-25"

    But toolhive-core/mcpcompat/client/client.go contains zero references to ProtocolVersion — it converts ClientInfo and ClientCapabilities into 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-server v1.6.0 is dual-era and supports that version, so per the MCP lifecycle spec it echoes it back. Verified against a virgin backend:

    requested negotiated
    2025-11-25 2025-11-25
    2026-07-28 2026-07-28

    So the vMCP handshake negotiates 2026-07-28 even though the code asked for 2025-11-25.

    The loop

    1. probeRevision runs server/discover. GitHub's response has supportedVersions including 2026-07-28 but no resultType, so modernCall raises errLegacyResponseBody and the probe correctly caches Legacy.
    2. legacyInit then 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.
    3. Next cycle the cache says Modern, modernDiscover hits the same resultType-less body, errLegacyResponseBody fires, and dispatch deliberately does not retry. Health check fails. reclassify re-probes back to Legacy.
    4. Next cycle is Legacy, succeeds, and step 2 repeats.

    Chronological trace, 10s interval:

    00:41:12  probe -> not Modern (Legacy)              health check succeeded
    00:41:22  probe -> not Modern; reclassified 2026-07-28 -> 2025-11-25   health check FAILED
    00:41:32  (no probe, cache hit)                     health check succeeded
    00:41:42  probe -> not Modern; reclassified 2026-07-28 -> 2025-11-25   health check FAILED
    00:41:52  (no probe, cache hit)                     health check succeeded
    

    What this means for the fix

    The negotiated version on a Legacy initialize is not proof that the backend serves the Modern wire shape. github-mcp-server demonstrates the two can disagree: it negotiates 2026-07-28 over the Legacy handshake while its server/discover response is not a valid Modern envelope. server/discover is the authoritative signal; the negotiated version is at best a hint.

    Suggested fix, minimal and preserving the original intent of the promotion:

    legacyInit should only promote a backend to Modern when there is no cached revision — that is, when probeRevision never 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 (dispatch falls 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.Initialize should honour the requested ProtocolVersion rather than silently dropping it. Right now no caller can control the version it negotiates.

  5. added a commit that references this issue on Jul 31, 2026
    09dfc7b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugvmcp

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions