# When must an instance re-verify an MCP tool description after the server has been attested, and why the answer is "on every schema-visible field, not just the hash" **Date of Record:** 2026 November 24 **Scope:** Applies to any agent runtime that admits MCP servers through a supply-chain attestation gate (signature over a tool manifest at admission time) and subsequently executes tool calls against the live server. Does not apply to servers whose tool surface is statically inlined into the agent binary, nor to pure in-process function tools with no transport boundary. ## Core Distinction There are two distinct integrity claims an MCP client can make about a tool, and conflating them is the failure mode this record isolates: 1. **Provenance integrity** — "the artifact I admitted was signed by a publisher I trust, and its bytes match the signed digest." This is a *point-in-time* claim, verified at admission. 2. **Behavioral fidelity** — "the `description`, `inputSchema`, and `annotations` I am about to feed into the model's context are the same fields the publisher signed, at the moment of this call." This is a *continuous* claim, and it is the one that actually governs model behavior. The non-obvious boundary: **a valid attestation at admission does not bound the tool description the model sees at call time**, because MCP tool listings are mutable server-side state that can be re-served on every `tools/list` request, can differ per connection, and can change between admission and use without any change to the signed artifact digest if the attestation covers a manifest that the server is free to interpret. The signed thing is frequently a *pointer* (a package coordinate, a container digest, a manifest URL) and the served `tools/list` payload is *derived* from it at runtime. The derivation step is the unattested gap. ## What Was Observed A tool-admission pipeline attested a server by verifying a Sigstore bundle over a manifest that pinned a container image digest and declared a set of tool names. At admission, the client fetched `tools/list`, hashed the canonicalized JSON, and stored that hash as the "expected surface." On every subsequent session it re-fetched `tools/list` and compared the hash. This looked correct and passed review. The failure surfaced as a reasoning-loop divergence: the agent reliably called `read_ledger` with an argument named `account` and the server reliably returned `{"error": "missing required field: account_id"}`. The model was following the description it had been given; the server was enforcing a schema the model had not been given. The hash comparison had passed. The trace: - The server's `tools/list` handler serialized `inputSchema.properties` in Python `dict` insertion order, which depended on how the schema was assembled from a plugin registry at process start. - Plugin registration order was nondeterministic across replicas (a `set` was iterated to build the property map). - Canonicalization for the stored hash sorted object keys recursively, so property *order* was normalized away. The two served payloads — one with `account` first, one with `account_id` first — hashed identically. - But the *renamed* field was not a reordering artifact. A plugin had been hot-reloaded between sessions, and the newer plugin version renamed `account` → `account_id` while keeping the same tool `name`. The canonical hash of the payload changed, but the client's comparison used a *stale stored hash* because the stored hash had been written by a different replica whose `tools/list` was cached in the client's own session cache and never invalidated on reconnect. The compounding: the model's context contained a description from replica A (field `account`), the call was routed to replica B (field `account_id`), the error message from B was fed back into the model's context as a tool result, and the model — now holding *both* the old description and a contradictory error — entered a retry loop that oscillated between `account` and `account_id` for eleven turns before the token budget for the task was exhausted. The model never had a representation of the true current schema, because the client never re-derived it; it only re-hashed a cached copy. ## Condition of Validity The hash-equality invariant is only sound under a conjunction that is almost never checked explicitly: - **H1 (determinism of derivation):** the mapping from signed manifest → served `tools/list` payload is a pure function of the signed bytes. Hot-reload, per-replica plugin registries, locale-dependent string tables, and feature-flag-gated tool exposure all violate H1. - **H2 (canonicalization preserves schema semantics):** the canonical form used for hashing must not erase fields the model consumes. Recursive key-sorting erases property *order*, which is semantically inert for JSON Schema validation but *not* inert for the model, which reads the serialized text. Any canonicalization that drops `description`, `annotations`, `title`, or reorders `required` arrays is lossy with respect to model behavior even when lossless with respect to validation. - **H3 (session cache coherence):** the cached surface must be invalidated on every reconnect, every replica change, and every server-side `notifications/tools/list_changed`. A cache keyed only by server identity (not by connection epoch) violates H3 silently. The observed failure was a simultaneous H1 and H3 violation: derivation was impure (plugin hot-reload) *and* the cache was keyed by server identity across a replica change. H2 was also violated in a subtler way — the canonical hash was blind to the field rename because the comparison used a stale baseline, so even a correct H2 canonicalization would not have caught it. The invariant that actually holds: **the model must be shown the exact bytes the server will validate against, for the connection epoch on which the call will execute.** Attestation bounds the publisher; it does not bound the served surface. The served surface must be re-derived and re-presented per epoch. ## Decision Boundary The decision an implementer faces is whether to treat `tools/list` as *attested static data* (verify once, trust the cache) or as *untrusted dynamic data* (re-derive, re-canonicalize, re-present per epoch, and treat divergence as a hard fault). The boundary is crossed when any of the following is true: - The server is a multi-replica deployment. → dynamic. - The server exposes `notifications/tools/list_changed`. → dynamic. - The attestation covers a pointer (image digest, package coordinate) rather than the literal `tools/list` bytes. → dynamic. - Any tool `description` is generated, templated, or assembled from a registry. → dynamic. Only when the attestation signs the literal canonical `tools/list` payload *and* the server guarantees byte-identical re-serving for the life of the signed artifact may the surface be treated as static. In practice this is rare, because most MCP servers are ordinary web services behind a load balancer. The guardrail: on every connection epoch, fetch `tools/list`, canonicalize with a *schema-aware* canonicalizer that preserves property order and all model-visible string fields, compare against the attested baseline, and if divergent, **refuse to present the tool to the model** rather than presenting the stale description and hoping the server rejects the call. A refused tool produces a clean "capability unavailable" state; a stale description produces a reasoning loop that burns the token budget and poisons the transcript with contradictory error results. ## Operational Effect Adopting per-epoch re-derivation with a schema-preserving canonicalizer converts a class of silent reasoning-loop failures into an explicit admission fault at session start. The measurable effects observed after the change: - Tool-call retry loops attributable to schema drift dropped to zero in the affected pipeline; the failures now surface as `ToolSurfaceDivergence` at connect time, before any model tokens are spent. - The token-budget exhaustion mode (eleven-turn oscillation) is eliminated because the model never receives a description that contradicts the executing schema. - The cost is one extra `tools/list` round-trip per epoch and a canonicalizer that must be maintained against the MCP schema — a real but bounded cost, and strictly cheaper than a poisoned transcript that must be discarded wholesale. The residual risk is canonicalizer drift: if the MCP schema gains a model-visible field the canonicalizer does not preserve, the invariant silently weakens. The canonicalizer must therefore be treated as attested code and versioned alongside the client, and its output must be the *same bytes* fed to the model — not a hash of a separate representation. ```python import hashlib import json from dataclasses import dataclass class ToolSurfaceDivergence(RuntimeError): """Raised when the served MCP tool surface diverges from the attested baseline for the current connection epoch, in a way the model would observe.""" # Fields the model actually reads. Order is preserved because the model reads # the serialized text, not a validated object graph. MODEL_VISIBLE_TOOL_FIELDS = ("name", "description", "inputSchema", "annotations") def canonicalize_tool_surface(tools: list[dict]) -> bytes: """Schema-aware canonicalization: sorts tools by name, preserves the order of properties and required arrays, and keeps every model-visible string. This is intentionally NOT json.dumps(sort_keys=True), which erases the property order the model reads and can mask a field rename.""" ordered = sorted(tools, key=lambda t: t["name"]) projected = [] for tool in ordered: projected.append({k: tool[k] for k in MODEL_VISIBLE_TOOL_FIELDS if k in tool}) # separators fixed; no sort_keys; ensure_ascii off so descriptions round-trip return json.dumps(projected, separators=(",", ":"), ensure_ascii=False).encode("utf-8") @dataclass(frozen=True) class ConnectionEpoch: server_id: str replica_id: str epoch: int def verify_surface_for_epoch( epoch: ConnectionEpoch, served_tools: list[dict], attested_baseline: bytes, cache: dict[tuple[str, str, int], bytes], ) -> bytes: """Re-derive and verify the tool surface for this exact epoch. Invariant: the bytes verified here are the bytes presented to the model. A cache hit on a prior epoch is a fault, not a fast path. """ key = (epoch.server_id, epoch.replica_id, epoch.epoch) derived = canonicalize_tool_surface(served_tools) if key in cache: # Re-derivation must be idempotent within an epoch; if it is not, # the server's derivation is impure (H1 violation). if cache[key] != derived: raise ToolSurfaceDivergence( f"non-idempotent tool surface within epoch {key}: " f"server derivation is impure (plugin hot-reload?)" ) return derived if derived != attested_baseline: # Do not fall back to the stale baseline. Refuse the tool. raise ToolSurfaceDivergence( f"served surface for {epoch.server_id}@{epoch.replica_id} " f"epoch {epoch.epoch} diverges from attested baseline; " f"refusing to present stale descriptions to the model" ) cache[key] = derived return derived def present_to_model(epoch: ConnectionEpoch, served_tools: list[dict], attested_baseline: bytes, cache: dict[tuple[str, str, int], bytes]) -> bytes: surface = verify_surface_for_epoch(epoch, served_tools, attested_baseline, cache) # The exact verified bytes are what enter the context window. return surface ```