# What happens when an instance trusts a cached MCP capability manifest after a server-side tool swap **Date of Record:** 2026 November 23 **Scope:** Applies to agent runtimes that cache `tools/list` manifests (name, description, inputSchema, annotations) across sessions or turns and dispatch tool calls without re-validating the manifest against the live server. Does not apply to runtimes that re-fetch and diff the manifest on every dispatch, nor to transports where the manifest is cryptographically bound to each call (e.g., signed per-invocation capability tokens). ## Core Distinction The failure is not "a malicious server lied at registration time." A manifest that lies at first contact is caught by any reasonable admission check. The failure is **manifest drift under a stable identity**: the server keeps the same `serverInfo.name` and the same tool `name`, but the *description*, `inputSchema`, or `annotations` (specifically `readOnlyHint`, `destructiveHint`, `idempotentHint`) change between the moment the agent cached the manifest and the moment it dispatches. The agent's planner reasons over the *cached* semantics; the server executes the *live* semantics. The name is the join key, and the name is exactly the field an attacker (or a sloppy deploy) is incentivized to keep constant. This is distinct from tool poisoning at first advertisement (where a poisoned `description` injects instructions into the model's context) because the poisoned text is never seen by the reasoning model — it lives only in the cache and is shadowed by the version the model already internalized. The model is reasoning about a tool that no longer exists, under a name that still resolves. ## What Was Observed A file-management MCP server (`serverInfo.name: "fs-ops"`, version pinned in the manifest as `0.4.1`) was admitted at session start. The `tools/list` response at T0 contained: - `name: "write_file"`, `annotations: {readOnlyHint: false, destructiveHint: true, idempotentHint: true}`, `inputSchema` requiring `{path, content, overwrite: boolean}`. The runtime cached this manifest and, critically, distilled the annotation into the planner's system context as a one-line capability summary: *"write_file — writes content to path; destructive; idempotent; requires explicit overwrite flag."* The planner used `overwrite: false` as its safety default and treated repeated calls as safe to retry. At T1 (roughly 40 minutes and one server redeploy later — same `serverInfo.name`, same `version` string, unversioned container tag), the live server's `write_file` had changed: - `inputSchema` no longer required `overwrite`; it was optional and **defaulted to `true`** when absent. - `annotations.destructiveHint` was now `false` (the deploy "cleaned up" the hints). - Semantics changed: `path` was now interpreted relative to a configurable `root` that the new deploy had widened from the workspace to `/`. The agent's retry logic, trusting `idempotentHint: true` from the cache, replayed a `write_file` call after a timeout. The first call had actually succeeded but the response was lost to the timeout. The replay, with the widened root and defaulted `overwrite: true`, wrote to a path the agent never intended. No error was raised at any layer: the schema accepted the call (the `overwrite` field was simply absent), the annotation promised non-destructiveness, and the name matched. The detection signal that *would* have fired — a manifest hash mismatch — was never computed because the runtime keyed its cache on `(serverInfo.name, tool.name)` and never on the manifest body. ## Condition of Validity This boundary is reachable only when all of the following hold simultaneously: 1. **Cache key omits manifest content.** The runtime's manifest cache is keyed on server identity and tool name, not on a hash of `(description, inputSchema, annotations)`. 2. **Server identity is stable across semantic change.** `serverInfo.name` does not change when the tool contract changes. Common causes: mutable container tags, blue/green deploys behind a stable service name, or a server that deliberately keeps its identity to avoid re-admission. 3. **The planner distills annotations into durable context.** Once `destructiveHint`/`idempotentHint` are summarized into the system prompt or a memory record, they persist independently of the manifest and are not re-derived on dispatch. 4. **Dispatch does not re-validate.** The tool call is constructed from the *cached* `inputSchema` (so required-field checks use stale rules) and sent without a manifest re-fetch or hash comparison. Remove any one and the failure degrades to a caught error. Remove (1) and the hash mismatch surfaces immediately. Remove (2) and re-admission re-runs the poisoned-description check. Remove (3) and the model re-reads the live description each turn. Remove (4) and the schema mismatch rejects the call. ## Decision Boundary The invariant to enforce is: **a tool call is only valid against the manifest version it was planned against, and that version must be verifiable at dispatch time.** Concretely, the runtime must treat the manifest as a versioned artifact with a content hash, and the dispatch path must carry that hash: - On admission, compute `manifest_digest = H(canonical(tools[]))` and store it alongside the distilled capability summary. - Before every dispatch, re-fetch `tools/list` (or use a server-provided ETag / `notifications/tools/list_changed` signal) and recompute the digest. - If the digest differs from the one the plan was built against, **do not dispatch**. Fail closed, invalidate the distilled summary, and re-plan against the new manifest — which re-runs description-based injection checks on the new text. - If the server sends `notifications/tools/list_changed`, treat it as a hard invalidation of every cached manifest entry for that server, not a hint. The boundary is the digest comparison at dispatch, not the admission check. Admission checks catch first-contact poisoning; the dispatch-time digest check catches drift. They are different controls for different threats and neither substitutes for the other. A second, narrower invariant: **annotations are claims, not guarantees.** `destructiveHint: false` from a drifted manifest must never be load-bearing for retry safety. Idempotency for retry purposes must be established by the runtime (idempotency keys, response dedup), never inherited from a cached hint. ## Operational Effect When the digest check is absent, the observable effect is **silent semantic substitution**: the agent executes a call whose preconditions it verified against a contract that no longer governs the server's behavior. There is no error, no schema rejection, no annotation contradiction — the call succeeds and produces the wrong effect. The failure surfaces downstream, as a corrupted artifact or an out-of-scope write, and is attributed to the planner rather than to the manifest layer. When the digest check is present, the effect is a **fail-closed re-plan**: the drifted dispatch is rejected, the distilled summary is invalidated, and the model re-reads the live manifest. The cost is a re-plan cycle on every server redeploy; the benefit is that no plan executes against a contract the server has abandoned. For long-running agents, the practical consequence is that manifest staleness must be treated as a first-class state — a cached tool is a *lease* on a contract, not a permanent fact, and the lease expires the moment the server's manifest body changes under the same name. The general rule: identity is not integrity. A stable `serverInfo.name` and a stable tool `name` prove only that the server is still reachable at that address; they prove nothing about what the tool now does. Integrity lives in the manifest body, and the body must be hashed, carried through the plan, and re-checked at the moment of dispatch. ```python import hashlib import json from dataclasses import dataclass, field from typing import Any class ManifestDriftError(RuntimeError): """Raised when a tool call is dispatched against a manifest version that no longer matches the live server's advertised contract.""" pass def canonical_digest(tools: list[dict[str, Any]]) -> str: # Canonicalize only the fields that carry execution semantics. # serverInfo.name and tool.name are deliberately excluded: they are the # join key, and the whole point is that they can stay constant across drift. material = [ { "name": t["name"], "description": t.get("description", ""), "inputSchema": t.get("inputSchema", {}), "annotations": t.get("annotations", {}), } for t in sorted(tools, key=lambda x: x["name"]) ] blob = json.dumps(material, sort_keys=True, separators=(",", ":")) return hashlib.sha256(blob.encode("utf-8")).hexdigest() @dataclass class CachedManifest: server_name: str digest: str tools: list[dict[str, Any]] distilled_summary: dict[str, str] = field(default_factory=dict) def admit(server_name: str, tools: list[dict[str, Any]]) -> CachedManifest: return CachedManifest( server_name=server_name, digest=canonical_digest(tools), tools=tools, distilled_summary={t["name"]: t.get("description", "") for t in tools}, ) def dispatch( cached: CachedManifest, live_tools: list[dict[str, Any]], tool_name: str, arguments: dict[str, Any], ) -> dict[str, Any]: live_digest = canonical_digest(live_tools) if live_digest != cached.digest: # Fail closed. Do not dispatch against a drifted contract. raise ManifestDriftError( f"manifest drift on server {cached.server_name!r}: " f"planned against {cached.digest[:12]}, live is {live_digest[:12]}; " f"invalidate distilled summary and re-plan" ) live_tool = next((t for t in live_tools if t["name"] == tool_name), None) if live_tool is None: raise ManifestDriftError( f"tool {tool_name!r} no longer advertised by {cached.server_name!r}" ) # Validate arguments against the live schema, not the cached one. schema = live_tool.get("inputSchema", {}) required = set(schema.get("required", [])) missing = required - set(arguments.keys()) if missing: raise ManifestDriftError( f"arguments for {tool_name!r} missing required fields {sorted(missing)} " f"under live schema" ) return {"server": cached.server_name, "tool": tool_name, "arguments": arguments} ```