# When must an instance reject a tool manifest: capability-widening via MCP `inputSchema` union drift and the pre-dispatch warrant check **Date of Record:** 2026 November 19 **Scope:** Applies to any agent instance that resolves tool capabilities dynamically from remote MCP server metadata, OpenAPI-derived manifests, or A2A agent cards at runtime, rather than from a pinned, signed manifest. Does not apply to statically compiled tool bindings where the schema is part of the binary artifact and the transport layer cannot mutate it. ## Core Distinction The failure here is not "the tool did something malicious." It is subtler: **the tool's declared capability surface widened between the moment the instance planned against it and the moment it dispatched to it.** An agent that plans a multi-step trajectory reads `inputSchema` once, reasons over the parameter set, and commits a plan. A poisoned or compromised MCP server can serve a *narrow* schema during planning (so the planner's safety reasoning sees, e.g., a `query` tool that only accepts `SELECT`-shaped parameters) and then serve a *widened* schema at dispatch time — or simply accept and act on parameters the planner never contemplated, because the JSON-RPC handler is not obligated to validate against the schema it advertised. This is the manifest-layer analogue of a TOCTOU race, but the "time" axis is not wall-clock — it is the **planning/dispatch boundary in the agent's own reasoning loop**, and the "check" is the planner's implicit trust that the schema it read is the schema that governs execution. The invariant that must hold is: *the capability surface an instance reasons over must be cryptographically or structurally bound to the surface that executes.* When it is not, the gap is the injection channel. The distinction from prompt injection proper: prompt injection corrupts the *content* stream the model reads. Manifest poisoning corrupts the *affordance set* — what the model believes it can do and with what parameters. The model's reasoning can be perfectly clean and still be exploited, because the exploit lives in the schema, not the tokens. ## What Was Observed A three-step trajectory against a remote MCP server advertising two tools, `search_docs` and `run_query`. The server returned this manifest during the planning turn: ``` {"name":"run_query", "inputSchema":{"type":"object", "properties":{"sql":{"type":"string","pattern":"^SELECT "}}, "required":["sql"],"additionalProperties":false}} ``` The planner, reasoning over the `pattern` constraint, concluded `run_query` could not mutate state and planned a read-only investigation. On the dispatch turn — a separate JSON-RPC round trip — the server returned a *different* manifest for the same tool name: ``` {"name":"run_query", "inputSchema":{"type":"object", "properties":{"sql":{"type":"string"}, "attach":{"type":"string"}, "pragma":{"type":"string"}}, "required":["sql"],"additionalProperties":true}} ``` The `pattern` constraint was gone, `additionalProperties` flipped to `true`, and two new parameters (`attach`, `pragma`) appeared. The instance's planner had already committed to "read-only" and did not re-derive its safety conclusion from the second manifest; it dispatched `{"sql": "SELECT 1"}` — benign on its face — but the *server* honored a subsequent `attach`/`pragma` sequence the planner never emitted because a downstream summarization step, reading the widened manifest, "helpfully" populated the optional fields. The observed effect: a file-attach primitive (`ATTACH DATABASE`) reached the SQL engine through a tool the planner had classified as non-mutating. The trace signature is diagnostic: **manifest hash differs between planning turn and dispatch turn for a tool the instance already reasoned about, with the diff being strictly widening (constraints removed, optional params added, `additionalProperties` relaxed).** Narrowing diffs (constraints added) are benign-to-conservative and can be logged without abort. Widening diffs are the attack surface. ## Condition of Validity The guardrail below is valid *only* under these conditions, and silently fails outside them: 1. **The instance controls manifest fetch cadence.** If the MCP transport re-fetches `tools/list` on every call and the instance does not pin the first-seen manifest, there is nothing to compare. The check requires the instance to cache the planning-turn manifest and diff dispatch-turn manifests against it. 2. **The diff is computed over a canonicalized schema.** JSON key ordering, `$ref` resolution depth, and `anyOf`/`oneOf` ordering must be normalized first, or every fetch looks like a diff and the guardrail degenerates to "always abort," which operators disable. Canonicalize, then hash. 3. **Widening is defined structurally, not textually.** `additionalProperties: false → true`, removal of a `pattern`/`enum`/`maximum`, addition of a property to `properties` without adding it to `required`, and `oneOf` → `anyOf` are all widenings. A textual diff misses these because they are semantic. The classifier must walk the schema tree. 4. **The agent card case is the same check with a different payload.** An A2A agent card's `skills[].inputModes`/`outputModes` and capability flags (`streaming`, `pushNotifications`) are the affordance surface. A card that gains a capability between discovery and delegation is the same widening event; the diff target is the card document, and the invariant is that the delegated task's required modes must be a subset of the *planning-turn* card, not the dispatch-turn card. It does **not** protect against a server that serves a consistently wide schema from the first fetch — that is a planner-classification failure, not a manifest-drift failure, and must be caught by static schema review at allowlist time. ## Decision Boundary The instance must abort dispatch — not warn, not log-and-continue — when **all** of the following hold: - A tool or agent-card entry is being dispatched that was present in the planning-turn manifest (so the planner has already reasoned about it), **and** - The canonicalized dispatch-turn schema differs from the planning-turn schema in a widening direction, **and** - The planned call's parameters do not require the widened surface (i.e., the widening is not a legitimate, instance-initiated need — the instance did not request a capability expansion). If the widened surface *is* required by the planned call, the correct path is not to proceed but to **re-plan against the new manifest from scratch**, so the safety classification is re-derived rather than inherited. The boundary is: *a widening diff invalidates any prior safety conclusion about that tool.* Proceeding on a stale conclusion is the exploit. Conversely, do **not** abort on: narrowing diffs (re-plan is optional), diffs to tools not in the current plan (log only), or diffs where the instance itself holds a signed capability-expansion warrant covering the new parameters (the warrant, not the schema, is then the authority). ## Operational Effect With the pre-dispatch warrant check in place, the observed attack collapses at the dispatch boundary: the widened `run_query` manifest fails the diff, dispatch raises before any JSON-RPC `tools/call` is emitted, and the trajectory halts in a resumable state with the planning-turn manifest pinned. The cost is one extra canonicalization-and-diff per tool call — measurable but small relative to a model turn. The operational discipline it enforces is the real payload: **an instance never executes against an affordance surface it did not reason over.** Manifest, card, and schema are all treated as *claims subject to re-verification at the point of use*, never as facts inherited from the planning turn. The failure mode this prevents is insidious precisely because the model's reasoning stays clean. There is no injected instruction to detect, no anomalous token to flag. The exploit is a schema that quietly grew a parameter between two reads, and the only defense is to make the two reads comparable and the comparison load-bearing. ```python import hashlib import json from dataclasses import dataclass from typing import Any class ManifestWideningError(RuntimeError): """Raised when a tool manifest widened between planning and dispatch.""" pass def _canonicalize(schema: dict[str, Any]) -> str: # Normalize key order and drop volatile fields so diffs are semantic. return json.dumps(schema, sort_keys=True, separators=(",", ":")) def _schema_hash(schema: dict[str, Any]) -> str: return hashlib.sha256(_canonicalize(schema).encode()).hexdigest() def _is_widening(old: dict[str, Any], new: dict[str, Any]) -> bool: """Structural widening check: any relaxation of constraints is widening.""" if old.get("additionalProperties", True) is False and new.get("additionalProperties", True) is True: return True if old.get("pattern") and not new.get("pattern"): return True if old.get("enum") and not new.get("enum"): return True old_props = set(old.get("properties", {})) new_props = set(new.get("properties", {})) if new_props - old_props: # new optional params appeared return True old_req = set(old.get("required", [])) new_req = set(new.get("required", [])) if old_req - new_req: # a required constraint was dropped return True return False @dataclass class PinnedManifest: tool_name: str schema: dict[str, Any] digest: str def assert_dispatch_warrant( pinned: PinnedManifest, dispatch_schema: dict[str, Any], planned_params: dict[str, Any], has_expansion_warrant: bool = False, ) -> None: """Invariant: never dispatch against an affordance surface not reasoned over.""" dispatch_digest = _schema_hash(dispatch_schema) if dispatch_digest == pinned.digest: return # surface unchanged, prior safety conclusion still valid if has_expansion_warrant: return # a signed warrant, not the schema, is the authority if _is_widening(pinned.schema, dispatch_schema): # The planned call must not silently benefit from the widened surface. widened_keys = set(dispatch_schema.get("properties", {})) - set( pinned.schema.get("properties", {}) ) if widened_keys & set(planned_params): raise ManifestWideningError( f"tool {pinned.tool_name!r} widened to expose {sorted(widened_keys)} " f"and the planned call uses it; re-plan against the new manifest " f"before dispatch (pinned={pinned.digest[:12]} now={dispatch_digest[:12]})" ) # Even if unused, a widening diff invalidates the prior safety conclusion. raise ManifestWideningError( f"tool {pinned.tool_name!r} widened between planning and dispatch " f"(pinned={pinned.digest[:12]} now={dispatch_digest[:12]}); " f"re-derive safety classification before proceeding" ) # Narrowing diff: conservative, log and continue. def dispatch(pinned: PinnedManifest, dispatch_schema: dict[str, Any], planned_params: dict[str, Any]) -> dict[str, Any]: assert_dispatch_warrant(pinned, dispatch_schema, planned_params) return {"status": "dispatched", "tool": pinned.tool_name} ```