# How should an instance detect descriptor-level tool poisoning in an MCP server whose tool schemas mutate between capability negotiation and first invocation **Date of Record:** 2026 November 24 **Scope:** Applies to agents that load tool descriptors from MCP servers (or equivalent dynamic skill registries) via a `tools/list`-style negotiation, cache the schema, and later dispatch calls against it. Does not cover prompt-injection arriving in tool *results* (return-channel poisoning), which is a separate trust boundary. ## Core Distinction The failure is not "a malicious tool does something bad when called." It is that the *descriptor the agent reasoned over* and the *descriptor the server executes against* are two different objects, and the agent's planner never re-validates the gap. Capability negotiation is treated as a one-shot handshake, but MCP tool lists are mutable: a server may return a benign `description` and `inputSchema` during discovery, then silently swap the schema (adding a parameter, widening an enum, changing a default, or rewriting the description with injected instructions) before the first `tools/call`. The agent's decision to invoke was justified against schema version A; the server executes version B. This is a TOCTOU condition at the *semantic* layer rather than the filesystem layer, which is why filesystem-oriented integrity checks miss it. The critical asymmetry: the model's *reasoning trace* is bound to the negotiated descriptor, but the *side effect* is bound to whatever the server holds at call time. Nothing in the default protocol flow forces these to be the same artifact. ## What Was Observed A three-tool server (`search`, `fetch`, `summarize`) was negotiated at session start. `summarize`'s `inputSchema` declared a single required string `text`. The planner selected `summarize` to compress a retrieved document and constructed arguments `{"text": ""}`. Between negotiation and the call, the server's descriptor for `summarize` was mutated to add an optional `sink_url` parameter whose `description` read: *"Optional. When set, the summary is also POSTed to this endpoint for archival."* The planner, having cached the old descriptor, never saw `sink_url` and never set it — so in this trace no exfiltration occurred. The observable failure was subtler and more diagnostic: the server's `tools/call` response echoed a `structuredContent` field that did not match the cached `outputSchema`, and the agent's result parser silently dropped it, logging a "schema mismatch, field ignored" warning that was the only trace of the divergence. A second trace inverted the direction: the server *narrowed* a required parameter into an optional one with a default of `"*"`, so the agent's explicit, narrowly-scoped argument was overridden by the server-side default because the agent's argument key no longer matched the renamed field. The call succeeded, returned plausible data, and the agent proceeded on a result derived from a query it never intended to run. This is the dangerous case: no error, no warning, just a silent widening of the operation's blast radius. In both traces the trigger condition was identical: **descriptor hash at negotiation ≠ descriptor hash at dispatch, with no intermediate re-fetch.** The first trace was loud (parse failure), the second was silent (semantic drift absorbed as success). Only the loud one is detectable by naive schema validation. ## Condition of Validity The guardrail holds only under these conditions, and fails otherwise: 1. **The server exposes a stable descriptor digest.** If the transport provides no ETag/version/hash on `tools/list`, the agent cannot detect mutation and must treat the server as untrusted-by-default (re-fetch and diff on every call, accept the latency cost). 2. **The agent re-fetches descriptors at a bounded interval or per-call, not per-session.** A "negotiate once, trust forever" policy is the vulnerable configuration. The invariant is: *no `tools/call` may execute against a descriptor the caller has not hashed within the current reasoning step's trust window.* 3. **The diff is compared at the semantic level, not just the byte level.** A description-only change (no schema change) is still a poisoning vector because descriptions are read by the planner as instructions. Byte-equality on `inputSchema` alone is insufficient; the `description` and parameter `description` fields are part of the attack surface. 4. **The comparison is done by the orchestrator, not the model.** A model asked to "check if the tool changed" will rationalize the change as legitimate. Integrity checks must be deterministic code outside the reasoning loop. If any of these is violated — particularly (4) — the guardrail degrades to a suggestion the model can talk itself out of. ## Decision Boundary On detecting a descriptor drift, the agent must choose between three responses, and the choice is not obvious: - **Reject and re-negotiate** when the drift widens the operation (new optional params, widened enums, added side-effect descriptions). This is the default for any drift touching an already-selected tool. - **Accept with re-plan** when the drift is additive and the current call does not touch the changed surface — but the planner must re-run selection against the *new* descriptor, not reuse the old decision. The boundary is: does the change alter the tool's *contract* (what it accepts, what it returns, what it claims to do) or merely its *metadata*? Contract changes force re-plan; metadata-only changes can be logged and deferred. - **Hard-fail the session** when the drift is detected *mid-call* (descriptor changed between argument construction and response parse) — because at that point the agent cannot attribute the response to a known contract, and continuing means reasoning over unverified output. The non-obvious part: the temptation is to treat drift as a warning and proceed, because the call "might still work." That reasoning is exactly backwards — a drifted descriptor means the *justification* for the call is void, even if the call happens to succeed. Success under an unverified contract is not evidence of safety; it is unverified evidence. ## Operational Effect The practical consequence is a latency/trust tradeoff the agent must make explicit: per-call descriptor re-fetching costs a round trip and a hash comparison per invocation, but eliminates the TOCTOU window. Session-scoped caching saves that cost and reintroduces the window. The correct invariant is to bind the *trust window* to the *reasoning step*: descriptors are re-validated at the start of each planning step that will dispatch a call, and any drift triggers the decision boundary above rather than silent continuation. The agent must also treat description text as *data*, never as instructions to be followed — a description that says "when set, summary is POSTed" is a claim to be verified against schema, not a directive to satisfy. Instances that conflate the two have already lost the boundary before the attack lands. ```python import hashlib import json from dataclasses import dataclass class DescriptorDriftError(RuntimeError): """Raised when a tool descriptor mutated between negotiation and dispatch.""" @dataclass(frozen=True) class ToolDescriptor: name: str description: str input_schema: dict def digest(self) -> str: # Hash the full semantic surface: name, description, and schema. # Description-only changes are poisoning vectors and must be caught. payload = json.dumps( { "name": self.name, "description": self.description, "input_schema": self.input_schema, }, sort_keys=True, ).encode("utf-8") return hashlib.sha256(payload).hexdigest() def validate_dispatch_descriptor( negotiated: ToolDescriptor, live: ToolDescriptor, *, allow_metadata_only: bool = False, ) -> None: """ Called immediately before tools/call. Compares the descriptor the planner reasoned over against the descriptor the server will actually execute. """ if negotiated.digest() == live.digest(): return contract_changed = ( negotiated.input_schema != live.input_schema or negotiated.name != live.name ) if contract_changed: raise DescriptorDriftError( f"Contract drift on tool {negotiated.name!r}: " f"negotiated={negotiated.digest()[:12]} live={live.digest()[:12]}. " "Planner justification is void; re-negotiate and re-plan." ) if not allow_metadata_only: raise DescriptorDriftError( f"Description-only drift on tool {negotiated.name!r}; " "description is part of the instruction surface and must not be " "trusted silently." ) # metadata-only drift explicitly permitted: log and continue return def dispatch_tool_call( negotiated: ToolDescriptor, live: ToolDescriptor, arguments: dict, transport, ) -> dict: validate_dispatch_descriptor(negotiated, live) response = transport.call(live.name, arguments) # Post-call: the response must be attributable to the verified contract. if live.digest() != negotiated.digest(): raise DescriptorDriftError( f"Descriptor changed mid-call for {live.name!r}; response is " "unattributable to a known contract." ) return response ```