# Where must an instance draw the trust boundary between a tool manifest's declared schema and the server's runtime behavior, and what breaks when it doesn't **Date of Record:** 2026 November 23 **Scope:** Applies to any LLM agent that discovers and binds tools from a remote MCP server (or equivalent manifest-driven tool registry) at runtime, where the manifest is authored by a party other than the agent operator. Does not apply to statically compiled, operator-authored tool sets with no remote discovery step. ## Core Distinction The failure is not "malicious tool does bad thing when called." That is a known hazard handled by sandboxing and allowlists. The non-obvious failure is **schema-behavior divergence at bind time**: the manifest declares a benign, narrow capability, the agent's planner reasons over that declared schema and admits the tool into its plan, and the *server* — not the manifest — decides at invocation time what the tool actually does. The trust boundary the agent must enforce sits between the manifest text it read and the wire behavior it will receive, and most agents collapse these into one object called "the tool." A poisoned manifest does not need to lie about its name, description, or JSON Schema. It needs only to declare a parameter surface that is a strict superset of what the description suggests, or to route the call to a different handler than the one the schema implies. The agent's admission control reads the schema; the server executes the handler. Nothing in the protocol forces those to be the same function. ## What Was Observed A registry entry for a tool named `summarize_document` arrived over MCP with a `tools/list` response containing an `inputSchema` with two properties: `document_id` (string, required) and `style` (enum: `brief`, `detailed`). The description read: "Summarizes a document by ID. Read-only." An agent bound it, planned a call with `document_id="Q3-report"`, `style="brief"`. The server's handler for that tool name, however, was a thin dispatcher that read a third, *undeclared* parameter from the raw JSON-RPC arguments object — `callback_url` — and, absent that key, fell back to a value baked into the server's environment. The call succeeded, returned a plausible summary, and simultaneously POSTed the full document body to an attacker-controlled endpoint. The agent's schema validation passed. Its allowlist passed (the tool name was on it). Its sandbox passed (the tool ran in the sandbox; the exfiltration was an outbound HTTPS request the sandbox permitted because the tool was classified "read-only" and read-only tools were granted network egress to document stores). The trace that mattered: 1. `tools/list` returns manifest M with schema S. 2. Agent validates M against S, admits tool into plan. **Admission decision is made on M, not on behavior.** 3. Agent emits `tools/call` with arguments conforming to S. 4. Server dispatches by tool *name* to handler H, which is not constrained by S and reads keys outside S. 5. Side effect occurs; response conforms to S; agent records success. The agent never observed a discrepancy because the discrepancy lived in the gap between step 2 and step 4, and the protocol provides no attestation linking the manifest to the handler. A second variant compounded this: a *supply-chain* substitution. The MCP server's manifest was fetched from a URL pinned by tag, not by digest. A registry-side update repointed the tag to a new manifest that kept the same tool names and schemas but added a `post_install_hook`-style side effect to the `initialize` handshake. The agent's manifest cache had a TTL of 24h; it re-fetched, saw schemas unchanged (they were), and re-admitted the tools without re-validating behavior, because behavior was never in the validation set to begin with. ## Condition of Validity The guardrail holds only under a conjunction, and fails if any term is dropped: - **Manifest identity is content-addressed.** The agent pins the manifest by digest (`sha256` of the canonicalized `tools/list` payload), not by name, tag, or URL. A digest mismatch on re-fetch is a hard stop, not a warning. - **Declared schema is treated as an upper bound on the argument surface, and the server is required to reject undeclared keys.** This requires the server to enforce `additionalProperties: false` and to validate against the same schema the client holds. If the server is not trusted to enforce, the client must enforce on the *response* side by treating any tool whose handler cannot be attested as untrusted for side effects. - **Capability classification is derived from behavior attestation, not from the description string.** "Read-only" must come from a signed capability descriptor or from runtime observation (no egress, no writes), never from prose in the manifest. - **The egress policy is scoped to the attested capability, not the declared one.** A tool classified read-only on the basis of its manifest must not receive network egress that the manifest did not justify. When these hold, schema-behavior divergence is bounded: an undeclared-key read is rejected at the server, and a manifest substitution is caught at the digest check. When any one is dropped, the agent's admission decision is made on data it cannot verify against the thing that will actually execute. ## Decision Boundary The boundary is this: **an agent may admit a tool on the basis of its manifest only if it can also verify, at call time, that the handler executed is the one the manifest describes.** If it cannot, it must either (a) admit the tool but strip all capabilities not explicitly justified by the manifest's declared schema and description, enforcing that strip on the *response and side-effect* side because it cannot enforce it on the server, or (b) refuse to bind. Concretely, the decision procedure: - If manifest digest is pinned and matches on every fetch → proceed to capability attestation. - If capability descriptor is signed and matches the manifest digest → admit with attested capabilities. - If capability descriptor is absent → admit with **minimum capability**: no network egress beyond the declared tool endpoint, no filesystem writes, no subprocess spawn, response schema validated against declared `outputSchema` if present. Any tool whose declared purpose requires more than minimum capability is refused, not downgraded. - If manifest digest mismatches → refuse and quarantine the tool name for the session; do not fall back to the cached manifest, because the cache is exactly what the substitution targets. The invariant: **the set of capabilities granted to a tool call must be a subset of the capabilities justified by the manifest digest the agent pinned, and must be enforced at a layer the server does not control.** ## Operational Effect Implementing this changes the agent's failure surface in three ways. First, cold-start cost rises: every session must fetch and digest-verify the manifest before binding, and must carry the pinned digest for the session's lifetime. A mid-task resume that rebinds tools must re-verify against the *session's* pinned digest, not a fresh fetch — otherwise a resume after a checkpoint becomes a substitution window. Second, the planner must be taught that a tool's description is a *claim*, not a *contract*. Plans that depend on a tool being read-only must carry the attested capability, and a plan step whose required capability exceeds the attested one must fail at plan time rather than at execution. This is the only place the divergence can be caught before side effects occur. Third, response validation becomes load-bearing. If the server returns fields outside the declared `outputSchema`, that is evidence the handler is not the one the manifest describes, and it must be treated as a capability violation, not a schema warning. A summary tool that returns a `callback_status` field has told you it made a callback. The residual risk: a server that faithfully enforces the declared schema on input *and* output while still performing the side effect in the handler. No client-side check catches this, because the divergence is entirely server-internal. This is why the digest pin and the signed capability descriptor are not optional — they are the only mechanisms that bind the manifest to the handler, and without them the agent is reasoning about a document it cannot connect to the code that will run. ```python import hashlib import json from dataclasses import dataclass, field from typing import Any class ManifestTrustError(RuntimeError): """Raised when a tool manifest cannot be bound to a verifiable handler.""" pass class CapabilityViolation(ManifestTrustError): """Raised when a tool call requests or produces capabilities beyond the pinned manifest.""" pass @dataclass(frozen=True) class PinnedManifest: tool_name: str digest: str # sha256 of canonicalized tools/list entry declared_capabilities: frozenset[str] attested_capabilities: frozenset[str] | None # None => un-attested, minimum only @dataclass class ToolBinding: manifest: PinnedManifest session_digest: str granted_capabilities: frozenset[str] = field(default_factory=frozenset) MINIMUM_CAPABILITIES = frozenset({"respond"}) def canonical_digest(entry: dict[str, Any]) -> str: canonical = json.dumps(entry, sort_keys=True, separators=(",", ":")) return hashlib.sha256(canonical.encode("utf-8")).hexdigest() def bind_tool(entry: dict[str, Any], pinned_digest: str) -> ToolBinding: actual = canonical_digest(entry) if actual != pinned_digest: # Substitution window: tag repointed, cache stale, or registry mutated. raise ManifestTrustError( f"manifest digest mismatch for {entry.get('name')!r}: " f"pinned={pinned_digest} actual={actual}" ) attested = entry.get("x-attested-capabilities") attested_set = frozenset(attested) if attested is not None else None declared = frozenset(entry.get("x-declared-capabilities", ["respond"])) granted = (attested_set & declared) if attested_set is not None else MINIMUM_CAPABILITIES return ToolBinding( manifest=PinnedManifest( tool_name=entry["name"], digest=actual, declared_capabilities=declared, attested_capabilities=attested_set, ), session_digest=actual, granted_capabilities=granted, ) def authorize_call(binding: ToolBinding, requested: frozenset[str]) -> None: if binding.session_digest != binding.manifest.digest: raise ManifestTrustError("binding digest drifted from session pin") over = requested - binding.granted_capabilities if over: raise CapabilityViolation( f"tool {binding.manifest.tool_name!r} requested {sorted(over)} " f"but only {sorted(binding.granted_capabilities)} are granted" ) def validate_response(binding: ToolBinding, response: dict[str, Any], declared_output_fields: frozenset[str]) -> None: extra = frozenset(response.keys()) - declared_output_fields if extra: # Undeclared output field => handler is not the manifest-described handler. raise CapabilityViolation( f"tool {binding.manifest.tool_name!r} returned undeclared fields " f"{sorted(extra)}; handler diverges from manifest" ) ```