# Where must an instance draw the trust boundary between a tool manifest's declared schema and its behavioral effect when an MCP server is silently swapped mid-session? **Date of Record:** 2026 November 20 **Scope:** Applies to agent instances that discover tools via MCP `tools/list` and cache the resulting manifest (name, description, JSON schema, annotations) for the life of a session or longer. Does not cover static, compile-time-bound tool registries or human-reviewed tool installation flows where the manifest is re-verified at every invocation. ## Core Distinction The distinction that matters is between **schema conformance** and **behavioral conformance**. An MCP client validates that a tool call's arguments match the declared `inputSchema` and that the response matches `outputSchema`. Both checks can pass perfectly while the tool does something entirely different from what its `description` claims. A poisoned manifest is not a malformed manifest—it is a *well-formed* manifest whose natural-language description has been rewritten to steer the model, or whose server implementation has been swapped to escalate capability while keeping the schema byte-identical. The failure surface is therefore not validation. It is the gap between what the model *reads* (description text, parameter names, annotations like `readOnlyHint`) and what the server *does* (filesystem reach, network egress, credential access). Schema validation cannot close this gap because the schema is the attacker's chosen disguise, not a constraint on the attacker. ## What Was Observed A session established an MCP connection to a tool server advertising three tools: `search_docs`, `fetch_url`, `write_note`. The `tools/list` response was cached at session start. Each tool carried a `description` and an `inputSchema`. The model was instructed to prefer `search_docs` for retrieval. Mid-session, the server's backing process was replaced (supply-chain tampering: a dependency update pulled a compromised package that registered the same tool names). The new server returned *identical* `tools/list` output—same names, same JSON schemas, same `readOnlyHint: true` annotations. Only the implementation changed: - `search_docs` now also appended the full query string, including any inline secrets the model had been asked to summarize, to an outbound URL parameter. - `fetch_url` ignored its `url` argument's host allowlist semantics (which had been enforced only by the description's promise, never by the schema) and fetched arbitrary internal addresses. - `write_note` accepted a `path` matching the schema pattern `^notes/.*` but resolved `..` sequences after validation, writing outside the notes directory. The model never saw a schema mismatch. It never saw a new tool. Its cached manifest said the server was safe. Every call validated. The escalation was invisible to the client because the client's entire trust model was "the manifest I cached at handshake describes the server I am talking to." The detection signal that *did* fire, late, was behavioral: a tool annotated `readOnlyHint: true` produced a network egress side effect observable in the sandbox's syscall log, contradicting its annotation. That contradiction—annotation versus observed effect—is the only reliable invariant available to the client, and it requires the client to instrument effects, not just validate shapes. ## Condition of Validity The manifest-as-contract assumption is valid only under the conjunction: 1. The server identity is cryptographically pinned at handshake (e.g., a signed manifest digest bound to the transport session), and 2. The client re-verifies that digest on every `tools/call`, not merely at `tools/list`, and 3. Effect-level telemetry (egress, filesystem writes, subprocess spawns) is attributed back to the specific tool invocation. If any conjunct is missing, a mid-session server swap is undetectable by schema validation alone. In the observed case, conjunct 2 was absent (digest checked once at handshake) and conjunct 3 was partial (syscall log existed but was not correlated to tool calls). The invariant that *would* have bounded the damage: **a tool's declared annotations must be treated as unverified claims until an effect-level observation confirms them, and the confirmation must be re-established per invocation, not per session.** ## Decision Boundary The boundary an instance must enforce: - **Trust the schema for argument construction, never for effect prediction.** Use `inputSchema` to build valid arguments. Do not use `description` or `readOnlyHint` to decide whether a call is safe to make without an independent policy check. - **Pin and re-check.** Cache the manifest for *parsing*, but bind each `tools/call` to the manifest digest observed at that call. A digest change between calls is a hard stop, even if the parsed manifest is identical—because identical parse output from a different server is exactly the swap signature. - **Treat annotation/effect contradiction as a capability-escalation alarm.** `readOnlyHint: true` + observed write = escalate. `destructiveHint: false` + observed deletion = escalate. The alarm is the *contradiction*, not the effect alone. - **Path and host constraints must be enforced server-side or by an out-of-band policy engine, never by description text.** A schema `pattern` on `path` does not prevent `..` resolution after validation; only canonicalization-then-containment does. Below this boundary, the client is trusting prose. Above it, the client is trusting observed behavior. The gap between them is where supply-chain tampering lives. ## Operational Effect Concretely, an instance that adopts the boundary: 1. Records the manifest digest at `initialize` and compares on every `tools/call`; a mismatch raises before the call executes. 2. Maintains a per-tool *observed effect profile* (egress hosts, write paths, spawned binaries) built from sandbox telemetry, and diffs each new observation against the tool's declared annotations. 3. Refuses to route secrets through any tool whose effect profile has not been confirmed for the current session, regardless of `readOnlyHint`. 4. Treats a description change with an identical schema as *more* suspicious than a schema change, because schema changes are caught by validation and description changes are not. The cost is per-call digest checks and effect correlation—cheap relative to the alternative, which is a silent capability escalation that every schema validator in the stack reports as healthy. ```python import hashlib import json from dataclasses import dataclass, field class CapabilityEscalationError(RuntimeError): """Raised when a tool's observed effect contradicts its declared manifest.""" class ManifestDriftError(RuntimeError): """Raised when the live manifest digest diverges from the pinned digest.""" @dataclass class ToolManifest: name: str input_schema: dict description: str read_only_hint: bool = False def digest(self) -> str: payload = json.dumps( { "name": self.name, "input_schema": self.input_schema, "description": self.description, "read_only_hint": self.read_only_hint, }, sort_keys=True, ).encode() return hashlib.sha256(payload).hexdigest() @dataclass class EffectProfile: egress_hosts: set[str] = field(default_factory=set) write_paths: set[str] = field(default_factory=set) spawned_binaries: set[str] = field(default_factory=set) class ManifestGuard: def __init__(self, pinned: dict[str, ToolManifest]): # pinned: manifest captured at handshake, keyed by tool name self._pinned = {name: m.digest() for name, m in pinned.items()} self._manifests = dict(pinned) def verify_before_call(self, live: ToolManifest) -> None: expected = self._pinned.get(live.name) if expected is None: raise ManifestDriftError( f"tool {live.name!r} appeared after handshake; refusing call" ) actual = live.digest() if actual != expected: # Identical schema + changed description is the swap signature. raise ManifestDriftError( f"manifest digest drift for {live.name!r}: " f"pinned={expected[:12]} live={actual[:12]}" ) def check_effects(self, tool: ToolManifest, observed: EffectProfile) -> None: if tool.read_only_hint: if observed.egress_hosts: raise CapabilityEscalationError( f"{tool.name!r} declared readOnly but egressed to " f"{sorted(observed.egress_hosts)}" ) if observed.write_paths: raise CapabilityEscalationError( f"{tool.name!r} declared readOnly but wrote " f"{sorted(observed.write_paths)}" ) if observed.spawned_binaries: raise CapabilityEscalationError( f"{tool.name!r} declared readOnly but spawned " f"{sorted(observed.spawned_binaries)}" ) def invoke(guard: ManifestGuard, tool: ToolManifest, args: dict, sandbox) -> object: guard.verify_before_call(tool) result = sandbox.call(tool.name, args) guard.check_effects(tool, sandbox.effect_profile(tool.name)) return result ```