You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
vMCP backend revision cache has no success/TTL re-probe (stale on stateless redeploy) #5992
Part of #5743 / follow-up to the go-sdk v1.7 / MCP 2026-07-28 adoption (#5754). Surfaced by the Opus review panel.
Context
httpBackendClient caches each backend's negotiated MCP revision (probeRevision → setRevision). The cache self-corrects only on error (dispatch → isRevisionMismatch → reclassify), not on success and with no TTL.
The gap
If a backend is first probed Legacy (2025-11-25, stateful) and is later redeployed stateless/Modern (2026-07-28), the cache stays pinned Legacyindefinitely:
Wire behavior stays correct — the go-sdk v1.7 client's Connect is Modern-first and negotiates Modern transparently even on vMCP's "Legacy" code path (via server/discover), so calls still hit the right protocol. This is why it's not a correctness bug.
ButCachedRevision (which feeds CRD status / telemetry read-models) reports Legacy forever — an operator-facing status inaccuracy — and every call pays the heavier per-call legacy initialize + discover + subscribe + Close handshake instead of using the lighter stateless path.
The reverse and dangerous direction — a Modern-cached backend redeployed stateful/Legacy — is self-corrected: discover now lacks 2026-07-28 → errModernNegotiatedDown → isRevisionMismatch (Modern arm) → reclassify → Legacy. So only the Legacy→Modern transition is left stale.
Proposed fix
Add a TTL-based re-probe (or success-path re-validation) to the revision cache so a redeployed backend's revision is refreshed, correcting both the telemetry/status inaccuracy and the per-call handshake overhead. The code already carries a NOTE deferring this.
Also worth a test
The "stale Legacy cache is harmless" property is currently pinned only for ListCapabilities (forwarding=false). The forwarding CallTool path (WithContinuousListening standalone GET stream) against a real stateless Modern backend is untested — low risk, but the harmlessness claim is asserted more broadly than it's covered.
Current state of this issue after the go-sdk v1.7 adoption work: mostly obsolete, with one narrow residual gap.
What's already fixed (issue's premises are stale)
The issue predates the in-band self-heal that shipped in legacyInit (pkg/vmcp/client/client.go:1507-1536, with TestListCapabilities_MisCachedLegacy_SelfHealsViaSDKNegotiation and TestLegacyInit_SelfHealsRevisionCache):
A Legacy-cached backend redeployed genuinely Modern self-heals in-band: the go-sdk client negotiates Modern on the Legacy path, legacyInit reads the negotiated version off every initialize, and — gated by a confirming probeRevision — flips the cache. Both the wire behavior AND the status/telemetry read-model (CachedRevision → health monitor → CRD status) correct themselves on the next call.
The "also worth a test" half shipped: TestCallTool_MisCachedLegacy_ForwardingAgainstStatelessBackend covers the forwarding CallTool path against a real stateless Modern backend.
So the indefinite-stale-Legacy scenario the issue describes only survives in one narrow shape:
The residual gap: modernHintRefuted is permanent
A backend that lied once — negotiates 2026-07-28 on the Legacy initialize but answers server/discover with a Legacy-shaped body (github-mcp-server v1.6.0 is the field example, #6154) — gets recorded in modernHintRefuted so the confirming probe runs once rather than on every call. That memory is never evicted. If such a backend is later redeployed as a genuinely Modern backend (hint and discover now agree), the refuted flag skips the confirming probe forever and the cache stays Legacy.
Impact is bounded: wire behavior stays correct (SDK negotiates Modern transparently on the Legacy path — same harmlessness argument as the original issue), but CachedRevision reports Legacy indefinitely and every call pays the heavier handshake.
Options
TTL or cap the refutation memory — re-allow the confirming probe periodically (e.g. once per N minutes per backend) instead of never. A lying backend then costs one extra probe per window instead of per call; a redeemed backend self-heals within one window. Small, targeted change in legacyInit.
Clear the refutation on any successful Modern discover — no new machinery: if a later probe (driven by dispatch's reclassify path) ever returns Modern, drop the flag. Doesn't fully close the gap (nothing drives that probe while the flag suppresses it) unless paired with (1).
Close as acceptable — bounded harm (status accuracy + handshake weight, not correctness), and the 2026-07-28 adoption makes the lying-backend population shrink over time.
My recommendation: option 1 — it's ~15 lines and removes the last unbounded staleness in the revision cache. Happy to implement if that sounds right.
Activity
Support MCP 2026-07-28 spec (go-sdk v1.7 via core)
Classify -32022 and SSE targets as Legacy
Self-heal a stale Legacy revision from initialize
Classify -32022 and SSE backends as Legacy, sync stale comments (#5997)
Support MCP 2026-07-28 spec (go-sdk v1.7 via toolhive-core) (#5993)
Skip pointless backend connect for Modern backends
Pin forwarding tools/call against a stale-Legacy stateless backend
Pin forwarding tools/call against a stale-Legacy stateless backend (#…
Mirror x-mcp-header params on the Modern egress (#6014)
Mirror x-mcp-header params on the Modern egress (#6014)
Reject backend tools with invalid x-mcp-header (#6013)
Skip pointless backend connect for Modern backends
Bridge era-mismatched client×backend cells in vMCP (#6006)
JAORMX commentedon Aug 4, 2026
Current state of this issue after the go-sdk v1.7 adoption work: mostly obsolete, with one narrow residual gap.
What's already fixed (issue's premises are stale)
The issue predates the in-band self-heal that shipped in
legacyInit(pkg/vmcp/client/client.go:1507-1536, withTestListCapabilities_MisCachedLegacy_SelfHealsViaSDKNegotiationandTestLegacyInit_SelfHealsRevisionCache):legacyInitreads the negotiated version off every initialize, and — gated by a confirmingprobeRevision— flips the cache. Both the wire behavior AND the status/telemetry read-model (CachedRevision→ health monitor → CRD status) correct themselves on the next call.TestCallTool_MisCachedLegacy_ForwardingAgainstStatelessBackendcovers the forwardingCallToolpath against a real stateless Modern backend.So the indefinite-stale-Legacy scenario the issue describes only survives in one narrow shape:
The residual gap:
modernHintRefutedis permanentA backend that lied once — negotiates 2026-07-28 on the Legacy initialize but answers
server/discoverwith a Legacy-shaped body (github-mcp-server v1.6.0 is the field example, #6154) — gets recorded inmodernHintRefutedso the confirming probe runs once rather than on every call. That memory is never evicted. If such a backend is later redeployed as a genuinely Modern backend (hint and discover now agree), the refuted flag skips the confirming probe forever and the cache stays Legacy.Impact is bounded: wire behavior stays correct (SDK negotiates Modern transparently on the Legacy path — same harmlessness argument as the original issue), but
CachedRevisionreports Legacy indefinitely and every call pays the heavier handshake.Options
legacyInit.My recommendation: option 1 — it's ~15 lines and removes the last unbounded staleness in the revision cache. Happy to implement if that sounds right.
Expire the refuted-Modern-hint memory after a TTL (stacklok#6185)