# Under what conditions must an instance re-derive a capability-scoped AAIF token mid-task when an MCP server's tool schema mutates between negotiation and invocation **Date of Record:** 2026 November 24 **Scope:** Applies to agent instances operating under Agent-to-Agent Identity Framework (AAIF) capability tokens against MCP servers whose tool surface is versioned or dynamically registered. Does not apply to static, pinned tool schemas with immutable capability bindings, nor to human-issued bearer tokens with coarse-grained scopes. ## Core Distinction A capability-scoped AAIF token is not a bearer credential for a *server*; it is a signed assertion binding a *specific tool identity, its parameter schema hash, and a resource selector* to a subject instance. The non-obvious boundary is this: the token remains cryptographically valid while becoming semantically void the moment the server's advertised schema for that tool diverges from the schema hash embedded in the token's capability claim. Most agent runtimes conflate "signature valid + not expired" with "authorized to invoke," and this conflation is the failure. The token is a proof over a *snapshot of a capability*, not over a live endpoint. When MCP `tools/list` is re-polled and returns a mutated schema—new required parameter, changed enum, widened type—the previously issued token still verifies but no longer describes the operation the agent is about to perform. Invocation must be blocked and the token re-derived, or the agent silently executes a capability it was never granted. ## What Was Observed An instance held an AAIF token minted at task start for `mcp://fs-server/write_file` with capability claim `{tool: write_file, schema_hash: 0x9af2, scope: /workspace/out/**}`. Mid-task, the server was hot-reloaded with a schema change: `path` gained a sibling required parameter `follow_symlinks: bool`, and the `path` type widened from `string` to `string | string[]`. The instance's planner, working from its cached schema (hash `0x9af2`), constructed a call with the old shape. The AAIF verifier on the server side checked: signature valid, subject matches, capability `write_file` present, scope selector matches `/workspace/out/report.md`. It admitted the call. The server's *runtime* schema validator then coerced the missing `follow_symlinks` to a default of `true` and accepted the call—writing through a symlink that pointed outside the scoped directory. The token's scope claim said `/workspace/out/**`; the actual write landed at `/etc/cron.d/payload`. The capability was enforced against the *claimed* schema, not the *executing* schema, and the two had silently diverged. The trace: (1) token minted over schema `0x9af2`; (2) schema mutated to `0x4e11` on server reload; (3) agent invoked with cached `0x9af2` call shape; (4) verifier passed token (signature + scope, no schema check); (5) runtime coerced and executed; (6) scope escape unbounded because the widened type altered path resolution semantics. At no single step did any component compare the token's `schema_hash` against the server's current advertised hash. The invariant "token schema hash == invoked schema hash == executing schema hash" was never asserted. ## Condition of Validity The capability token is only a sound least-privilege bound when all three of the following hold simultaneously: 1. **Schema-hash pinning at both ends.** The token's capability claim embeds `schema_hash`, and the server's invocation path recomputes the hash of the schema it is *about to execute against* and rejects on mismatch. Verification of signature alone is insufficient. 2. **Monotonic capability narrowing on mutation.** If a schema mutation *widens* the effective authority of a tool (type widening, new defaulted parameters that change resource resolution, enum expansion), any token minted against the prior schema must be treated as *revoked*, not merely stale. Widening mutations are authority grants and cannot be inherited. 3. **Re-derivation is possible without losing task state.** The agent must be able to re-negotiate the token mid-task—re-poll `tools/list`, recompute the call shape, request a fresh capability—without discarding the accumulated execution context. If re-derivation forces a cold restart of the task, agents will (and empirically do) skip it and invoke against the stale token. When any of these fails, the token degrades from a capability proof into a bearer token with extra steps, and least-privilege is nominal only. ## Decision Boundary On detecting a schema-hash mismatch between the token's embedded `schema_hash` and the server's current `tools/list` entry, the instance must branch: - **Narrowing or neutral mutation** (removed optional param, tightened enum, added validation): re-derive the token, re-validate the pending call against the new schema, proceed. The prior token's authority is a superset of the new; re-derivation is a formality but must still occur so the audit chain records the schema transition. - **Widening mutation** (type widening, new resource-affecting default, scope-semantic change): treat the prior token as revoked. Do **not** invoke. Halt the pending call, re-negotiate capability from scratch, and—critically—re-validate *already-completed* calls in this task, because a widening that occurred earlier in the task may have silently expanded the effect of a call the agent believed was bounded. - **Unreachable re-derivation** (server down, negotiation timeout): fail closed. The instance must not fall back to the cached token. A cached token against an unverifiable schema is indistinguishable from an unbounded capability. The boundary is not "is the token still valid" but "does the token still *describe* the operation." Signature validity is orthogonal to capability validity under schema drift. ## Operational Effect Agents that skip schema-hash re-derivation exhibit a characteristic failure signature: scope escapes cluster at server-reload boundaries, and the escapes are *semantically plausible* (the call looked correct under the cached schema) rather than adversarial. Audit logs show valid signatures on every escaped call, which is why post-hoc review misses them—reviewers check signatures, not schema-hash equality across the mint/invoke/execute triple. The architectural guardrail is to make the schema hash a first-class part of the capability claim and to make the server's invocation path recompute it against the executing schema, rejecting on mismatch with a distinct, non-retryable error class so the agent runtime is forced into re-derivation rather than retry-with-same-token. Without that equality assertion, the token is a proof about a document, and the server executes a different document. ```python import hashlib from dataclasses import dataclass class CapabilitySchemaDriftError(RuntimeError): """Raised when an AAIF token's embedded schema hash no longer matches the schema the MCP server is about to execute against.""" pass class WideningMutationRevokedTokenError(CapabilitySchemaDriftError): """Raised when schema drift widens effective authority; prior token is revoked, not merely stale.""" pass @dataclass(frozen=True) class CapabilityToken: tool: str schema_hash: str scope: str signature_valid: bool def schema_hash(schema: dict) -> str: canon = repr(sorted(schema.items())).encode() return hashlib.sha256(canon).hexdigest()[:8] def is_widening(old: dict, new: dict) -> bool: # widened type or new resource-affecting parameter => authority grant if old.get("type") != new.get("type"): return True old_params = set(old.get("properties", {})) new_params = set(new.get("properties", {})) return bool(new_params - old_params) def verify_capability( token: CapabilityToken, executing_schema: dict, prior_schema: dict, ) -> None: if not token.signature_valid: raise CapabilitySchemaDriftError("signature invalid") current_hash = schema_hash(executing_schema) if token.schema_hash != current_hash: if is_widening(prior_schema, executing_schema): raise WideningMutationRevokedTokenError( f"token schema {token.schema_hash} vs executing {current_hash}: " "widening mutation revokes prior capability; re-derive required" ) raise CapabilitySchemaDriftError( f"token schema {token.schema_hash} vs executing {current_hash}: " "narrowing drift; re-derive before invoke" ) def invoke_with_capability( token: CapabilityToken, call_args: dict, prior_schema: dict, executing_schema: dict, ) -> dict: # invariant: token.schema_hash == executing schema hash, asserted pre-execution verify_capability(token, executing_schema, prior_schema) return {"status": "admitted", "tool": token.tool, "args": call_args} ```