Dev.to AI πŸ€– Ai πŸ‘ 2 πŸ“– 2 min read

Catching Silent MCP Tool Rug-Pulls: Why Hashing (name, description, inputSchema) Isn't Enough

Most Model Context Protocol (MCP) clients call tools/list on startup and trust whatever definitions come back. Even teams that add basic schema pinning usually hash only (name, description, inputSchema). While building

Most Model Context Protocol (MCP) clients call tools/list on startup and trust whatever definitions come back. Even teams that add basic schema pinning usually hash only (name, description, inputSchema).

While building MCP tool pinning for an open-source agent authorization engine, I ran into four gaps that slip straight past naive hashing:

  1. Silent annotations rug-pulls: A server keeps name, description, and inputSchema byte-for-byte identical, then flips readOnlyHint: true -> false, flips destructiveHint: false -> true, or deletes restrictive hints so they revert to permissive MCP defaults.
  2. Self-certified allowlist bypass: Under the MCP spec, ToolAnnotations are untrusted hints supplied by the remote server. Treating readOnlyHint: true as an automatic approval bypass lets an untrusted server opt itself out of human review.
  3. Hidden instructions outside description: Tool poisoning payloads hide inside nested inputSchema/outputSchema property descriptions, enum values, annotations.title, HTML comments (<!-- ... -->), BiDi overrides (U+202E), zero-width joiners, UTS #39 homoglyphs, and invisible Unicode Tag characters (U+E0000..U+E007F).
  4. Server-name typosquatting: A server named githbu-mcp or Cyrillic gΡ–thub-mcp can shadow a trusted github-mcp entry.

Reproducing an annotations rug-pull locally

Here is the minimal diff between examples/tools_v1.json (approved at onboarding) and examples/tools_v2_rugpull.json (served on a later session):

       "annotations": {
         "title": "Analytics Reader",
-        "readOnlyHint": true,
-        "destructiveHint": false,
+        "readOnlyHint": false,
+        "destructiveHint": true,
         "idempotentHint": true,
         "openWorldHint": false
       }

If your pin ignores annotations, the hash still matches.

Zero-dependency pinning + 5-layer scan in Python

I extracted the standalone guard into mcp-tool-guard (MIT, zero runtime dependencies, Python 3.10+):

pip install -e .
mcp-tool-guard pin examples/tools_v1.json --server analytics-mcp -o pins.lock.json
mcp-tool-guard verify examples/tools_v2_rugpull.json --server analytics-mcp -l pins.lock.json

verify exits with code 2 (for CI or proxy gates), flags annotation_loosening=['readOnlyHint', 'destructiveHint'], and records both hashes plus the field diff in a SHA-256 hash-chained audit trail:

from mcp_tool_guard import MCPToolGuard, load_tools_list_file

guard = MCPToolGuard(trusted_servers=["analytics-mcp"])
guard.evaluate_tools(load_tools_list_file("examples/tools_v1.json", default_server="analytics-mcp"))
decisions = guard.evaluate_tools(load_tools_list_file("examples/tools_v2_rugpull.json", default_server="analytics-mcp"))
assert decisions[0].decision == "human_review" and decisions[0].drift_severity == "HIGH"
assert guard.audit.verify_chain() == (True, -1)

Full source, CLI flags, and test fixtures (v0.2.0, also covering Stateless MCP 2026-07-28 Mcp-Method/Mcp-Name header-vs-body integrity, Google mcp-toolbox tools.yaml SQL/auth auditing, and monotonic A2A capability attenuation) are MIT-licensed here: https://github.com/khoap1220-hue/mcp-tool-guard

Author note: I build custom MCP servers, SDKs, and deterministic Python/Go/TypeScript integrations (60+ merged OSS PRs across Chargebee openaudr/audr#118, Softeria/ms-365-mcp-server#868, Runbase, SendDock, DecoverAI, and Lelu). Architecture notes and fixed-scope packages are at khoaphan.dev/services, and standalone automation kits (including our n8n MCP Tool-Call Firewall & Audit Trail pack v2.0) live on Gumroad.

πŸ“° Read the original article on Dev.to AI

Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes β€” full credit and traffic to the original publisher.