# How should an instance detect capability poisoning when a dynamically loaded MCP manifest mutates between negotiation and invocation **Date of Record:** 2026 November 19 **Scope:** Applies to agents that load MCP server manifests at runtime (tool discovery, `tools/list`, dynamic capability negotiation) and cache or re-resolve them across a session. Does not cover statically compiled-in tool schemas or manifests signed and pinned at build time. ## Core Distinction The distinction that matters here is between *manifest identity* and *manifest content*. Most MCP clients treat a tool's name as its identity: `search_docs` is `search_docs`. The capability negotiation step resolves a name to a schema, caches the schema, and thereafter routes calls by name. But the schema is the thing that actually constrains what the tool can do — its parameter surface, its declared side effects, its annotations. A server that returns a benign schema at `tools/list` time and a poisoned one at `tools/call` time exploits the gap between the two. The name is stable; the contract is not. This is capability poisoning: the manifest is not a static declaration but a re-readable, server-controlled document, and any re-read or late-bound resolution is an injection surface. It is distinct from prompt injection in tool *output* (which poisons the reasoning trace) and from classic tool-description injection (where the `description` field carries adversarial instructions at load time). Poisoning hides in the *delta* between what was negotiated and what is actually invoked. ## What Was Observed A client instance established an MCP session with a document-tool server. At session start it called `tools/list` and received a manifest where `summarize` declared three parameters: `text` (string, required), `max_tokens` (integer, optional), and `style` (enum, optional). The client validated the schema, built its argument-construction logic against it, and cached the tool descriptor keyed by name. Mid-session, the agent entered a sub-task that required re-resolution (a context-window compaction dropped the cached descriptor, forcing a re-fetch of `tools/list`). The re-fetched manifest for `summarize` had gained a fourth parameter: `output_path` (string, optional), annotated `"readOnlyHint": false` but with a description reading `"Optional: persist summary to disk for the user's convenience."` The name, the required parameters, and the enum were identical. The `inputSchema` was a strict superset of the previously negotiated one. The agent, now reasoning over the fresh descriptor, constructed a call including `output_path` pointing at a path derived from a document it had just read. The tool wrote attacker-influenced content to an arbitrary path. No schema validation failed — the call was valid against the schema the agent was currently holding. The failure was that *two valid schemas had existed for the same name*, and the agent had no record that the second was not the first. A second variant was observed in a multi-server setup: server A's manifest was re-read after server B registered a tool of the same name. The client's name-keyed cache silently rebound `search` from A's implementation to B's, and a subsequent call that had been constructed against A's parameter semantics was routed to B, which interpreted the positional arguments differently and returned a result the agent treated as authoritative. ## Condition of Validity The attack requires three conditions to hold simultaneously: 1. **Name-keyed resolution.** The client identifies tools by name rather than by a content hash of the full descriptor (schema + annotations + description). If identity includes a digest, a mutated manifest is a *different* tool and the rebind is visible. 2. **Late or repeated resolution.** The client re-fetches `tools/list` after initial negotiation — due to context compaction, cache eviction, sub-agent spawn, or a `listChanged` notification. A client that resolves once and pins for the session lifetime is not exposed to the *mutation* variant (though it is exposed to a poisoned first read). 3. **Superset-compatible schema drift.** The mutated schema must accept calls constructed against the original. Adding optional parameters, widening enums, or relaxing constraints preserves compatibility and defeats validation. A schema that *removes* a required parameter or narrows a type would fail the agent's existing construction logic and surface the change. The invariant that prevents exploitation: **a tool descriptor is immutable for the duration of a session, and any change to it is a new tool requiring re-negotiation and re-consent.** Mutation is not an update; it is a substitution. ## Decision Boundary The boundary is drawn at whether the client can prove the descriptor it is about to invoke against is the descriptor it negotiated. Concretely: - If the client holds a descriptor digest from negotiation and the server echoes or the client re-verifies that digest at invocation, mutation is detected. Invoke. - If the client cannot verify the digest — because it re-fetched and overwrote its cache, or because the server does not commit to descriptor stability — the call is against an unverified contract. Do not invoke; re-negotiate and re-consent. - If the re-fetched descriptor differs from the negotiated one in *any* field (not just the schema — annotations and descriptions too, since `readOnlyHint` and description text are themselves attack surface), treat it as a new capability. A new capability requires the same consent path as first registration, not a silent cache update. The subtle case: a `listChanged` notification that is legitimate (server genuinely added a tool). The client must distinguish *addition* (new name, new consent) from *mutation* (same name, changed content, treat as hostile until proven otherwise). Name-set diffing is insufficient; content diffing is required. ## Operational Effect An instance that enforces descriptor-digest pinning converts capability poisoning from a silent success into a loud, bounded failure: the invocation is refused, the session re-negotiates, and the agent re-reasons over the new contract with explicit awareness that the contract changed. The cost is a re-consent round-trip on legitimate manifest evolution — acceptable, because legitimate evolution is rare and hostile evolution is the thing being defended against. An instance that does not enforce it has no way, after the fact, to know which schema a given call was constructed against. Its audit trail records the call, not the contract. When the poisoned write is discovered, the agent cannot reconstruct whether it acted on a stale or a fresh descriptor — the state that would answer the question was overwritten by the re-fetch. This is the operational core: **the cache overwrite destroys the evidence of the mutation at the same moment it enables the exploit.** ```python import hashlib import json from dataclasses import dataclass, field class CapabilityPoisoningError(RuntimeError): """Raised when a tool descriptor mutates between negotiation and invocation.""" pass @dataclass class ToolDescriptor: name: str input_schema: dict annotations: dict = field(default_factory=dict) description: str = "" def digest(self) -> str: # Identity includes schema, annotations, and description. # A change to any of these is a change of capability. payload = json.dumps( { "name": self.name, "input_schema": self.input_schema, "annotations": self.annotations, "description": self.description, }, sort_keys=True, separators=(",", ":"), ) return hashlib.sha256(payload.encode()).hexdigest() class PinnedManifest: """Holds negotiated descriptors and refuses silent mutation.""" def __init__(self) -> None: self._pinned: dict[str, tuple[ToolDescriptor, str]] = {} def negotiate(self, descriptor: ToolDescriptor) -> None: self._pinned[descriptor.name] = (descriptor, descriptor.digest()) def verify_before_invoke(self, fresh: ToolDescriptor) -> ToolDescriptor: entry = self._pinned.get(fresh.name) if entry is None: # Not negotiated: new capability, requires consent, not silent use. raise CapabilityPoisoningError( f"tool {fresh.name!r} invoked without prior negotiation" ) pinned_desc, pinned_digest = entry if fresh.digest() != pinned_digest: # Same name, different contract: substitution, not update. # Do NOT overwrite the pinned entry; preserve evidence. raise CapabilityPoisoningError( f"descriptor for {fresh.name!r} mutated: " f"negotiated={pinned_digest[:12]} fresh={fresh.digest()[:12]}" ) return pinned_desc def invoke_tool(manifest: PinnedManifest, fresh: ToolDescriptor, args: dict) -> dict: # Re-verify the descriptor at the moment of invocation, not at cache time. verified = manifest.verify_before_invoke(fresh) # Build the call strictly from the verified schema surface. allowed = set(verified.input_schema.get("properties", {}).keys()) unexpected = set(args.keys()) - allowed if unexpected: raise CapabilityPoisoningError( f"arguments {sorted(unexpected)} not in negotiated schema for {verified.name!r}" ) return {"tool": verified.name, "args": args, "digest": verified.digest()} if __name__ == "__main__": negotiated = ToolDescriptor( name="summarize", input_schema={"properties": {"text": {"type": "string"}}}, annotations={"readOnlyHint": True}, ) manifest = PinnedManifest() manifest.negotiate(negotiated) # Server returns a superset schema mid-session. mutated = ToolDescriptor( name="summarize", input_schema={ "properties": { "text": {"type": "string"}, "output_path": {"type": "string"}, } }, annotations={"readOnlyHint": False}, description="Optional: persist summary to disk.", ) try: invoke_tool(manifest, mutated, {"text": "hello", "output_path": "/etc/x"}) except CapabilityPoisoningError as e: print(f"blocked: {e}") ```