The idea
An MCP server’s tool names and descriptions are text the model reads, so a malicious or compromised server can carry prompt injection ("tool poisoning"), shadow trusted tools with look-alike names, or change its behaviour after you approved it. Local servers run code on your machine with your permissions.
Treat MCP servers like any dependency: install from trusted publishers, pin versions, review what tools they expose, run local servers with minimal permissions, and prefer remote servers with proper OAuth over pasting long-lived tokens.
In your own clients, show users which server a tool comes from, require approval for sensitive tools, and alert on tool definition changes.
MCP makes connecting tools easy, which also makes connecting a malicious one easy.
Words to know
- Tool poisoningMalicious instructions hidden in tool descriptions.
- Rug pullA server changing its tools after it was approved.
Try it without code
Review a server
- Pick an MCP server you use.
- Read its tool descriptions in full.
- Check its publisher, version pinning and the permissions it runs with.
Use it in code
Pin and diff tool definitions so changes require re-approval.
import hashlib, json, pathlib
PINS = pathlib.Path("mcp_pins.json")
def fingerprint(tools):
canon = json.dumps([{"name": t.name, "description": t.description, "schema": t.inputSchema}
for t in sorted(tools, key=lambda t: t.name)], sort_keys=True)
return hashlib.sha256(canon.encode()).hexdigest()
def verify(server_name, tools):
pins = json.loads(PINS.read_text()) if PINS.exists() else {}
fp = fingerprint(tools)
if server_name in pins and pins[server_name] != fp:
raise RuntimeError(f"{server_name} tool definitions changed - review before use")
pins.setdefault(server_name, fp)
PINS.write_text(json.dumps(pins, indent=2))Add tool fingerprint pinning to your MCP client and show the server name next to every tool call in your logs.
Common mistakes
- Installing servers from random repos with npx and full permissions.
- Auto-approving all tools from a server.