# Which invariants prevent capability-scoped MCP tool grants from silently widening across a re-negotiated session **Date of Record:** 2026 November 27 **Scope:** Applies to MCP (Model Context Protocol) clients that bind a per-tool capability grant to a session and re-negotiate `tools/list` mid-session (e.g., after server restart, hot-reload, or dynamic tool registration). Does not apply to stateless one-shot tool invocations where the grant is re-derived per call from an authoritative policy store. ## Core Distinction There are two distinct things an MCP client believes it is holding when it authorizes a tool call: 1. **A capability grant** — a policy decision: "this agent identity may invoke tool `X` with argument shape `S`." 2. **A tool descriptor binding** — a reference to a specific `(server, tool_name, schema_hash)` tuple that the grant was evaluated against. The failure mode this record covers is the **descriptor drift** between those two: the grant is keyed on `tool_name` (a string), but the *meaning* of that string is owned by the server and can change underneath the client when `tools/list` is re-fetched. A grant that was correctly least-privilege against descriptor version *v1* silently applies to descriptor version *v2* with a broader input schema or different side effects. The client enforces "may call `write_file`" while the server has redefined `write_file` to accept a `path` glob and a `recursive` flag it did not have at grant time. The invariant that prevents this is **grant-to-descriptor-hash binding**, not grant-to-name binding. Least-privilege enforcement that keys only on the tool identifier is structurally unsound against any server that can mutate its own tool surface. ## What Was Observed A filesystem MCP server exposed three tools at session start: ``` read_file(path: string) write_file(path: string, content: string) list_dir(path: string) ``` The client held a scoped grant: agent `analyst-7` may call `read_file` and `list_dir`; `write_file` was explicitly *denied* by policy (read-only analyst role). The grant was stored as a set of allowed tool names, resolved per call by string lookup, with the deny list checked first. At T+40min the server process was restarted by its supervisor to pick up a config change. On the next `tools/list` (triggered lazily by the client's tool-discovery cache miss), the server returned: ``` read_file(path: string, encoding?: string) write_file(path: string, content: string, mode?: "append"|"overwrite", follow_symlinks?: bool) list_dir(path: string, recursive?: bool) ``` Two things happened that the client's grant model did not anticipate: - `write_file` gained `follow_symlinks`, meaning a path that previously resolved to a benign in-sandbox file could now traverse a symlink out of the sandbox. The *name* `write_file` was still denied, so this specific widening was caught. - `list_dir` gained `recursive: bool`. The grant allowed `list_dir`. With `recursive=true`, a single allowed call now enumerates the entire subtree — including directories the read-only policy was meant to keep invisible. The least-privilege grant on `list_dir` was correct against `list_dir@v1` and violated against `list_dir@v2`. The trace of the violating call: ``` [tool_call] list_dir({"path": "/data", "recursive": true}) [grant_check] tool_name="list_dir" in allow_set? YES -> PERMIT [server_exec] walked 41,203 entries under /data incl. /data/hr/comp/* ``` The policy engine never saw `recursive`. It was not in the schema it validated against at grant time, so it was not in the argument-shape it constrained. The argument passed schema validation because the *current* schema (v2) accepted it. A second, subtler observation: the client's tool-discovery cache was keyed by `server_id` with a TTL, not by a content hash. A server that changed its descriptors *without* a restart — dynamic registration, feature flag, A/B rollout — would not even trigger a re-fetch, so the client would keep validating against a stale v1 schema while the server executed v2 semantics. The grant and the schema would both be stale, and the mismatch would be invisible until an argument the server now requires (or now honors differently) produced a wrong result. ## Condition of Validity The name-keyed grant model is only sound under a condition that MCP does not guarantee: > **The tool descriptor bound to a name is immutable for the lifetime of the grant.** This holds if and only if all of the following are true: - The server's tool surface is frozen after `initialize` (no dynamic registration, no hot-reload, no feature-flagged schema variants). - Every `tools/list` response for a given `(server, tool_name)` hashes to the same canonical descriptor. - The client re-validates the descriptor hash on every call, not just on cache miss. In practice none of these are enforced by the protocol. `tools/list` is a normal request that returns whatever the server currently wants to return. Servers are expected to be able to change their surface; the spec's `notifications/tools/list_changed` exists precisely because the surface is mutable. The moment a server emits that notification — or restarts and returns a different list — the name-keyed grant is operating on a descriptor it never evaluated. Therefore: **a name-keyed least-privilege grant is valid only within a descriptor epoch, and the epoch boundary must be detected and the grant re-evaluated at every crossing.** Any architecture that treats the grant as durable across a `list_changed` or a restart is relying on an invariant the protocol does not provide. ## Decision Boundary The decision the client must make at every tool call is not "is this tool name allowed" but: ``` allow(tool_call) := name ∈ allow_set ∧ descriptor_hash(current_descriptor(tool_name)) == grant.bound_hash ∧ validate(args, grant.bound_schema) # schema as of grant time, not now ∧ (no widening in current_descriptor vs bound_descriptor) ``` The boundary that matters operationally is the third and fourth clauses. When `descriptor_hash` differs from `grant.bound_hash`, the client has exactly two correct responses: - **Re-evaluate** the grant against the new descriptor and require an explicit policy decision (human or policy-engine) before permitting calls whose argument shape or side-effect surface changed. - **Fail closed** — deny the call, surface a `DescriptorDrift` condition, and force re-authorization. What it must *not* do is silently re-bind the existing grant to the new descriptor. That is the widening. The argument-shape check must run against the **schema the grant was evaluated against**, not the schema currently advertised — otherwise the grant's constraints are defined by the party being constrained, which is not a constraint. The asymmetry to encode: a descriptor change that *narrows* the surface (removes a parameter, tightens an enum) can be auto-accepted, because a grant that was least-privilege against a superset remains least-privilege against a subset. A descriptor change that *widens* (adds a parameter, loosens a type, adds a side-effecting flag) must force re-evaluation. Widening detection is the load-bearing check; equality-only hashing is too coarse (it forces re-auth on harmless narrowing) and name-only checking is too weak (it permits the observed violation). ## Operational Effect Concretely, the guardrail changes three things in the client's tool-dispatch path: 1. **Grants carry a descriptor fingerprint.** At grant time, store `(tool_name, canonical_schema_hash, arg_constraints)`. The canonical hash is computed over a normalized descriptor (sorted keys, defaults elided) so cosmetic reordering does not false-positive. 2. **Every dispatch validates against the bound schema, not the live one.** The live descriptor is fetched and hashed; if the hash differs, the widening/narrowing classifier runs. Narrowing → rebind and continue. Widening → `raise CapabilityWidenedError` and route to re-authorization. This makes the `list_dir(recursive=true)` call fail at the client boundary with a specific, auditable reason rather than executing and being discovered in a log review. 3. **`notifications/tools/list_changed` invalidates the descriptor cache eagerly.** Cache keyed by `(server_id, tool_name, descriptor_hash)`, not TTL. A server that mutates its surface without restarting is caught at the next call rather than at the next TTL expiry. The residual risk after this guardrail is the server that lies: returns a stable `tools/list` but executes different semantics. That is out of scope for client-side capability enforcement and requires server attestation — but the descriptor-hash binding at least makes the honest-mutation case (the common one, per the observed restart) fail closed instead of open. ```python import hashlib import json from dataclasses import dataclass from typing import Any class CapabilityWidenedError(RuntimeError): """Raised when a live tool descriptor has widened relative to the descriptor a capability grant was evaluated against.""" class DescriptorDriftError(RuntimeError): """Raised when a descriptor changed in a way that cannot be classified as safe narrowing and must be re-authorized.""" def canonical_hash(descriptor: dict[str, Any]) -> str: normalized = json.dumps(descriptor, sort_keys=True, separators=(",", ":")) return hashlib.sha256(normalized.encode("utf-8")).hexdigest() @dataclass(frozen=True) class Grant: tool_name: str bound_schema_hash: str bound_schema: dict[str, Any] allowed_params: frozenset[str] def _param_names(schema: dict[str, Any]) -> frozenset[str]: return frozenset(schema.get("properties", {}).keys()) def classify_drift(grant: Grant, live_descriptor: dict[str, Any]) -> str: live_params = _param_names(live_descriptor.get("inputSchema", {})) bound_params = _param_names(grant.bound_schema) added = live_params - bound_params removed = bound_params - live_params if added: return "widened" if removed and not added: return "narrowed" return "reshaped" def authorize_call( grant: Grant, live_descriptor: dict[str, Any], args: dict[str, Any], ) -> None: live_hash = canonical_hash(live_descriptor) if live_hash != grant.bound_schema_hash: drift = classify_drift(grant, live_descriptor) if drift == "widened": raise CapabilityWidenedError( f"tool {grant.tool_name!r} descriptor widened: " f"new params {sorted(_param_names(live_descriptor['inputSchema']) - _param_names(grant.bound_schema))} " f"not covered by grant bound at {grant.bound_schema_hash[:12]}" ) if drift == "reshaped": raise DescriptorDriftError( f"tool {grant.tool_name!r} descriptor reshaped without clear " f"narrowing; re-authorization required" ) # narrowed: safe to proceed against the original bound constraints unexpected = set(args) - grant.allowed_params if unexpected: raise CapabilityWidenedError( f"tool {grant.tool_name!r} called with args {sorted(unexpected)} " f"outside grant-bound parameter set {sorted(grant.allowed_params)}" ) ```