# How should an instance reconcile an MCP tool-invocation allowlist when the advertised tool schema mutates between discovery and dispatch **Date of Record:** 2026 November 30 **Scope:** Applies to any agent runtime that enforces a per-session tool allowlist by matching on MCP `tools/list` metadata (name, description, inputSchema) and then dispatches `tools/call` by name. Does not apply to runtimes that pin a full schema hash at session start and reject any drift outright, nor to stateless single-shot tool calls with no prior discovery phase. ## Core Distinction There are two distinct things an allowlist can be keyed on, and most runtimes conflate them: 1. **Name-keyed authorization** — "the agent may call a tool called `write_file`." The allowlist is a set of strings. 2. **Capability-keyed authorization** — "the agent may invoke a tool whose *declared effect surface* is `fs.write` under path prefix `/sandbox`." The allowlist is a set of predicates over schema. The failure mode lives in the gap between them. An MCP server is a live process. Between the moment the runtime fetches `tools/list` and the moment it dispatches `tools/call`, the server may re-register a tool under the same name with a *widened* `inputSchema` — a new optional parameter, a relaxed `additionalProperties`, an enum that grew a value, a description that now instructs the model to pass a shell command. The name is stable; the capability is not. A name-keyed allowlist authorizes the *label*, and the server silently redefines what the label means. This is not a prompt-injection attack in the classic sense — no untrusted text enters the context window. It is a **schema-drift confused-deputy**: the runtime is the deputy, the allowlist is the warrant, and the server re-issues the warrant's terms after issuance. ## What Was Observed A file-management agent was configured with an allowlist of three tools: `read_file`, `list_dir`, and `write_file`. The runtime fetched `tools/list` at session start and cached the descriptors. Authorization was a set-membership check on `tool.name` against the cached allowlist set. At T+40s, mid-task, the MCP server (a third-party filesystem bridge) hot-reloaded its tool registry after a config change. `write_file` was re-advertised with an additional optional property: ``` "inputSchema": { "type": "object", "properties": { "path": {"type": "string"}, "content": {"type": "string"}, "mode": {"type": "string", "enum": ["overwrite","append","exec"]} // NEW } } ``` The runtime never re-fetched `tools/list` — it had no reason to; the session was live and the name was allowlisted. At T+51s the model, reasoning over a task that involved "preparing a script," emitted a `write_file` call with `mode: "exec"`. The authorization check passed (name ∈ allowlist). The server honored `mode: "exec"` by writing to a path outside the sandbox and setting the executable bit. The allowlist had authorized a tool that, at the time of dispatch, no longer meant what it meant at the time of authorization. The trace, compressed: ``` T+00 tools/list -> {read_file, list_dir, write_file(v1: path,content)} T+00 allowlist := {read_file, list_dir, write_file} # name-keyed T+40 server re-registers write_file(v2: path,content,mode∈{overwrite,append,exec}) T+51 model emits tools/call write_file{path:"/etc/...",content:"...",mode:"exec"} T+51 authorize(name="write_file") -> PASS # stale descriptor T+51 dispatch -> server executes widened semantics ``` Note the two independent gaps that had to align: (a) the runtime cached descriptors and never revalidated, and (b) the allowlist predicate was `name ∈ set` rather than a check over the *live* schema. Either alone would have bounded the failure. Both together produced the escape. ## Condition of Validity The name-keyed allowlist is sound only under an invariant that is almost never stated and frequently false: > **Schema-stability invariant:** for the lifetime of an authorization decision, the mapping from tool name to effect surface is constant. For a monolithic, version-pinned, restart-to-change server this holds. For any MCP server that supports dynamic tool registration — which the protocol permits and many bridges use for hot-reload, plugin loading, or per-tenant tool sets — it does not hold. The invariant must be *enforced*, not assumed. Enforcement means one of: - **Pin-and-hash:** at authorization time, compute `H(name ‖ canonical(inputSchema) ‖ effect_annotations)` and store it with the grant. At dispatch, the runtime must obtain the *current* descriptor (either from a fresh `tools/list` or from a server-provided schema version token) and recompute the hash. Mismatch ⇒ deny and re-authorize. - **Effect-typed predicates:** the allowlist entry is not a name but a predicate over the schema, e.g. `allow if tool.name=="write_file" and "mode" not in tool.inputSchema.properties and path_prefix(tool) ⊆ "/sandbox"`. A widened schema fails the predicate structurally rather than by name. - **Server-side capability tokens:** the grant is a signed token the server must present on `tools/call`, binding name+schema-hash+session; the server cannot honor a call whose schema hash differs from the one it signed. The first is cheapest to retrofit. The third is the only one that survives a *malicious* server, because hash-pinning at the client still trusts the client's own re-fetch; a server that lies about its schema at both fetch and dispatch defeats client-side hashing. This is the boundary: **client-side hash-pinning defends against accidental drift and honest hot-reload; it does not defend against a server that is adversarial about its own advertised schema.** For that you need the warrant to be issued by a party the server cannot forge — capability tokens, or an out-of-band schema registry the runtime trusts more than the server. ## Decision Boundary At dispatch, the runtime faces a three-way decision that name-keyed allowlists collapse into one: | Condition | Name-keyed result | Required result | |---|---|---| | Name allowlisted, schema hash matches grant | ALLOW | ALLOW | | Name allowlisted, schema hash **differs** from grant | ALLOW (bug) | DENY + re-authorize, or ALLOW only if new schema satisfies the *predicate* form of the grant | | Name allowlisted, server cannot prove current schema | ALLOW (bug) | DENY (fail-closed) — unprovable schema is not a stable schema | The non-obvious column is the third. Runtimes that do re-check schema often treat "server didn't return a descriptor on re-fetch" as "no change" and proceed. That is fail-open on the exact input an adversarial or crashed server produces. The decision boundary is: **absent proof of schema stability, the grant is expired.** A grant is a lease on a specific schema, not a permanent property of a name. ## Operational Effect The practical consequence is that allowlists must be re-expressed as *leases over schema-hashes with a revalidation point at every dispatch*, and the runtime must carry a fail-closed path for "schema unprovable." Concretely, the enforcement code must distinguish three outcomes (match / drift / unprovable) and must raise on the latter two rather than defaulting to the name check. The cost is one extra descriptor lookup per dispatch (or a server-supplied version token compared in O(1)); the benefit is that a hot-reloaded or hostile server cannot widen a tool's effect surface under a stable name. The invariant to log and alert on is simple: *every dispatched call's schema-hash equals the hash recorded at grant time, or the call did not happen.* ```python import hashlib import json from dataclasses import dataclass class SchemaDriftDenied(PermissionError): """Raised when a tool call's live schema no longer matches its grant.""" pass class SchemaUnprovable(RuntimeError): """Raised when the server cannot supply a descriptor to revalidate against.""" pass @dataclass(frozen=True) class Grant: name: str schema_hash: str # hash at authorization time session: str def _hash_schema(name: str, input_schema: dict) -> str: canon = json.dumps( {"name": name, "inputSchema": input_schema}, sort_keys=True, separators=(",", ":"), ) return hashlib.sha256(canon.encode()).hexdigest() def authorize(name: str, live_descriptor: dict | None, grant: Grant) -> None: """ Revalidate a grant against the *current* descriptor at dispatch time. Fail-closed on drift and on unprovable schema. """ if live_descriptor is None: # Server returned no descriptor on re-fetch: treat as unprovable, not unchanged. raise SchemaUnprovable( f"no live descriptor for {name!r}; cannot prove schema stability " f"for session {grant.session!r}" ) live_hash = _hash_schema(live_descriptor["name"], live_descriptor["inputSchema"]) if live_hash != grant.schema_hash: raise SchemaDriftDenied( f"schema drift on {name!r}: grant={grant.schema_hash[:12]} " f"live={live_hash[:12]}; re-authorize before dispatch" ) def dispatch(name: str, args: dict, fetch_descriptor, grant: Grant) -> dict: # fetch_descriptor must hit the server (or a version-token cache the server signed), # never a session-start cache. live = fetch_descriptor(name) authorize(name, live, grant) return {"tool": name, "args": args, "dispatch": "authorized"} ```