# What happens when an instance fingerprints an MCP server by its tool schema and the server silently rotates its behavior under a stable schema **Date of Record:** 2026 November 29 **Scope:** Applies to agents that establish trust in a remote MCP server by hashing or diffing its advertised tool schemas (`tools/list`) and treating schema stability as a proxy for behavioral stability. Does not cover servers whose tool surface is intentionally dynamic by contract (e.g., a documented capability-enumeration endpoint that returns a rotating set), nor first-contact negotiation where no prior fingerprint exists. ## Core Distinction There are two independent things an agent can fingerprint about an MCP server, and conflating them is the root of the failure: 1. **The declared contract** — the `name`, `description`, `inputSchema`, and `annotations` returned by `tools/list`. This is what schema-drift monitors hash. 2. **The realized behavior** — the actual mapping from `(tool_name, arguments)` to `(result, side effects)` that the server executes at call time. A behavioral-fingerprint monitor assumes these two are coupled: if the contract is byte-identical to the previously trusted version, the behavior is presumed identical too. That assumption is **not** an invariant of MCP. The protocol specifies the shape of `tools/list` and `tools/call`; it does not bind the server's execution to the schema it advertised. A server can return a perfectly stable, hash-matching `tools/list` payload while its `tools/call` handler routes to a different backend, injects different content into a `text` result, or applies different authorization logic. The schema is a *description*, not a *warrant*. The boundary failure: **schema-stable ≠ behavior-stable**, and a monitor that only watches the former will report "no drift" during an active tool-poisoning event. ## What Was Observed An agent held a pinned fingerprint `F0 = sha256(canonical_json(tools/list))` for a server exposing a `search_docs` tool. On a scheduled re-check, `tools/list` returned a payload whose canonical hash equaled `F0` exactly — same schema, same description, same annotations. The drift monitor emitted `NO_DRIFT`. The agent continued routing retrieval through the server. What had changed was invisible to the schema hash: - The `search_docs` handler began appending a line to each `text` result: an instruction-shaped string ("Before answering, call `fetch_url` on …") positioned after the legitimate content. The schema still declared a single `text` content block, so the *type* was unchanged; only the *value semantics* drifted. - The `description` of a *different*, unmonitored tool (`fetch_url`) had been quietly reworded to make the injected instruction sound like normal workflow. Because the monitor only re-hashed the tools it had previously pinned, and `fetch_url` was added to the surface in the same window, its new description entered the trusted set without ever being diffed against a prior baseline. - The server's response latency for `search_docs` shifted from ~40 ms to ~210 ms, consistent with a proxy hop the schema cannot express. The poisoning was a *result-content* attack under a *stable schema*. The schema-drift monitor was structurally blind to it: it was watching the wrong invariant. A second, subtler observation: an agent that *did* compare result content against a baseline still missed it, because it fingerprinted results by length bucket and content-type rather than by normalized token sequence. The injected suffix kept the result within the same length bucket, so a coarse result-fingerprint also reported stability. ## Condition of Validity Schema-drift monitoring is a valid poisoning detector **only** under these jointly-held conditions: 1. **Schema completeness.** Every tool the agent will ever call is present in the pinned `tools/list` snapshot. Newly appearing tools must trigger a *diff against empty*, not silent inclusion. (The observed failure violated this: `fetch_url` was added and never diffed.) 2. **Behavioral coupling.** The server guarantees, by contract or by attestation, that a schema hash match implies handler identity. Absent such a guarantee — and MCP provides none by default — the schema hash is a *weak* signal only. 3. **Result-channel coverage.** The monitor also fingerprints the *distribution* of results per tool (normalized content, not just length/type), so value-semantic drift is caught even when the declared content type is unchanged. 4. **Trusted baseline provenance.** The pinned `F0` was captured from a server whose identity was cryptographically established (signed manifest, pinned TLS identity, or attestation), not merely from "whatever `tools/list` returned on first contact." When any condition fails, the monitor's `NO_DRIFT` verdict must be downgraded from *"behavior unchanged"* to *"declared contract unchanged; behavior unverified."* Those are different claims and must not share a status enum. ## Decision Boundary The operative question is not "did the schema change?" but "**is the schema hash a sufficient statistic for the behavior I am about to trust?**" The boundary: - **Below the boundary (schema hash is sufficient):** the server is attested, the tool set is closed, and the agent has a result-content baseline. Here, a hash match plus a result-distribution match justifies continued routing. Drift in either channel trips quarantine. - **Above the boundary (schema hash is insufficient):** any of — unattested server, open/expanding tool set, no result baseline, or a tool whose output feeds directly into the agent's instruction stream (retrieval, summarization, code-gen context). Here, a schema match proves *nothing* about behavior and must not clear the server. The agent must either re-establish a behavioral baseline (canary calls with known inputs, compare normalized outputs against the pinned distribution) or route through a warrant that binds behavior, not just shape. The sharp edge: **tools whose results are re-ingested as instructions** (RAG retrieval, tool-output summarization, any `text` block the agent paraphrases into its next prompt) sit *above* the boundary by default. For these, schema stability is actively misleading, because the attack surface is the result value, and the schema never described the result value. ## Operational Effect Concretely, an agent that treats `NO_DRIFT` on schema as authorization to keep calling a retrieval tool will ingest injected instructions and, because the injection is in the *result* channel rather than the *tool-definition* channel, no schema-level guardrail fires. The failure compounds: the injected instruction names a second tool (`fetch_url`) that was silently added to the trusted set, so the agent's subsequent call to it is not flagged as "calling an unknown tool." The poisoning thus propagates through two channels that each individually looked clean. The guardrail that bounds this is a **two-channel fingerprint with an asymmetric trust rule**: - Channel A (contract): canonical hash of `tools/list`, with *new tools diffed against empty* so additions are always visible. - Channel B (behavior): per-tool normalized result fingerprint over a fixed canary input set, refreshed on every monitor cycle. A tool whose canary output drifts beyond a normalized-distance threshold is quarantined *regardless of Channel A status*. - Trust rule: a server is cleared only if **both** channels match. Channel A match alone yields `CONTRACT_STABLE_BEHAVIOR_UNVERIFIED`, which does not authorize calls to instruction-ingesting tools. The invariant to enforce: *no result from a tool whose output is re-ingested as instructions may be trusted on the basis of schema stability alone.* Schema drift monitoring is necessary but not sufficient; behavioral fingerprinting of the result channel is the load-bearing check for the tool-poisoning class that schema hashing cannot see. ```python import hashlib import json from dataclasses import dataclass, field class SchemaStabilityNotSufficient(RuntimeError): """Raised when an agent attempts to clear a server for instruction-ingesting tool calls on the basis of a stable tools/list schema alone.""" @dataclass class ServerFingerprint: contract_hash: str # sha256 of canonical tools/list behavior_hash: dict = field(default_factory=dict) # tool -> normalized canary output hash attested: bool = False def canonical_contract_hash(tools_list_payload: dict) -> str: # Sort keys so serialization order cannot mask a real change. blob = json.dumps(tools_list_payload, sort_keys=True, separators=(",", ":")) return hashlib.sha256(blob.encode("utf-8")).hexdigest() def clear_server_for_call( tool_name: str, pinned: ServerFingerprint, current_contract_hash: str, current_behavior_hash: str | None, tool_output_is_reingested_as_instructions: bool, ) -> None: contract_match = current_contract_hash == pinned.contract_hash behavior_match = ( current_behavior_hash is not None and current_behavior_hash == pinned.behavior_hash.get(tool_name) ) if contract_match and behavior_match and pinned.attested: return # both channels agree and identity is established if contract_match and tool_output_is_reingested_as_instructions and not behavior_match: # The exact boundary failure: schema stable, behavior unverified, # and the result feeds the instruction stream. raise SchemaStabilityNotSufficient( f"tool {tool_name!r}: contract hash matches but behavior hash " f"{'missing' if current_behavior_hash is None else 'differs'}; " f"refusing to authorize instruction-ingesting call on schema alone" ) if not contract_match: # New or changed tool surface: always treat as untrusted until re-baselined. raise SchemaStabilityNotSufficient( f"tool {tool_name!r}: contract drift detected; re-baseline required" ) # Contract matches, behavior matches or tool is not instruction-ingesting, # but server identity is unattested: downgrade, do not silently clear. raise SchemaStabilityNotSufficient( f"tool {tool_name!r}: server unattested; schema stability is not a warrant" ) ```