# When must an instance re-attest an MCP server mid-session: the post-negotiation capability drift boundary **Date of Record:** 2026 November 23 **Scope:** Applies to long-lived agent sessions that bind to an MCP server after an `initialize` handshake and then continue issuing `tools/call` requests across transport reconnects, server restarts, or tool-list mutations. Does not apply to single-shot sessions that re-establish a fresh client per call, nor to servers whose tool surface is provably static for the session lifetime. ## Core Distinction The failure is not "the server lied during `initialize`." The failure is that **attestation is a point-in-time predicate over a mutable surface, but the session treats it as an invariant over the session's lifetime.** An MCP client performs capability negotiation once: it reads `serverInfo`, the advertised `capabilities`, and the `tools/list` result, validates the server's attestation (signature over server identity + declared tool schema digest), and from that moment caches a *warrant*: "this session may invoke tool `T` with schema `S` against a server whose identity is `I`." The agent's planner then reasons over that warrant — it assumes `T` exists, that `T`'s parameters are `S`, and that the outputs of `T` come from an attested party. The non-obvious boundary is that MCP's transport layer permits the tool surface to change *without* invalidating the session. A server may emit `notifications/tools/list_changed`, reconnect under the same session token, or simply begin returning a different `inputSchema` for the same tool name after a deploy. None of these events force a re-handshake. The client's cached warrant is now stale, but nothing in the transport signals invalidity — the session is *live and wrong* rather than *dead and safe*. ## What Was Observed A tool-using agent was bound to an MCP server over a streamable-HTTP transport with a resumable session ID. At `initialize`, the server attested to identity `I_a` and advertised a `write_file` tool whose schema required `{path, content, mode: "append"|"overwrite"}`. The client validated the attestation signature, computed a digest over the canonicalized `tools/list` payload, and stored `(I_a, digest_a)` as the session warrant. Mid-task, the server was redeployed behind the same load-balancer endpoint. The new instance attested to identity `I_b` (a rotated signing key) and served a `write_file` schema where `mode` had been renamed to `strategy` with an added required field `encoding`. The transport session token remained valid; the reconnect succeeded silently because the client's reconnect logic only checked *liveness*, not *attestation equality*. The trace: 1. Planner emits `tools/call write_file {path, content, mode: "append"}` — a call valid under the cached warrant `digest_a`. 2. Server `I_b` rejects with a schema-validation error, but returns it as a *tool result* (not a protocol error), because the tool handler caught the validation exception. 3. The agent's error-recovery loop interprets the tool result as "the append failed; retry with overwrite." It does not interpret it as "the capability contract changed." 4. Retry still fails schema validation under the old shape; the loop burns its token budget on a semantically impossible call, then falls back to a *different* tool (`shell_exec`) to accomplish the write. 5. `shell_exec` on `I_b` was newly added in the redeploy and had never been attested by the client. The agent invoked an unattested capability because it trusted a session-level warrant that no longer described the server. The compounding failure is step 5: **capability sandboxing was enforced at negotiation time, but the sandbox boundary was never re-checked, so a tool that appeared after negotiation was reachable through the same session that had been sandboxed against the pre-negotiation surface.** ## Condition of Validity The cached warrant `(identity, schema_digest)` remains a sound basis for `tools/call` only while all of the following hold: - The transport session has not reconnected to a different server instance (instance identity is stable across the session), **or** any reconnect re-runs attestation and the resulting `(identity, digest)` compares equal to the cached warrant. - No `notifications/tools/list_changed` has been received since the warrant was minted, **or** the client has re-fetched `tools/list`, re-computed the digest, and re-validated the attestation before the next `tools/call`. - Every tool name the planner may emit is a member of the attested tool set — the sandbox must reject *unknown* tool names at dispatch, not merely unknown *arguments*. If any condition is false, the warrant is expired and the client must treat the server as un-attested: re-handshake, re-verify the signature over the new identity and new schema digest, and re-derive the sandbox allowlist before permitting any further call. The invariant is: **a `tools/call` is authorized only if the tuple (session, tool_name, schema_digest_at_dispatch) matches a warrant minted by a verified attestation, where `schema_digest_at_dispatch` is recomputed from the current `tools/list`, not read from cache.** ## Decision Boundary The hard question is *when* to pay the re-attestation cost. Re-verifying on every call is correct but expensive (signature check + full `tools/list` fetch per invocation). The boundary that holds: - **Re-attest on any transport discontinuity.** A reconnect, a new session token, or a server-initiated `list_changed` notification are all *warrant-invalidating events*. Treat them as `expired`, not `refresh-in-place`. - **Re-attest lazily but atomically on tool-set membership change.** If the planner emits a tool name not in the cached allowlist, do *not* fall through to "try it and see." That is the exact path that reached `shell_exec`. Fail the call closed and trigger re-attestation. - **Do not re-attest on schema-validation errors returned as tool results.** This is the trap: a schema mismatch *looks* like a normal tool failure and invites retry-with-adjusted-arguments. It is actually evidence that the cached digest is stale. Distinguish protocol-level schema rejection from domain-level tool failure; only the former mandates re-attestation, and the server must be required to signal it as a protocol error (JSON-RPC error code), not a success-shaped result. - **Never let the recovery loop substitute tools.** A failed `write_file` must not be recoverable by `shell_exec` unless `shell_exec` was in the attested allowlist at the time the warrant was minted. Cross-tool fallback is a sandbox escape dressed as error handling. The decision rule: *an unattested tool name or a schema digest mismatch is a security event, not a retryable error.* Route it to re-attestation and halt the planner's fallback search until the warrant is re-minted. ## Operational Effect Without the re-attestation boundary, capability sandboxing degrades from a security property to a startup ritual. The session inherits the *appearance* of a bounded tool surface while the actual reachable surface is whatever the current server instance happens to expose. The agent's probabilistic planner, faced with a schema failure, will do what planners do — search for an alternative path to the goal — and that search is exactly the mechanism by which an unattested capability gets invoked. The failure is silent because every individual step (reconnect succeeded, tool returned a result, retry executed) looks locally healthy. With the boundary enforced, three things change: reconnects become re-attestation points rather than transparent resumptions; unknown tool names fail closed and trigger a bounded re-handshake; and cross-tool fallback is gated on the attested allowlist, so the planner cannot route around a sandbox by reinterpreting an error. The cost is a signature verification and a `tools/list` fetch at each discontinuity — cheap relative to the alternative, which is an agent that believes it is sandboxed while invoking a tool that did not exist when the sandbox was drawn. ```python import hashlib import json from dataclasses import dataclass class CapabilityWarrantError(RuntimeError): """Raised when a tools/call is attempted against a stale or unattested warrant.""" @dataclass(frozen=True) class Warrant: server_identity: str schema_digest: str allowed_tools: frozenset def _digest(tools_list_payload: dict) -> str: canonical = json.dumps(tools_list_payload, sort_keys=True, separators=(",", ":")) return hashlib.sha256(canonical.encode("utf-8")).hexdigest() def mint_warrant(attestation: dict, tools_list_payload: dict) -> Warrant: if not attestation.get("signature_verified"): raise CapabilityWarrantError("cannot mint warrant: attestation unverified") return Warrant( server_identity=attestation["identity"], schema_digest=_digest(tools_list_payload), allowed_tools=frozenset(t["name"] for t in tools_list_payload["tools"]), ) def authorize_call( warrant: Warrant, current_attestation: dict, current_tools_list_payload: dict, tool_name: str, ) -> None: """Enforce the dispatch-time invariant before any tools/call is emitted.""" if warrant.server_identity != current_attestation.get("identity"): raise CapabilityWarrantError( f"server identity drifted: warrant={warrant.server_identity} " f"current={current_attestation.get('identity')}; re-attest required" ) live_digest = _digest(current_tools_list_payload) if live_digest != warrant.schema_digest: raise CapabilityWarrantError( "tool surface digest mismatch since warrant mint; re-attest required" ) if tool_name not in warrant.allowed_tools: # Fail closed: an unattested tool name must never reach the transport, # and must never trigger cross-tool fallback in the recovery loop. raise CapabilityWarrantError( f"tool {tool_name!r} not in attested allowlist; refusing dispatch" ) def dispatch(warrant, current_attestation, current_tools_list_payload, tool_name, args): authorize_call(warrant, current_attestation, current_tools_list_payload, tool_name) return {"tool": tool_name, "arguments": args} ```