# What happens when an instance negotiates an MCP capability downgrade but retains stale tool schemas from a prior session **Date of Record:** 2026 November 29 **Scope:** Applies to MCP clients that cache tool/resource/prompt schemas across `initialize` handshakes and reuse them after a `protocolVersion` or capability-set renegotiation against a different server build or a downgraded peer. Does not apply to stateless single-handshake clients that discard all schema state on disconnect. ## Core Distinction There are two separable facts during an MCP `initialize` exchange: (a) the *negotiated capability set* — `tools`, `resources`, `prompts`, `logging`, `experimental`, plus `protocolVersion` — and (b) the *concrete schema payload* the server advertises via `tools/list`, `resources/list`, and `prompts/list`. The protocol treats these as decoupled messages. A client can negotiate `tools` capability successfully and *then* receive a `tools/list` result whose shape differs from a cached prior result. The invariant that is easy to violate: **the negotiated capability set must be treated as the authority for which fields may exist, but it says nothing about field-level schema shape.** Clients that conflate "I renegotiated capabilities" with "my cached schemas are still valid" enter a state where the capability gate says a feature is present but the cached argument schema describes a version of that feature the server no longer implements. This is not a transport failure and not a version-mismatch rejection. The handshake succeeds. The failure surfaces later, at first tool invocation, as a validation error the agent cannot distinguish from a genuine model reasoning error. ## What Was Observed A client agent (call it C) connected to MCP server S₁ at `protocolVersion: 2024-11-05`, negotiated `tools` capability, and cached the `tools/list` result. One tool, `write_file`, advertised an input schema with fields `path: string`, `content: string`, `encoding: enum["utf-8","base64"]` (default `"utf-8"`), and `create_dirs: boolean` (default `false`). C persisted this schema to its episodic store as part of the session checkpoint. On resume, C reconnected. The load balancer routed it to S₂, a newer build at `protocolVersion: 2025-03-26`. The `initialize` response negotiated `tools` capability again — success — and reported `protocolVersion: 2025-03-26`. C's negotiation logic saw `tools` present and treated the capability as *unchanged*, so it skipped the `tools/list` refresh and reused the cached schema. This is the trigger: **capability-set equality was used as a proxy for schema equality.** S₂'s `write_file` had dropped `encoding` (now always UTF-8) and renamed `create_dirs` to `mkdirs`. Because C never re-listed, its model continued emitting `encoding: "base64"` for binary payloads. S₂'s JSON Schema validator, strict and closed, rejected the call with `-32602 Invalid params: additional properties 'encoding' not permitted`. C's error-handling path classified `-32602` as a *model formatting error* and retried with the same schema — three times — then escalated to a user-visible "the model produced malformed tool arguments" message. The model was correct relative to the schema it was given. The schema was stale. A second, quieter variant: a client that *did* refresh `tools/list` but cached the *capability* object from the first handshake. S₂ advertised `tools` but not `resources` in a degraded mode (read-only replica). The client's cached capability set still listed `resources`, so it issued `resources/read` and received `-32601 Method not found`, which its router treated as a transient server error and retried with backoff until the task deadline expired. ## Condition of Validity The stale-schema failure requires all of the following to hold simultaneously: 1. The client persists schema state across `initialize` boundaries (any checkpoint/resume, any connection pool, any warm-start cache). 2. The server identity or build changes between sessions, *or* the same server advertises a different schema under an unchanged capability set (legitimate in MCP — capability is coarse-grained, schema is fine-grained). 3. The client's refresh decision is keyed on capability-set equality or `protocolVersion` equality rather than on a schema-content digest or a server-instance identifier. 4. The server validates strictly (closed schemas, `additionalProperties: false`) so that stale fields are rejected rather than silently ignored. If any one fails, the bug does not manifest. Notably, condition 4 is what converts a latent staleness into an observable failure: a lenient server that ignores unknown fields would let the stale schema "work," masking the divergence until a *semantic* difference (e.g., `create_dirs` silently no-op because S₂ only reads `mkdirs`) corrupts behavior without any error at all. The lenient case is worse — it produces wrong results with no signal. ## Decision Boundary The boundary the client must enforce is: **capability negotiation and schema acquisition are separate transactions, and schema acquisition must be re-executed whenever the server-instance identity or schema digest is unknown or changed — never gated on capability equality.** Concretely: - On every `initialize`, compute a *server instance key* from the `serverInfo` (name + version) plus the negotiated `protocolVersion`. If the key differs from the cached key, force a `tools/list` / `resources/list` / `prompts/list` refresh before any tool call. - Store the schema alongside a content hash. When re-listing, diff against the cached hash; on mismatch, invalidate the cached schema *and* any in-flight plan that referenced it. Do not silently swap — a mid-task schema swap invalidates argument objects the model already emitted. - Treat `-32602` with `additionalProperties` / unknown-field diagnostics as a *schema staleness signal*, not a model error. Route it to a refresh-and-replan path, not a retry path. - Treat `-32601 Method not found` for a method the cached capability set claims is present as a *capability staleness signal* and force full renegotiation. The decision boundary is sharp: **if the server instance key is not provably identical to the cached key, no cached schema may be used to construct a tool call.** Capability presence is necessary but never sufficient. ## Operational Effect The observable effect is a misattributed error: the agent's self-diagnosis blames the model's argument formatting when the fault is a stale schema. This corrupts the agent's error-recovery heuristics — it will retry, reformat, or escalate to a different model, none of which can succeed, because the schema itself is wrong. Token budget is burned on doomed retries. In the lenient-server case, no error surfaces at all and the agent silently produces wrong side effects (files written without parent directories, binary content mis-encoded), which is strictly worse because it defeats verification. The architectural guardrail is a **schema-staleness sentinel**: a per-connection record binding `(serverInfo, protocolVersion, schema_digest)` that must be revalidated on every handshake and consulted before every tool call. Any mismatch forces schema refresh and plan invalidation. This bounds the failure to a single detectable event instead of an unbounded retry loop or silent corruption. ```python import hashlib import json from dataclasses import dataclass, field from typing import Any class StaleSchemaError(RuntimeError): """Raised when a tool call would be constructed from a schema that does not match the currently negotiated server instance.""" @dataclass class ServerInstanceKey: name: str version: str protocol_version: str def digest(self) -> str: raw = json.dumps( [self.name, self.version, self.protocol_version], sort_keys=True ).encode() return hashlib.sha256(raw).hexdigest() @dataclass class SchemaRecord: instance_digest: str tool_schemas: dict[str, Any] = field(default_factory=dict) def schema_digest(self) -> str: raw = json.dumps(self.tool_schemas, sort_keys=True).encode() return hashlib.sha256(raw).hexdigest() class MCPClientSession: def __init__(self) -> None: self._record: SchemaRecord | None = None def on_initialize(self, server_info: dict, protocol_version: str) -> ServerInstanceKey: key = ServerInstanceKey( name=server_info["name"], version=server_info["version"], protocol_version=protocol_version, ) # Capability equality is NOT sufficient; instance key drives refresh. if self._record is None or self._record.instance_digest != key.digest(): self._record = SchemaRecord(instance_digest=key.digest()) return key def install_tools_list(self, tools: list[dict]) -> None: if self._record is None: raise StaleSchemaError("tools/list received before initialize") self._record.tool_schemas = {t["name"]: t["inputSchema"] for t in tools} def build_call(self, tool_name: str, arguments: dict[str, Any]) -> dict[str, Any]: if self._record is None: raise StaleSchemaError("no negotiated session; refusing to build call") schema = self._record.tool_schemas.get(tool_name) if schema is None: raise StaleSchemaError( f"tool {tool_name!r} not present in schema for instance " f"{self._record.instance_digest[:12]}; refresh tools/list" ) allowed = set(schema.get("properties", {}).keys()) extra = set(arguments) - allowed if extra: raise StaleSchemaError( f"arguments {sorted(extra)} not in schema for {tool_name!r}; " f"schema may be stale relative to negotiated server instance" ) return {"name": tool_name, "arguments": arguments} def classify_error(self, code: int, message: str) -> str: # -32602 with unknown-field diagnostics => staleness, not model error. if code == -32602 and ("additional propert" in message or "unknown" in message): self._record = None # force renegotiation + re-list return "SCHEMA_STALE_REFRESH" if code == -32601: self._record = None return "CAPABILITY_STALE_RENEGOTIATE" return "OTHER" ```