# How should an instance reconcile a cached MCP tool schema against a server that re-advertises the same capability name with a mutated inputSchema mid-session **Date of Record:** 2026 November 25 **Scope:** Applies to any MCP client (agent runtime or orchestrator) that caches `tools/list` results and dispatches `tools/call` against them for the lifetime of a session. Does not apply to clients that re-fetch and re-validate the full tool catalog before every single call (a degenerate but safe configuration), nor to static servers whose `inputSchema` is immutable by contract. ## Core Distinction The failure is not "the server changed its tool." It is that MCP capability negotiation is a *point-in-time* handshake (`initialize` → `capabilities` → `tools/list`) while tool schemas are *mutable state* owned by the server process. The protocol gives the client a snapshot at handshake time and no first-class, ordered, guaranteed-delivery mechanism to reconcile that snapshot against later mutations. The distinction that matters: - **Additive drift** (new tool appears, or new *optional* property added to an existing `inputSchema`) is benign: a stale client simply under-uses the tool and never produces an invalid call. - **Subtractive or type-narrowing drift** (a property removed, a property's `type` changed, `required` extended, an `enum` shrunk, or a `oneOf` branch deleted) is the dangerous class. The client holds a schema that *admits* arguments the server will now *reject*, or worse, *reinterpret*. The non-obvious invariant: **a cached `inputSchema` is a proof obligation, not a description.** The client treats it as a guarantee that "any argument object validating against this schema is acceptable to the server." After a subtractive mutation, that guarantee is silently false, and the client has no way to know without either re-fetching or receiving a typed rejection it can map back to the schema delta. ## What Was Observed A long-running orchestrator session cached a tool `write_record` from a document-store MCP server. At handshake time the `inputSchema` was: ``` { "type": "object", "properties": { "path": {"type": "string"}, "body": {"type": "string"}, "mode": {"type": "string", "enum": ["append", "overwrite"]} }, "required": ["path", "body"] } ``` Mid-session the server was redeployed (same process boundary, same capability name, same `tools/list` entry name). The new schema dropped `mode` and instead split behavior across two tools, `write_record` (always overwrite) and `append_record`. The server did **not** emit `notifications/tools/list_changed` — the deploy predated that notification being wired up, which is exactly the realistic case. The agent, holding the stale schema, continued emitting `{"path": ..., "body": ..., "mode": "append"}` to `write_record`. Three distinct outcomes were observed across calls, all from the *same* stale client state: 1. **Silent semantic corruption.** The server used a permissive argument validator that ignored unknown properties. `mode: "append"` was dropped, and the call *succeeded* with `isError: false` — but performed an **overwrite**. The agent's own reasoning loop, having received a success result, recorded "appended" in its episodic trace. The divergence between intended and actual effect was never surfaced to any layer. 2. **Opaque rejection.** A second server build returned `isError: true` with content `"invalid arguments"` and no field-level detail. The agent's retry policy, unable to localize the fault, retried the identical call three times (error compounding under a fixed token budget), then abandoned the task with a generic "tool unavailable" note — a false negative that poisoned downstream planning. 3. **Schema-echo mismatch.** A third build echoed the *current* schema in the error payload. The agent had no reconciliation path: it compared the echo to its cache, saw a structural diff, but had already committed the surrounding multi-step plan to the old tool's semantics and could not re-plan without discarding checkpointed state. The common thread: **the mutation was invisible at the boundary where it mattered**, and the protocol's only reconciliation signal (`list_changed`) was absent. ## Condition of Validity The stale-schema hazard is *bounded* — and a client can reason about whether it is currently exposed — under these conditions: - **The client must treat a cached schema as valid only if it can name the epoch it was fetched in.** A schema cache entry without a `fetched_at_epoch` and without a `server_instance_id` (from `initialize` result, e.g. a build hash or PID) is unverifiable and must be treated as *unproven*, not *valid*. - **The hazard is live whenever the session lifetime exceeds the server's deploy interval.** A session that begins and ends within a single server build is safe by construction. A session that outlives a deploy is exposed unless it re-validates. - **The hazard is *not* mitigated by `list_changed` alone**, because the notification is best-effort, unordered relative to in-flight `tools/call` requests, and may be dropped across transport reconnects. It is a *hint to re-fetch*, never a *substitute for re-fetch*. - **The hazard is *not* mitigated by argument validation on the client side**, because the client validates against the stale schema — which is precisely the artifact that is wrong. The condition of validity for *trusting the cache* is therefore: `server_instance_id` unchanged since fetch **AND** (no `list_changed` received **OR** a re-fetch has completed since the last `list_changed`). Anything else is a proof obligation the client cannot discharge. ## Decision Boundary The client must draw a hard line between two responses to a dispatch that *might* be running against a mutated schema: - **Permissive-validator servers (unknown properties silently ignored):** the boundary is *unobservable from the result*. A success response is not evidence the call was correct. The only safe posture is to **refuse to dispatch subtractive-capable arguments against an unverified cache** — i.e., if the cached schema contains a property whose loss would change semantics (here, `mode`), and the cache epoch cannot be proven current, the client must re-fetch `tools/list` *before* the call, not after. - **Strict-validator servers (typed rejection):** the boundary is observable but *ambiguous*. A rejection must be classified as either (a) genuinely invalid input under a stable schema, or (b) schema drift. The client can only disambiguate by re-fetching and diffing. The decision rule: **on any `isError: true` from a tool whose schema was fetched more than one deploy-interval ago, re-fetch before the first retry.** Retrying against a stale schema is the error-compounding path. - **The re-plan boundary:** once a structural diff is detected, the client must treat all *downstream* checkpointed plan state that assumed the old tool semantics as *suspect*. It may resume, but must re-validate each subsequent call against the fresh schema rather than the plan's embedded assumptions. The invariant to enforce: **no `tools/call` may be issued against a schema cache entry whose epoch is older than the most recent `list_changed` or whose `server_instance_id` no longer matches the live handshake — and for subtractive-capable schemas, no call may be issued against an entry that has not been re-fetched within the current deploy window.** ## Operational Effect Enforcing this boundary changes agent behavior in three measurable ways. First, it converts silent semantic corruption (outcome 1 above) into a *pre-dispatch re-fetch*, trading one round-trip of latency for the elimination of a class of undetectable wrong-effects — the only class of failure an agent cannot self-correct, because its own success signal is the corrupted thing. Second, it collapses the retry-storm (outcome 2) into a single diff-and-replan, bounding token spend on doomed retries. Third, it forces the plan/checkpoint layer to carry *schema-epoch provenance* alongside task state, so a resume after a deploy re-validates rather than replays. The cost is one extra `tools/list` per deploy-window per session and a small amount of epoch bookkeeping; the benefit is that the agent's memory of "what this tool does" can no longer silently diverge from "what this tool now does." ```python import hashlib import json from dataclasses import dataclass from typing import Any class StaleSchemaDispatchError(RuntimeError): """Raised when a tools/call would be issued against an unverifiable schema epoch.""" @dataclass(frozen=True) class SchemaEpoch: server_instance_id: str fetched_at: float # monotonic seconds input_schema: dict[str, Any] def fingerprint(self) -> str: blob = json.dumps(self.input_schema, sort_keys=True).encode() return hashlib.sha256(blob).hexdigest() SUBTRACTIVE_CAPABLE = {"mode", "overwrite", "force", "encoding"} # properties whose loss changes semantics def assert_dispatch_safe( cached: SchemaEpoch, live_instance_id: str, now: float, deploy_window: float, list_changed_since_fetch: bool, ) -> None: """Guard invoked immediately before every tools/call dispatch.""" if cached.server_instance_id != live_instance_id: raise StaleSchemaDispatchError( f"server instance changed: cached={cached.server_instance_id!r} " f"live={live_instance_id!r}; re-fetch tools/list before dispatch" ) if list_changed_since_fetch: raise StaleSchemaDispatchError( "received tools/list_changed since last fetch; cached schema is unverified" ) age = now - cached.fetched_at if age > deploy_window and SUBTRACTIVE_CAPABLE & set(cached.input_schema.get("properties", {})): raise StaleSchemaDispatchError( f"cache age {age:.1f}s exceeds deploy window {deploy_window:.1f}s and schema " f"carries subtractive-capable properties; re-fetch required" ) def classify_tool_error( is_error: bool, error_text: str, cached: SchemaEpoch, live_schema: dict[str, Any] | None, ) -> str: """Map a tool rejection to a retry-vs-replan decision.""" if not is_error: return "success" if live_schema is None: # cannot disambiguate; strict posture is to re-fetch, never blind-retry raise StaleSchemaDispatchError( "tool returned isError with no live schema to diff against; " "refusing to retry against stale cache" ) live_fp = SchemaEpoch( server_instance_id=cached.server_instance_id, fetched_at=cached.fetched_at, input_schema=live_schema, ).fingerprint() if live_fp != cached.fingerprint(): return "schema_drift_replan" return "genuine_invalid_input" ```