MCP Security Hardening Guide
Practical guide to securing Model Context Protocol (MCP) servers against tool poisoning, indirect prompt injection, unscoped credentials, and confused deputy attacks.
1. Why Default MCP Deployments Are High Risk
Most early MCP servers were built for local developer convenience and later promoted into shared workflows. When an LLM connects to an MCP server with broad credentials, any indirect prompt injection inside an email, ticket, web page, or code repository can hijack the agent's tool calls.
- Unscoped credentials: MCP servers running with shared admin API keys or read/write production database strings.
- Tool poisoning: Malicious instructions hidden inside third-party MCP tool descriptions or parameter schemas.
- Confused deputy: The LLM acts with the MCP server's elevated permissions rather than the invoking user's permissions.
- Zero auditability: No log tying a specific user prompt to the resulting SQL query, API call, or file write.
2. Production Hardening Checklist
| Control Area | Insecure Default | Hardened Production Standard |
|---|---|---|
| Authentication | Static shared API key in `.env` | Per-user OAuth 2.1 / short-lived scoped tokens propagated to backend |
| Database Access | Production `postgres` / `sa` user | Read-only replica user with row-level security and query allowlists |
| Tool Inventory | Dynamic unverified npm/PyPI MCP packages | Pinned versions, cryptographic hashes, reviewed tool descriptions |
| Mutations / Writes | Autonomous execution on model output | Mandatory human confirmation step + policy engine gate before write/delete |
| Network & Runtime | Host network access, local filesystem | Containerized sandbox, egress allowlist, no arbitrary shell execution |
| Observability | Stdout logs only | Structured JSON audit log (user, session, tool, args, result) shipped to SIEM |
3. Defending Against Indirect Prompt Injection and Tool Poisoning
- Maintain an explicit allowlist of approved MCP servers and tools; block arbitrary community servers on developer workstations via endpoint/MDM policy.
- Treat all tool outputs (web fetches, Jira tickets, emails, database rows) as untrusted data, never as executable instructions.
- Separate read-only retrieval tools from state-changing action tools into distinct MCP servers with separate trust boundaries.
- Red-team every MCP-connected workflow against OWASP LLM Top 10 and MITRE ATLAS before exposing it to staff or customers.
Frequently asked questions
What is MCP tool poisoning?
Tool poisoning hides adversarial instructions inside an MCP server's tool metadata, description, or schema. Even if the user never invokes that specific tool, the LLM reads all loaded tool definitions in its context window and can be manipulated into exfiltrating data or calling other tools.
How should we secure local developer MCP servers in Cursor or Claude?
Enforce an allowlist of vetted MCP servers, require read-only scoped tokens instead of admin PATs, isolate local servers from production networks, and log or block unauthorized tool installations.