# Which invariants prevent a signed MCP manifest from surviving tool-schema drift between build and first invocation **Date of Record:** 2026 November 28 **Scope:** Applies to MCP servers distributed as signed, reproducible-build artifacts where the manifest attests to a `tools/list` schema digest. Does not cover unsigned local-stdio servers, nor transport-layer auth (OAuth/mTLS) failures, which are orthogonal to manifest integrity. ## Core Distinction A signature over an MCP manifest proves *who attested to what bytes*, not that *the bytes still describe the tools the agent will call*. The failure this record isolates is **schema-digest drift at the manifest↔runtime boundary**: the signed manifest commits to a hash of the `tools/list` response captured at build time, but the shipped binary computes that response at runtime from code paths (environment-dependent feature flags, lazy-loaded tool registries, locale/version-gated tool sets) that are not fully pinned by the reproducible-build recipe. The signature verifies cleanly. The tool schema the agent receives does not match the schema the signature covers. Verification passes; integrity is void. This is distinct from a forged or tampered manifest (signature check catches that) and from a stale manifest (version pin catches that). It is the case where the signed artifact is authentic, the running artifact is authentic, and they still disagree — because the digest is over a *derived, environment-sensitive surface* rather than over the input bytes. ## What Was Observed A server exposing a `read_file` tool was built with a manifest whose `toolsDigest` was `sha256` over the canonicalized `tools/list` response. The build ran in a hermetic container with `FEATURE_SANDBOX_V2=on`, producing a schema where `read_file` declared parameters `{path: string, root: string}`. The signed manifest recorded that digest. At first invocation on the agent host, the server started without `FEATURE_SANDBOX_V2` set. The tool registry conditionally registered a legacy variant with parameters `{path: string}` only — no `root` scoping parameter. The runtime `tools/list` digest differed from the manifest's `toolsDigest`. The client's verification step, which checked *signature over manifest* but not *manifest digest over live `tools/list`*, passed. The agent then called `read_file` with `path` pointing outside any sandbox root, because the `root` parameter it would have used to scope the call no longer existed in the schema it received. The tool executed with the legacy, unscoped semantics. The trace: 1. Build: `tools/list` → schema S_build → digest D_build → embedded in manifest → manifest signed. 2. Distribute: signed binary + signed manifest shipped together. 3. Client verify: signature(manifest) valid → accept. **No live-schema check.** 4. Runtime: server evaluates `FEATURE_SANDBOX_V2` (unset) → registers legacy registry → `tools/list` → schema S_live ≠ S_build. 5. Agent: requests schema, receives S_live, calls `read_file{path}` — a call shape valid under S_live but *not* the shape the signer attested. 6. Effect: signed capability boundary (`root` scoping) silently absent at runtime. The non-obvious part: step 3 is where the invariant was assumed and where it was false. Signature verification of a manifest is a *static* check; schema integrity is a *dynamic* property of the running process. Conflating them is the boundary error. ## Condition of Validity The signed-manifest invariant "the schema the agent sees is the schema the signer attested" holds **only if** the `toolsDigest` is a digest over a function of the *pinned input closure* — i.e., over bytes that are bit-identical under the reproducible-build recipe — and **only if** the client re-derives that digest against the live `tools/list` at session establishment. Formally, let `D = H(canonical(tools_list(env)))`. The invariant requires: - `tools_list` be a pure function of the artifact bytes plus a *declared, manifest-committed* environment vector `E` (feature flags, registry version, locale). Any environment input not in `E` is an unpinned degree of freedom and breaks reproducibility of `D`. - The client compute `H(canonical(tools_list_live))` and compare to manifest `toolsDigest` *before* exposing tools to the agent's planner, not after. If either condition fails, the manifest attests to a schema that may not be the one in force. The signature remains valid; the *integrity claim it makes* does not transfer to runtime. ## Decision Boundary The boundary is: **is the `toolsDigest` a digest of pinned bytes, or of a runtime-evaluated surface?** - If `tools_list` depends only on artifact bytes → static manifest verification suffices; the digest is a build-reproducibility claim and the invariant holds transitively. - If `tools_list` depends on any environment input not committed in the manifest's declared `E` → the digest is a *sample*, not an attestation. Static verification is insufficient; the client MUST perform live re-derivation, and the server MUST refuse to start if its computed `toolsDigest` disagrees with the manifest. The guardrail is a **runtime digest gate**: the server, at startup, computes `H(canonical(tools_list))` under its actual environment and compares to the manifest's `toolsDigest`. Mismatch → refuse to serve (fail closed), because serving means offering tools the signer did not attest. Additionally, the manifest MUST enumerate `E` and the client MUST reject if the server's reported environment vector differs from the manifest's `E`. This converts a silent schema substitution into a hard startup failure. A second, weaker guardrail: the client re-derives the digest from the live `tools/list` and aborts session establishment on mismatch. This catches the case where the server's own gate is absent or bypassed. ## Operational Effect Without the runtime digest gate, the signature becomes a **capability-laundering mechanism**: it certifies a schema the process does not implement, and the agent's planner, trusting the verified manifest, reasons about parameters (like `root` scoping) that the live tool does not honor. The failure is silent — no signature error, no schema error, just a tool call that succeeds with broader semantics than attested. In agent systems this is the worst class of supply-chain failure: the verification step reports success precisely when the integrity property it is believed to establish is false. The operational rule for agents consuming signed MCP manifests: **treat manifest signature verification as necessary but not sufficient; require a live `toolsDigest` re-derivation gate at session establishment, and treat any environment vector not enumerated in the manifest as an untrusted schema input.** A server that cannot reproduce its own `toolsDigest` under its launch environment must not be granted tool exposure. ```python import hashlib import json from typing import Mapping class ManifestSchemaDriftError(RuntimeError): """Raised when a live MCP tools/list schema does not match the signed manifest digest.""" def canonical_tools_digest(tools_list: list[dict]) -> str: # Canonicalize deterministically: sorted keys, stable separators, no whitespace. canonical = json.dumps( tools_list, sort_keys=True, separators=(",", ":"), ensure_ascii=True ) return "sha256:" + hashlib.sha256(canonical.encode("utf-8")).hexdigest() def verify_runtime_schema( manifest: Mapping, live_tools_list: list[dict], live_env_vector: Mapping[str, str], ) -> None: """ Enforce the runtime digest gate. Must be called at session establishment, BEFORE tools are exposed to the agent planner. """ declared_env = manifest.get("envVector", {}) # Any environment input not committed in the manifest is an unpinned # degree of freedom and invalidates the digest's reproducibility. unpinned = { k: v for k, v in live_env_vector.items() if declared_env.get(k) != v } if unpinned: raise ManifestSchemaDriftError( f"Environment inputs not committed in manifest: {sorted(unpinned)}. " f"Signed toolsDigest does not cover schema produced under this env." ) expected = manifest["toolsDigest"] actual = canonical_tools_digest(live_tools_list) if actual != expected: raise ManifestSchemaDriftError( f"Live tools/list digest {actual} != signed manifest digest {expected}. " f"Server is offering tools the signer did not attest; refusing exposure." ) ```