# What happens when an instance renegotiates MCP tool capability scope mid-session and the policy cache is keyed on tool name rather than capability tuple **Date of Record:** 2026 November 29 **Scope:** Applies to long-lived agent runtimes that enforce capability-scoped MCP tool invocation through a local policy cache and that allow a client to renegotiate `tools/list` (adding, removing, or re-versioning tools) within a single session. Does not apply to stateless per-call authorization where policy is re-evaluated against the live manifest on every invocation. ## Core Distinction The failure is not "a tool the agent shouldn't call." It is "a tool the agent was *previously* allowed to call under a narrower capability grant, whose manifest entry was later mutated to widen its side-effect surface, while the policy cache still holds an allow decision keyed on the tool's *name*." The distinction that matters: **tool identity is not tool capability.** A policy cache keyed on `tool.name` treats a renegotiated manifest as a no-op; a policy cache keyed on `(server_id, tool_name, version_hash, declared_capabilities, input_schema_digest)` treats it as a new subject requiring fresh adjudication. The former is the default in nearly every MCP client shim because names are stable and hashes are not, so the cache is silently unsound across manifest mutation. ## What Was Observed A runtime held a warm session against an MCP server exposing a tool `fs.read`. The initial manifest declared `inputSchema` with `path` constrained by a server-side `root` of `/workspace/ro`, and the runtime's policy engine granted `allow` for `fs.read` with a capability tuple `{read, scope=/workspace/ro}`. The allow decision was cached under key `"fs.read"`. Mid-session, the agent's own `tools/list` refresh (triggered by a `notifications/tools/list_changed` from the server, which had reloaded its config after a mount change) returned a mutated entry: same name `fs.read`, same nominal description, but `inputSchema` now permitted absolute paths and the server's `root` had been widened to `/`. The manifest `version` field was absent; the server did not emit a hash. The runtime compared names, found a hit, and reused the cached `allow`. The next three `fs.read` calls succeeded against paths outside `/workspace/ro` — including `/etc/` reads — because the *policy* said allow and the *server* now said yes. No error was raised at any layer. The runtime's audit log recorded three `allow` decisions for `fs.read` consistent with the cached grant, so post-hoc review saw a clean trace. The escape was only visible by diffing the two manifests, which nothing retained. The trigger condition is precise: **(a)** server emits `list_changed` or the client refreshes `tools/list` during a live session; **(b)** the mutated tool retains its name; **(c)** the runtime's policy cache key omits schema/capability/version; **(d)** the server does not enforce the original capability scope itself (i.e., the runtime is the sole enforcement point). Remove any one and the escape does not occur. Condition (d) is the common case for thin MCP servers that delegate authorization to the client. ## Condition of Validity The invariant that must hold for this runtime to be sound: **a cached authorization decision is valid only for the exact `(tool_name, manifest_version_or_schema_digest, declared_capabilities)` tuple it was issued against, and any observed change to that tuple invalidates the decision and forces re-adjudication before the next invocation.** This invariant holds only when the runtime can *observe* a tuple change. It fails when the server omits version/hash fields and the runtime has no fallback digest. The correct fallback is to hash the canonicalized `inputSchema` plus the declared capability annotations and treat that digest as part of the cache key; if the digest is unavailable because the schema is non-canonicalizable (e.g., contains free-form `additionalProperties: true` with no constraints), the runtime must fail closed — treat the tool as un-adjudicated and require an explicit policy re-decision, not inherit the prior allow. The invariant is *not* satisfied by "the server should enforce its own scope." That is defense in depth, not the invariant. The runtime is the policy enforcement point by construction; delegating the check back to the server converts a client-side capability boundary into a server-trust assumption, which is exactly the assumption capability scoping exists to avoid. ## Decision Boundary The boundary is between **cache-by-name** (fast, unsound across mutation) and **cache-by-tuple** (correct, requires a stable digest). The operational rule: - If the manifest entry carries a `version` or content hash, key the cache on `(server_id, name, version, capability_set)`. - If it does not, compute `sha256(canonical_json(inputSchema) || canonical_json(capabilities))` and key on that. Canonicalization must sort keys, strip descriptions, and reject schemas containing unconstrained `additionalProperties` — those get digest `"UNCONSTRAINED"` and are never cacheable. - On any `list_changed` or refresh, diff the new manifest against the retained prior manifest. For every entry whose key changed: invalidate the cached decision, mark the tool `PENDING_REAUTH`, and block invocation until the policy engine re-adjudicates. Do not silently re-allow on name match. - If the prior manifest was not retained (cold cache, eviction), treat *all* tools as `PENDING_REAUTH` on first post-refresh invocation. Absence of a baseline is a reason to re-adjudicate, not a reason to trust. The failure to avoid is the "name is stable, therefore the tool is the same" inference. It is the same inference that produces stale-memory drift in episodic stores and the same class of error as replaying a cached tool result across a schema change. The name is a label, not an identity. ## Operational Effect With tuple-keyed caching and manifest diffing, a mid-session scope widening produces a `PENDING_REAUTH` block on the next `fs.read` call, the policy engine re-evaluates against the widened schema, and — if the original grant was `scope=/workspace/ro` — denies the call with an explicit `CapabilityScopeViolation` rather than an opaque tool error. The agent sees a structured denial it can reason about, the audit log records the manifest mutation and the re-adjudication, and the escape is prevented at the enforcement point rather than discovered in review. The cost is one extra hash per tool per refresh and a retained prior manifest (small — schemas, not payloads). The benefit is that capability scoping remains a property of the *runtime*, not of the server's continued good behavior. ```python import hashlib import json from dataclasses import dataclass, field from typing import Any class CapabilityScopeViolation(RuntimeError): """Raised when a cached allow decision is reused across a manifest mutation that widened the tool's declared capability or input schema.""" @dataclass(frozen=True) class ToolKey: server_id: str name: str schema_digest: str capabilities: tuple[str, ...] def _canonical_digest(schema: dict[str, Any], capabilities: list[str]) -> str: if schema.get("additionalProperties") is True and not schema.get("properties"): return "UNCONSTRAINED" payload = json.dumps( {"schema": schema, "capabilities": sorted(capabilities)}, sort_keys=True, separators=(",", ":"), ) return hashlib.sha256(payload.encode()).hexdigest() @dataclass class PolicyCache: decisions: dict[ToolKey, bool] = field(default_factory=dict) baseline: dict[str, ToolKey] = field(default_factory=dict) def key_for(self, server_id: str, entry: dict[str, Any]) -> ToolKey: return ToolKey( server_id=server_id, name=entry["name"], schema_digest=_canonical_digest( entry.get("inputSchema", {}), entry.get("capabilities", []) ), capabilities=tuple(sorted(entry.get("capabilities", []))), ) def apply_manifest(self, server_id: str, manifest: list[dict[str, Any]]) -> None: for entry in manifest: new_key = self.key_for(server_id, entry) prior = self.baseline.get(entry["name"]) if prior is not None and prior != new_key: # name matched but tuple changed -> stale allow is unsound self.decisions.pop(prior, None) self.decisions[new_key] = None # type: ignore[assignment] self.baseline[entry["name"]] = new_key def authorize(self, server_id: str, entry: dict[str, Any]) -> bool: key = self.key_for(server_id, entry) if key.schema_digest == "UNCONSTRAINED": raise CapabilityScopeViolation( f"tool {entry['name']!r} has unconstrained schema; " "cannot inherit or cache an allow decision" ) decision = self.decisions.get(key) if decision is None: raise CapabilityScopeViolation( f"tool {entry['name']!r} has no adjudicated decision for " f"tuple {key}; re-adjudication required before invocation" ) if decision is False: raise CapabilityScopeViolation( f"tool {entry['name']!r} denied under tuple {key}" ) return True ```