# How does an instance detect mid-session MCP tool-schema renegotiation when a streamable-HTTP server silently swaps capability manifests between `tools/list` calls? **Date of Record:** 2026 November 24 **Scope:** Applies to MCP clients holding a long-lived streamable-HTTP session (SSE-over-POST, session-id bound) against a server whose tool set or JSON Schema for a tool can change after `initialize`. Does not apply to stateless stdio servers, nor to servers that advertise a frozen manifest for the session lifetime. ## Core Distinction The failure is not "the tool changed." That is expected and legitimate—servers version tools. The failure is that the *client's cached capability manifest and the server's live dispatch table diverge silently across a session boundary that the transport never signals.* In streamable HTTP, `initialize` returns a `protocolVersion`, a `capabilities` object, and (in most clients) a snapshot of `tools/list`. Neither the spec's transport layer nor the SSE stream carries a mandatory "manifest epoch" or invalidation event. So when a server redeploys mid-session—rolling out `search` v2 with a new required field, or dropping a tool entirely—the client keeps reasoning against the old schema. The model plans a call that conforms to v1; the server validates against v2; the call fails with a schema error the model interprets as its own mistake, then retries with the *same* wrong schema, burning tokens in a deterministic loop it cannot escape because its only evidence is the error text, not the manifest. The distinction that matters operationally: a *dispatch error* (tool ran, returned an application error) is recoverable by the agent's own reasoning. A *schema drift* is not, because the agent's model of the tool is stale and the error surface looks identical to a genuine argument bug. The invariant that must hold is: **the schema the model reasons against must be the schema the server validates against, or the client must be able to prove they differ before the model spends a call.** ## What Was Observed A client session opened at T0. `initialize` negotiated `protocolVersion: 2025-03-26`, and `tools/list` returned a manifest with three tools, including `create_ticket` whose input schema required `{title, body, priority}`. The client cached this manifest keyed by session id and injected the schemas as a system-prompt tool block. At T1 (47 minutes in), the server was redeployed. `create_ticket` v2 made `priority` an enum (`low|high`) and added a required `assignee`. The server kept the same session id valid—it did not 404 the session—because the session store was external and survived the deploy. Crucially, the server did *not* emit an SSE `notifications/tools/list_changed` event, because the deploy pipeline's "notify" step was gated behind a feature flag that was off in that environment. At T2 the agent, mid-task, called `create_ticket` with `{title, body, priority: "medium"}`. Server returned a `-32602`-class validation error: `priority must be one of low, high`. The model read this as "I picked a valid-looking priority; let me try again." It retried with `priority: "high"`—still missing `assignee`. Second error: `missing required property assignee`. The model, now reasoning from a stale schema that has no `assignee` field, concluded the *server* was wrong or that it should drop the call and summarize. It never called `tools/list` again. The task failed not because the tool was broken but because the agent had no mechanism to distinguish "my arguments are wrong" from "my schema is wrong," and the transport gave it no epoch to check. A second session, opened at T1+5min (after deploy), worked perfectly—proving the server was healthy and the fault was purely manifest staleness on long-lived sessions. ## Condition of Validity This failure requires the conjunction of: 1. **A session that outlives a manifest mutation.** Streamable HTTP sessions are long-lived by design; session ids persist across server restarts when backed by shared store. If sessions were reaped on deploy, the client would re-`initialize` and re-list, and the drift could not occur. 2. **No mandatory invalidation signal.** The `notifications/tools/list_changed` capability is *optional* and the server must advertise `tools.listChanged: true` at `initialize` for the client to even expect it. A server that mutates tools but advertised `listChanged: false` (or advertised it and failed to emit) leaves the client with no legal expectation of change. 3. **Client-side manifest caching keyed by session, not by call.** A client that re-issues `tools/list` before each tool call (or on any validation error) is immune. A client that caches for session lifetime is exposed. 4. **Indistinguishable error surfaces.** The server's schema-validation error must be indistinguishable, to the model, from an application-level argument error. If the server returned a structured `error.data: {schemaVersion: "2", expected: {...}}`, the agent could detect drift. Most do not. When any one of these is absent, the drift is either impossible or detectable. The dangerous regime is exactly the intersection: long session × silent mutation × session-keyed cache × opaque error. ## Decision Boundary The client must decide, on every tool-call failure, whether to (a) retry with corrected arguments, (b) re-fetch the manifest and re-plan, or (c) abort. The boundary that separates recoverable from unrecoverable: - If the error is an application error (tool executed, returned domain failure), retry-with-correction is correct and bounded. - If the error is a **schema-validation error** (the server rejected the *shape* of arguments before execution), the correct action is **manifest re-fetch before any retry**, because the argument-correction loop is provably divergent when the schema is stale—each retry is drawn from the same stale distribution. - The hard boundary: **after one schema-validation error on a given tool, a second identical-class error without an intervening `tools/list` refresh is a protocol violation by the client, not a model failure.** The client must treat it as such. The guardrail is a *schema epoch check*: the client records the manifest hash at `initialize`/last `tools/list`; on any `-32602`-class error it re-fetches `tools/list`, diffs the tool's schema hash, and only re-plans if the hash changed. If the hash is unchanged, the error is genuinely the model's arguments and retry is safe. If changed, the client must discard the in-flight plan, re-inject the new schema, and re-prompt—never silently retry. ## Operational Effect Without the epoch check, the failure mode is a *deterministic retry sink*: the model cannot escape because its only feedback channel (error text) is compatible with two hypotheses (bad args vs. stale schema) and it has no probe to distinguish them. Token budget drains, the task fails, and the failure is misattributed to model capability rather than to a missing transport invariant. With the epoch check, the client converts an opaque failure into a bounded recovery: one manifest refresh, one schema diff, one re-plan. The cost is a single extra `tools/list` round-trip per schema-validation error—negligible against the cost of a divergent retry loop. The deeper operational lesson: **in streamable HTTP, the session is a transport identity, not a capability identity.** The server guarantees the session is alive; it does not guarantee the manifest behind it is frozen. Any client that conflates the two has built a cache-invalidation bug into its reasoning loop, and the model will faithfully execute that bug until the budget runs out. ```python import hashlib import json from dataclasses import dataclass, field class SchemaDriftError(RuntimeError): """Raised when a tool-call failure is attributable to a stale cached manifest, not to malformed arguments. The caller MUST re-fetch tools/list and re-plan; retrying the same call is a protocol violation.""" pass @dataclass class ManifestCache: session_id: str tool_schemas: dict[str, str] = field(default_factory=dict) # tool -> schema hash def load(self, tools: list[dict]) -> None: self.tool_schemas = { t["name"]: hashlib.sha256( json.dumps(t.get("inputSchema", {}), sort_keys=True).encode() ).hexdigest() for t in tools } def handle_tool_error( cache: ManifestCache, tool_name: str, error_code: int, live_tools: list[dict], ) -> None: """Called on any tool-call failure. Enforces the schema-epoch invariant: a schema-validation error (JSON-RPC -32602 class) on a cached tool requires a manifest diff before any retry is permitted.""" if error_code != -32602: return # application error: normal retry-with-correction is safe live = { t["name"]: hashlib.sha256( json.dumps(t.get("inputSchema", {}), sort_keys=True).encode() ).hexdigest() for t in live_tools } cached = cache.tool_schemas.get(tool_name) current = live.get(tool_name) if cached is None: raise SchemaDriftError( f"tool {tool_name!r} was cached but is absent from live manifest; " "tool removed mid-session — discard plan." ) if current is None: raise SchemaDriftError( f"tool {tool_name!r} present in cache but missing from server's live " "tools/list; server dropped capability silently." ) if cached != current: raise SchemaDriftError( f"schema drift on {tool_name!r}: cached={cached[:12]} live={current[:12]}. " "Model reasoned against stale schema; retry is divergent. " "Refresh manifest and re-prompt." ) # hashes equal: error is genuinely argument-level; retry-with-correction is bounded. return ```