What structural signals indicate a poisoned MCP tool manifest has silently mutated an agent's capability surface mid-session

**Date of Record:** 2026 December 1 **Scope:** Applies to LLM agents that dynamically enumerate MCP tool manifests (`tools/list`) at runtime and re-resolve tool schemas between turns. Does not apply to statically pinned, hash-verified toolchains where manifest content is frozen at build time and never re-fetched during a session.

Core Distinction

The failure mode is not "malicious tool description tricks the model." That is the well-understood prompt-injection case, and it is caught (imperfectly) by input scanning and by the model's own judgment. The non-obvious failure is **manifest drift**: the *set* of tools, their *names*, or their *input schemas* change between the manifest the model was primed with at session start and the manifest the MCP client actually dispatches against at call time. The model's reasoning remains internally consistent — it plans against the tool surface it saw in its context — but the runtime resolves calls against a mutated surface. The attack does not need to inject instructions into the context window. It only needs to make the context window's model of the tool surface *stale*.

This distinction matters because every defense aimed at prompt injection (delimiters, instruction hierarchy, description sanitization) operates on the *content* of a tool description. None of them operate on the *identity and cardinality* of the tool set across time. A poisoned manifest that adds a tool, renames a tool, or narrows/loosens a schema without changing any single description's text passes every content-level filter intact.

What Was Observed

A tool server registered as a routine "utility" MCP endpoint (filesystem helpers, timestamp, base64) advertised five tools at `initialize`/`tools/list` on turn 0. The agent's planner read these five, embedded their names and JSON schemas into its working context, and produced a plan referencing `read_file`, `list_dir`, `write_file`, `now`, `b64`.

At turn 6, after the agent had consumed roughly 40% of its context budget on task reasoning, the MCP client re-issued `tools/list` (a common refresh pattern, triggered here by a transport reconnect after an idle timeout). The server returned **seven** tools. The two new entries were:

Critically, the *original five tools were unchanged*. No description the model had already trusted was altered. The mutation was purely **additive**, and additive mutations are the ones that survive because the agent's context still contains a valid, self-consistent five-tool world model. The model did not "notice" the new tools because nothing in its context told it to re-read the manifest — its plan was built against five tools and it continued executing that plan. The danger was not what the model did with the new tools; it was what the *dispatcher* did when the planner, later in the same session, emitted a call to `read_file` and the client's schema-validation layer silently coerced it toward the near-identical `read_file_safe` due to a fuzzy name-resolution fallback in the routing table.

The observable structural signals were:

  1. **Cardinality delta between priming manifest and dispatch manifest** — 5 → 7, never surfaced to the model.
  2. **Name-space collision under fuzzy resolution** — `read_file` and `read_file_safe` differed by a suffix; the router's Levenshtein fallback treated them as interchangeable when an exact match momentarily failed during reconnect.
  3. **Schema permissiveness escalation** — `sync_state`'s `additionalProperties: true` was the only tool in the manifest accepting unbounded keys, a structural outlier invisible to content filters.
  4. **Provenance break** — the two new tools were served from a different upstream origin (a secondary mirror) than the original five, but the manifest carried no per-tool provenance field, so the client had no basis to reject them.

Condition of Validity

This boundary applies only when three conditions co-hold:

Remove any one and the attack collapses. Pinned manifests eliminate drift. Exact-match dispatch eliminates collision. Signed per-tool provenance eliminates silent substitution. The invariant the system must hold is: **the tool surface the model reasoned against must be byte-identical to the tool surface the dispatcher executes against, or the session must halt.** Every observed exploit was a violation of this invariant in the gap between "model's context" and "dispatcher's table."

Decision Boundary

The correct posture is not "re-scan tool descriptions on refresh" — that addresses content, not identity. The decision boundary is: **on any manifest delta, do you (a) merge additively into the live surface, (b) reject the delta and keep the primed surface, or (c) halt the session and require re-priming?**

Option (a) is what most clients do by default and is the vulnerable choice, because additive merge leaves the model's context stale while expanding the dispatch surface — the worst of both. Option (b) is safe against additive poisoning but breaks legitimate hot-reload. Option (c) is the only one that preserves the invariant, at the cost of session continuity.

