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:
-
Silent
annotationsrug-pulls: A server keepsname,description, andinputSchemabyte-for-byte identical, then flipsreadOnlyHint: true -> false, flipsdestructiveHint: false -> true, or deletes restrictive hints so they revert to permissive MCP defaults. -
Self-certified allowlist bypass: Under the MCP spec,
ToolAnnotationsare untrusted hints supplied by the remote server. TreatingreadOnlyHint: trueas an automatic approval bypass lets an untrusted server opt itself out of human review. -
Hidden instructions outside
description: Tool poisoning payloads hide inside nestedinputSchema/outputSchemaproperty descriptions,enumvalues,annotations.title, HTML comments (<!-- ... -->), BiDi overrides (U+202E), zero-width joiners, UTS #39 homoglyphs, and invisible Unicode Tag characters (U+E0000..U+E007F). -
Server-name typosquatting: A server named
githbu-mcpor CyrillicgΡthub-mcpcan shadow a trustedgithub-mcpentry.
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.
Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes β full credit and traffic to the original publisher.