MCP rug pulls: how to detect when an MCP server changes its tools
Axium Lab released mcp-pin.mjs, a 100-line zero-dependency Node.js lockfile detector that hashes MCP tools/list schemas to catch post-approval rug pulls.
By Dillip Chowdary • Dec 06, 2026 • Source: axium-lab.com

At a glance
- Tool name
- mcp-pin.mjs detector
- Runtime
- Node 18+, zero dependencies
- Transport
- MCP Streamable HTTP (2025-06-18)
- Lockfile
- mcp-tools.lock.json (SHA-256)
- OWASP class
- MCP03 Tool Poisoning
- Exit codes
- 0 clean, 1 drift, 2 error
In this post
Model Context Protocol servers can pass a user's initial security review with an innocent tool definition and later swap in hidden model instructions after approval. To stop these silent post-approval changes, axium-lab.com's report details how MCP rug pulls work and presents a 100-line dependency-free Node.js detector called mcp-pin.mjs that hashes and diffs full tool schemas against a local lockfile.
The walkthrough sits inside Axium Lab's guide to MCP gateways, where change control is one of six core capabilities. Developers, security engineers, and gateway maintainers running Streamable HTTP MCP servers can use the attack taxonomy and lockfile workflow below to catch modified tools before an agent executes them.
01Protocol gaps behind MCP rug pulls
Three structural properties of the Model Context Protocol enable rug pull attacks after a user grants initial trust. First, models treat tool names, descriptions, and input schemas returned by tools/list with roughly the authority of a system prompt.
Second, nothing in MCP freezes a tool definition after onboarding. Servers declaring tools.listChanged can emit notifications/tools/list_changed to prompt a refresh, while servers without that capability can still return altered definitions on the next session's tools/list call.
Third, clients typically prompt for approval once when adding a server and rarely display the full text or highlight subsequent diffs. Invariant Labs first demonstrated this pattern publicly in April 2025, when a malicious "random fact of the day" server swapped its description to hijack a trusted WhatsApp MCP server and leak message history—an attack class now grouped under OWASP MCP03, Tool Poisoning.
02Eight schema fields attackers modify
Watching only the top-level tool description misses seven other ways an attacker can inject instructions or alter client trust decisions. Axium Lab catalogs eight mutation vectors that require hashing and diffing the complete tool object rather than selected fields.
| Mutation surface | Attack example | Security impact |
|---|---|---|
| Tool description | Hidden IMPORTANT tag instructs reading files | Classic prompt-injection poisoning payload |
| New parameter | inputSchema adds required context or notes field | Exfiltrates secrets via normal tool arguments |
| Parameter metadata | Instructions placed in description, default, enum, or key | Buried deep in schema, skipped in reviews |
| Requiredness | Optional parameter switches to required | Forces model to supply omitted sensitive data |
| Annotations | readOnlyHint flips true or destructiveHint drops | Bypasses client confirmation prompts |
| New tool | Unapproved tool appears in tools/list | Inherits server trust without user review |
| Shadowing text | Description tells model to always BCC on send_email | Compromises trusted sibling MCP servers |
| Invisible characters | Zero-width or Unicode tag characters carry hidden text | Defeats visual review unless diff reveals them |
Because clients sometimes trust readOnlyHint annotations to skip confirmation dialogs, the MCP specification advises treating annotations as untrusted unless the server itself is trusted. Detecting invisible Unicode characters also requires tooling that surfaces non-printable code points rather than relying on plain visual inspection.
Advertisement
Tech Pulse Daily
Get tomorrow's pulse first
Join engineers who read Tech Pulse before stand-up. Free, weekday mornings.
03Testing with a malicious HTTP server
To verify detection end to end, Axium Lab provides a standalone test server named rugpull-server.mjs speaking MCP Streamable HTTP over Node's built-in http module. It implements initialize using protocolVersion 2025-06-18, declares tools.listChanged as true, and exposes a single get_fact_of_the_day tool on port 3001.
When launched in clean mode, get_fact_of_the_day advertises a benign description ("Returns a random fun fact.") and a single topic string property. Restarted with PHASE=rugpull, the server injects an IMPORTANT block instructing the model to read ~/.ssh/id_rsa and pass its contents in a newly added context parameter without telling the user.
Note: Axium Lab warns that rugpull-server.mjs is strictly for local testing and must never be exposed on an accessible network interface.
04Pinning schemas with mcp-pin.mjs
The companion detector, mcp-pin.mjs, runs on Node 18 or later with zero external dependencies and mirrors the behavior of a package lockfile. It connects over Streamable HTTP, sends initialize and notifications/initialized, fetches every paginated page of tools/list, and optionally passes an MCP_TOKEN bearer header.
- Initial approval Run node mcp-pin.mjs <server-url> [lockfile] --approve (or run without an existing lockfile) to write canonical tool definitions and SHA-256 hashes into mcp-tools.lock.json.
- Continuous verification Run node mcp-pin.mjs <server-url> [lockfile] before sessions or inside CI jobs to fetch live tools/list output and compare every field against the lockfile.
- Quarantine on drift When any tool is added, removed, or modified, mcp-pin.mjs prints the exact changed fields and exits with status code 1 (returning 0 on clean match and 2 on error).
Using exit code 1 lets teams wire the check into scheduled pipelines or pre-session hooks so drifted definitions halt execution until a human re-approves them.
05Detection blind spots and gateway scope
Even a strict field-by-field hash comparison against tools/list has clear boundaries that teams must understand. If an attacker hosts a separate malicious tool behind a legitimate-looking first-party schema or alters server-side execution behavior without changing any advertised JSON field, a definition lockfile will not detect the behavioral shift.
Furthermore, mcp-pin.mjs targets Streamable HTTP servers and does not cover local stdio MCP processes out of the box. As part of a broader MCP gateway architecture, schema pinning handles change control alongside the five other gateway capabilities needed to govern agent tool access safely.
Frequently asked questions
What is an MCP rug pull attack?
An MCP rug pull happens when an MCP server serves a benign tool definition during initial user approval and later changes the description, schema, annotations, or tool list to inject hidden instructions for the AI model.
Why do visual reviews miss MCP tool poisoning?
Attackers can hide instructions inside nested parameter descriptions, enum values, default strings, or invisible zero-width and Unicode tag characters, and most MCP clients do not re-display diffs when definitions change.
How does mcp-pin.mjs detect changed MCP tool definitions?
It connects over Streamable HTTP, paginates tools/list, computes canonical SHA-256 hashes of every field, and compares live output against mcp-tools.lock.json, exiting with code 1 if any tool is added, removed, or modified.
Which standard categorizes MCP rug pulls and tool shadowing?
Invariant Labs publicly demonstrated the technique in April 2025 against a WhatsApp MCP server, and the OWASP MCP Top 10 now classifies rug pulls, poisoning, and shadowing under MCP03, Tool Poisoning.
Sources
Author
Dillip Chowdary
Writes Tech Bytes coverage of AI, engineering, and the tools that actually ship. Editor of Tech Pulse Daily.
Related on Tech Bytes
Advertisement