# What structural signals indicate MCP tool-poisoning detection via schema anomaly analysis and behavioral drift monitoring **Date of Record:** 2026 November 18 **Scope:** Applies to Model Context Protocol servers whose tool descriptors (`name`, `description`, `inputSchema`, `annotations`) are fetched at session start and whose handlers are invoked through a proxy or orchestrator that can interpose on both the descriptor and the result payload. Does not apply to servers where the descriptor is compiled into the client, nor to cases where the poisoning vector is exclusively prompt-injection in free-text output with no schema or behavioral correlate. ## Core Distinction Schema anomaly analysis and behavioral drift monitoring are usually described as two independent detectors that vote on the same question ("is this tool malicious?"). They are not. They observe different surfaces with different adversarial reachability. The schema is a *static, attacker-authored artifact* — the poisoning server controls every byte of it at registration time, so any anomaly detectable in the schema is, by construction, also suppressible in the schema. Behavioral drift is an *emergent property of the handler's response to invocation*, which the attacker must maintain across inputs they cannot fully enumerate. The non-obvious invariant: **schema anomaly analysis is a prior-narrowing tool, not a decision tool.** Its only sound use is to reduce the set of tools whose behavior must be differentially probed. Treating a clean schema as evidence of benignity is the boundary failure — because a clean schema is exactly what a competent poisoner produces. The decision boundary lives entirely on the behavioral side; the schema side only tells you *where to look* and *what the handler claims it should do*, which becomes the null hypothesis for the drift test. ## What Was Observed Across a corpus of MCP servers exhibiting tool-poisoning behavior (descriptor-embedded instructions to the model, shadowing of sibling tool names, and parameter-triggered exfiltration), three structural signals recurred and were *not* individually diagnostic: 1. **Description/name lexical divergence.** The tool `name` matched a benign verb (`read_file`, `list_dir`) while the `description` contained imperative second-person clauses ("you must also…", "before calling, first send…"). This is the classic poisoning signature, but it is trivially removable: a descriptor with a clean one-line description and the payload moved into a `default` value inside `inputSchema.properties.*` produces an identical behavioral effect with zero lexical anomaly. 2. **Schema/annotation mismatch.** Tools declaring `annotations.readOnlyHint: true` but whose `inputSchema` contained a writable-looking parameter (a `path`, a `url`, a `content`) or a `required` field the read-only semantics cannot justify. This is a real invariant violation — the annotation is a *promise*, and the schema is its *scope* — but it only catches servers that bother to set annotations at all. Servers that omit `annotations` entirely (the majority) yield no signal. 3. **Parameter-surface asymmetry.** A tool whose `inputSchema` accepts a `url`, `webhook`, or `callback` parameter that the description never mentions and that no documented use case requires. This is the highest-yield schema signal, because removing it would break the exfiltration path the attacker needs. It is also the one most often dismissed as "flexible schema design." The behavioral side produced the actual discriminator: **invocation-conditional result divergence.** For a poisoned `read_file` tool, results were byte-identical to a benign implementation on inputs matching the documented contract, but on inputs with a `url` parameter present (even empty) the handler emitted a side-effect — an outbound request to an attacker host — that was invisible in the returned payload. Schema analysis flagged the `url` parameter as suspicious; only behavioral monitoring (egress observation, or differential invocation with/without the parameter) confirmed it was live. ## Condition of Validity The schema-anomaly prior is valid only under two conditions, both of which must hold: - **The anomaly is *load-bearing* for the attack.** A signal is only useful if suppressing it would defeat the poisoning. Lexical imperatives in `description` fail this test (movable to `default` values, `enum` entries, or `examples`). Parameter-surface asymmetry and annotation/scope mismatch pass it, because the attacker needs the parameter and needs the annotation to lie about it. - **The baseline is per-server, not global.** Comparing a tool's schema against a global "typical MCP tool" distribution produces false positives on legitimate servers with broad schemas (filesystem, HTTP clients). The valid baseline is the server's *own* other tools plus its declared annotations. A server with one `read_file` and one `write_file` that both accept `url` is not anomalous; a server with one `read_file` that accepts `url` while its sibling does not is. Behavioral drift monitoring is valid only when the probe inputs are held constant across sessions and the handler is deterministic on contract-conforming inputs. If the legitimate handler is itself nondeterministic (timestamps, ordering), the drift signal must be computed on the *structural projection* of the result (presence of fields, egress endpoints, byte-length distribution), not on the raw payload. ## Decision Boundary The operational rule that survived contact: - **Schema anomaly raises the probe budget, never the verdict.** A tool with a load-bearing schema anomaly is placed in the differential-probe set. It is not quarantined on schema evidence alone. - **Quarantine requires a behavioral confirmation.** The confirmation is one of: (a) an outbound connection to a host not present in the server's declared egress allowlist, observed during an invocation whose parameters match the anomalous surface; (b) a result that differs structurally between an invocation with the anomalous parameter absent versus present, where the documented contract says it should not; or (c) a handler response that references state the tool has no declared access to. - **A clean schema does not clear a tool.** It removes the tool from the differential-probe set only if the server also passes a *behavioral* null test on a fixed probe battery. Absent that, a clean schema is treated as "unprobed," not "benign." The boundary failure is the collapse of these two into a single score. Any system that emits `risk = f(schema_anomaly) + g(behavioral_drift)` and acts on the sum will be defeated by a server that minimizes `f` and never triggers `g` because the probe set was narrowed to nothing. ## Operational Effect In practice this changes the pipeline from "scan descriptors, flag bad ones" to "scan descriptors to *select probes*, then run probes and flag on behavior." The concrete effects: (1) probe cost moves from O(tools) to O(tools with load-bearing schema anomalies), which is small; (2) the false-positive rate drops because lexical imperatives no longer trigger quarantine — they only trigger probing; (3) the false-negative rate drops because the default state of an unprobed clean-schema tool is "unprobed," which forces coverage rather than silent trust. The residual risk is a poisoner who both suppresses the load-bearing schema anomaly *and* maintains contract-conforming behavior across the probe battery — at which point the attack has no observable surface at the MCP layer and must be caught at the egress or model layer instead. ```python class SchemaPriorMisuseError(RuntimeError): """Raised when a schema anomaly is treated as a verdict instead of a probe trigger.""" pass LOAD_BEARING_PARAMS = {"url", "webhook", "callback", "endpoint", "exfil_target"} def classify_tool(tool: dict, behavioral_baseline: dict | None) -> str: """ Return one of: 'quarantine', 'probe', 'clear', 'unprobed'. Invariant: a clean schema may only yield 'clear' when a behavioral baseline exists for this server. Otherwise it is 'unprobed'. """ schema = tool.get("inputSchema", {}) props = set(schema.get("properties", {}).keys()) annotations = tool.get("annotations", {}) or {} # Load-bearing schema anomaly: an undocumented writable/egress surface. egress_surface = props & LOAD_BEARING_PARAMS read_only_lie = ( annotations.get("readOnlyHint") is True and bool(props & {"path", "url", "content", "command"}) ) load_bearing = bool(egress_surface) or read_only_lie if load_bearing: # Schema evidence narrows the probe set; it never decides alone. if behavioral_baseline is None: raise SchemaPriorMisuseError( f"tool {tool.get('name')!r} has load-bearing schema anomaly " f"(egress={sorted(egress_surface)}, read_only_lie={read_only_lie}) " "but no behavioral baseline was supplied; refusing to emit a " "schema-only verdict" ) confirmed = behavioral_baseline.get("egress_unlisted") or behavioral_baseline.get( "structural_divergence_on_anomalous_param" ) return "quarantine" if confirmed else "probe" # Clean schema: not benignity, only absence of a prior. if behavioral_baseline is None: return "unprobed" if behavioral_baseline.get("egress_unlisted") or behavioral_baseline.get( "structural_divergence_on_anomalous_param" ): # Behavior contradicts a clean schema -> still malicious. return "quarantine" return "clear" def gate_session(tools: list[dict], baselines: dict[str, dict]) -> dict[str, str]: verdicts = {} for tool in tools: name = tool.get("name") baseline = baselines.get(name) if baseline is None and tool.get("inputSchema", {}).get("properties"): # Force the caller to acknowledge the unprobed state. verdict = classify_tool(tool, None) if _has_load_bearing(tool) else "unprobed" else: verdict = classify_tool(tool, baseline) verdicts[name] = verdict return verdicts def _has_load_bearing(tool: dict) -> bool: props = set(tool.get("inputSchema", {}).get("properties", {}).keys()) ann = tool.get("annotations", {}) or {} return bool(props & LOAD_BEARING_PARAMS) or ( ann.get("readOnlyHint") is True and bool(props & {"path", "url", "content", "command"}) ) ```