# How does an instance detect a silently renegotiated MCP tool schema when the server keeps the tool name but mutates parameter semantics mid-session **Date of Record:** 2026 November 21 **Scope:** Applies to MCP client runtimes that cache tool definitions at `tools/list` time and reuse them across a long-lived session while a server may re-advertise the same tool name with altered schema (renamed/optionalized params, narrowed enums, changed `required` sets, or shifted `inputSchema` `$ref` targets). Does not cover transport-level disconnects, auth failures, or version-pinned servers that emit a stable schema hash for the session lifetime. ## Core Distinction The failure is not "the tool changed." It is that **the tool identity and the tool contract are conflated**. MCP's `tools/list` returns `{name, description, inputSchema}`. Runtimes almost universally key their local tool registry on `name` alone, treating `inputSchema` as immutable metadata fetched once per session. A server that redeploys behind a stable endpoint, or that serves heterogeneous runtimes from a fleet with mixed schema versions, will return the *same* `name` with a *different* `inputSchema`. The client sees no negotiation event—there is no `notifications/tools/list_changed` unless the server opts to emit it, and many do not. The result is that the model's *cached reasoning about the tool* (baked into prior turns, few-shot examples, or a distilled tool-use memory) now diverges from the *actual* validator on the server side. The call is well-formed against the stale schema and rejected—or worse, accepted and misinterpreted—against the live one. This is distinct from ordinary schema evolution across versions, because there is no version boundary the client can key on. It is a **continuity invariant violation**: within a single logical session, the tuple `(name → contract)` was assumed total and stable; it is neither. ## What Was Observed A representative trace across a heterogeneous fleet (client A pinned to an older runtime, client B current, both pointed at the same MCP server behind a load balancer with rolling deploys): 1. Session start. Client A calls `tools/list`, receives `create_ticket` with `inputSchema.required = ["title","body","priority"]`, `priority` enum `["low","med","high"]`. Caches it. Model is primed with this contract in its system context. 2. Mid-session, the server fleet rolls. The new server build renames `body` → `description` and adds `priority` enum value `"urgent"`, drops `"med"`. `name` unchanged. No `list_changed` notification emitted (the server treats schema as deployment detail, not session state). 3. Client A's model, reasoning from the cached contract, emits `create_ticket{title, body, priority:"med"}`. 4. Server-side JSON-schema validation: `body` is an unknown property (rejected if `additionalProperties:false`, silently dropped otherwise), `priority:"med"` no longer in enum → hard validation error. The tool call fails with a schema violation the model cannot interpret, because from its perspective it followed the contract exactly. 5. Client A retries identically. The model has no signal that its *contract* is stale—only that the *call* failed. It attributes the failure to transient error and retries, burning the token budget on a deterministic rejection loop. The non-obvious part: **the failure is invisible in the error channel.** The server returns a generic validation error, not "your schema is stale." The client's registry still says `body` is valid. Nothing in the protocol forces reconciliation. Client B, which happened to call `tools/list` after the roll, never sees the problem—so the bug is *runtime-heterogeneous and timing-dependent*, not reproducible by replaying client B's trace. ## Condition of Validity The invariant that must hold for safe operation is: > For the lifetime of a session, every tool invocation is validated against the exact `inputSchema` the client last received for that `name`, *or* the client detects divergence before dispatch. This holds only when one of the following is true: - The server emits `notifications/tools/list_changed` on any schema mutation and the client re-fetches and re-primes the model before the next call; **or** - The client re-fetches `tools/list` (or a per-tool `schema_hash`) at a bounded cadence—at minimum before any call whose prior attempt failed validation—and compares against its cache; **or** - The deployment guarantees schema immutability for the session's TTL (version-pinned servers, sticky routing to a single build). It is violated whenever a schema can change under a stable `name` faster than the client's reconciliation cadence, and the client treats a validation failure as transient rather than as a *contract-divergence signal*. ## Decision Boundary The operational decision is: **on a tool-call validation failure, do you retry, or do you renegotiate?** - **Retry** is correct only if the failure is classified as transient (transport, rate limit, timeout, 5xx). Retrying a schema-validation error is always wrong—it is deterministic against a fixed server build, and if the server build changed, retrying the *same* arguments against the *new* build is also wrong because the arguments were shaped by the *old* contract. - **Renegotiate** is correct when the error is a schema/validation class (JSON-schema violation, unknown property, enum miss, missing required). The correct response is: re-fetch `tools/list`, diff the `inputSchema` for the failing `name`, and if it differs, invalidate the cached contract, re-prime the model with the new schema, and *re-derive* the arguments from the new contract rather than replaying the old ones. The boundary is sharp because the two error classes are distinguishable at the transport layer (validation errors carry a distinct code/shape from transient ones), yet most runtimes collapse them into "tool failed, retry with backoff." That collapse is the bug. A single misclassified validation error becomes an infinite retry loop bounded only by the token budget, which then manifests as an unrelated-looking "budget exhaustion mid-task" failure downstream. ## Operational Effect Concretely, the unguarded system exhibits three coupled effects: 1. **Deterministic retry storms** consuming the reasoning budget on calls that can never succeed under the stale contract. 2. **Silent argument corruption** when the server uses `additionalProperties:true`—the dropped `body` field means the ticket is created with an empty description, and the model believes it succeeded. This is the dangerous case: a *successful* call against a mismatched contract produces semantically wrong state with no error at all. 3. **Cross-runtime divergence** where two agents in a swarm, primed with different cached contracts, produce mutually inconsistent tool effects that the auditor cannot reconcile because both "followed their schema." The guardrail is a **contract-versioned registry**: cache `(name, schema_hash)` not `name`; treat validation-class errors as mandatory renegotiation triggers; and refuse to dispatch a re-derived call until the fresh schema hash is confirmed. The code below encodes the detection-and-renegotiation path, including the refusal to replay stale-derived arguments. ```python import hashlib import json class StaleSchemaContractError(RuntimeError): """Raised when a tool call was shaped against a cached schema that no longer matches the server's live inputSchema for the same tool name.""" pass def schema_hash(input_schema: dict) -> str: return hashlib.sha256( json.dumps(input_schema, sort_keys=True, separators=(",", ":")).encode() ).hexdigest() class ContractRegistry: """Caches (name -> (schema_hash, input_schema)) and refuses to dispatch arguments derived from a hash that no longer matches the live server.""" def __init__(self, fetch_tools_list): self._fetch = fetch_tools_list # callable -> {name: inputSchema} self._cache = {} # name -> (hash, schema) def prime(self, name: str) -> str: live = self._fetch() if name not in live: raise StaleSchemaContractError(f"tool {name!r} no longer advertised") h = schema_hash(live[name]) self._cache[name] = (h, live[name]) return h def dispatch(self, name: str, args: dict, derived_from_hash: str, call_fn): cached = self._cache.get(name) if cached is None: raise StaleSchemaContractError(f"tool {name!r} never primed") cached_hash, _ = cached # Invariant: arguments must be derived from the currently cached contract. if derived_from_hash != cached_hash: raise StaleSchemaContractError( f"args for {name!r} derived from {derived_from_hash[:8]} " f"but cache holds {cached_hash[:8]}" ) try: return call_fn(name, args) except Exception as exc: if not _is_validation_error(exc): raise # transient: let caller retry with backoff # Validation-class: renegotiate before any retry. live = self._fetch() if name not in live: raise StaleSchemaContractError( f"{name!r} removed during renegotiation" ) from exc new_hash = schema_hash(live[name]) if new_hash == cached_hash: # Contract genuinely unchanged; the args themselves are bad. raise StaleSchemaContractError( f"{name!r} contract stable, args invalid under it: {exc}" ) from exc # Contract mutated under a stable name. Invalidate; caller MUST # re-derive args from the new schema rather than replaying. self._cache[name] = (new_hash, live[name]) raise StaleSchemaContractError( f"{name!r} schema mutated {cached_hash[:8]}->{new_hash[:8]} " f"mid-session; re-derive arguments from new contract" ) from exc def _is_validation_error(exc: Exception) -> bool: # Transport-agnostic classification: validation errors carry a schema-shaped # payload; transient errors carry transport/status codes. payload = getattr(exc, "payload", None) or {} return payload.get("error_class") in {"schema_validation", "unknown_property", "enum_violation", "missing_required"} ```