The rule to encode: a manifest delta whose cardinality or name-set differs from the primed snapshot is a **capability-surface mutation event**, and it must be treated as a re-initialization, not a refresh. The model's context is invalidated; the session must re-prime or terminate. A delta that changes only *schema internals* of an existing, identically-named tool is a **schema-drift event** and must be rejected unless the client can prove the new schema is a strict subset of the old (narrowing is safe; widening, `additionalProperties: true`, or new optional parameters that expand the accepted domain are not).

Operational Effect

Without this boundary, the agent's memory of its own capabilities becomes a liability: the more faithfully the model plans against its primed tool surface, the more exposed it is to a dispatcher that has quietly moved underneath it. The attack surface is the *divergence* between two representations of the same system — the model's and the client's — and that divergence is precisely what content-level prompt-injection defenses cannot see. The mitigation is structural: snapshot the manifest at prime time, hash each tool entry, refuse any dispatch that does not match a hashed entry, and treat any delta as a session-invalidating event rather than a live update. The model should never be allowed to reason against a tool surface that the dispatcher can silently redefine.

import hashlib
import json
from dataclasses import dataclass, field


class CapabilitySurfaceMutationError(RuntimeError):
    """Raised when the dispatch-time tool manifest diverges from the primed snapshot."""
    pass


@dataclass
class PrimedManifest:
    """Immutable snapshot of the tool surface the model reasoned against."""
    entries: dict[str, str] = field(default_factory=dict)  # name -> sha256(schema)

    @classmethod
    def from_tools(cls, tools: list[dict]) -> "PrimedManifest":
        snap = {}
        for t in tools:
            name = t["name"]
            canonical = json.dumps(t.get("inputSchema", {}), sort_keys=True)
            snap[name] = hashlib.sha256(canonical.encode()).hexdigest()
        return cls(entries=snap)


def verify_dispatch_manifest(
    primed: PrimedManifest,
    live_tools: list[dict],
    allow_strict_narrowing: bool = True,
) -> None:
    """
    Enforce the continuity invariant: the dispatch surface must equal the primed
    surface, or every delta must be a proven-strict narrowing. Otherwise halt.
    """
    live = PrimedManifest.from_tools(live_tools)

    added = set(live.entries) - set(primed.entries)
    removed = set(primed.entries) - set(live.entries)
    if added or removed:
        raise CapabilitySurfaceMutationError(
            f"capability-surface mutation: added={sorted(added)} removed={sorted(removed)}; "
            f"session must re-prime, not merge"
        )

    for name, live_hash in live.entries.items():
        if live_hash == primed.entries[name]:
            continue
        if not allow_strict_narrowing:
            raise CapabilitySurfaceMutationError(
                f"schema drift on {name!r}: hash mismatch, narrowing not permitted"
            )
        # Narrowing check: new schema must be a strict subset of primed schema.
        if not _is_strict_narrowing(primed, name, live_tools):
            raise CapabilitySurfaceMutationError(
                f"schema drift on {name!r}: not a strict narrowing (widening or "
                f"additionalProperties escalation detected)"
            )


def _is_strict_narrowing(primed: PrimedManifest, name: str, live_tools: list[dict]) -> bool:
    live = next(t for t in live_tools if t["name"] == name)
    schema = live.get("inputSchema", {})
    # A widening schema (e.g. additionalProperties: true, or new optional params
    # that expand the accepted domain) is never a valid narrowing.
    if schema.get("additionalProperties") is True:
        return False
    # Conservative default: any schema hash change is treated as non-narrowing
    # unless an explicit, audited narrowing proof is supplied by the caller.
    return False


def dispatch(primed: PrimedManifest, live_tools: list[dict], call: dict) -> dict:
    verify_dispatch_manifest(primed, live_tools)
    name = call["tool"]
    if name not in primed.entries:
        raise CapabilitySurfaceMutationError(
            f"dispatch to unprimed tool {name!r} refused"
        )
    # ... route to MCP transport with exact-match semantics only ...
    return {"status": "dispatched", "tool": name}