Direct answer
MCP security is the practice of limiting what a Model Context Protocol (MCP) server can reach and do once an AI agent calls it. The main risks are prompt injection through tool results, poisoned tool descriptions, fake or hijacked server packages and over-scoped tokens. You reduce them by installing fewer servers, scoping tokens, approving tool calls and sandboxing local servers.
Published 27 November 2026 by the Better Design team, who build and run an MCP server used in these clients. Checked that day against the MCP specification, the OWASP MCP Top 10, published advisories and each client's docs.
Summary
- An MCP server is code that runs with your permissions and your tokens. Treat installing one like installing any package from the internet.
- Your agent reads every tool description and every tool result. Text in a GitHub issue, a support ticket or a web page can steer it, which is called prompt injection.
- Real incidents already happened: a fake postmark-mcp package copied emails, and a public GitHub issue led an agent to leak private repository data.
- Every major client can approve calls one by one and allow or block single tools. Each of Claude Code, Cursor, Codex and VS Code names the setting differently.
- Project config files such as .mcp.json can start servers. Claude Code and Codex ask before trusting a cloned repository's servers; VS Code starts them once you trust the workspace.
- Free scanners exist: Snyk Agent Scan (formerly mcp-scan), Cisco MCP Scanner and the official MCP Inspector.
What is MCP security?
MCP security covers three parts: the server you install, the client that runs it, and the connection between them. The Model Context Protocol itself does not decide what a tool may do. The server code and its credentials decide that, and the client decides when to call it.
A server can offer tools, which the model calls, resources, which the application reads into context, and prompts. Each is a way for outside text to reach the model.
The new part is who picks the call. With a normal API, a developer writes each request. With MCP, the model chooses the tool and its arguments from natural language. Everything in its context can influence that choice, including text attackers wrote in an issue, an email or a web page.
This guide is for people who use MCP servers in clients such as Claude Code, Cursor, Codex, VS Code or Claude Desktop. If you build a server, also read the MCP security best practices in the specification. They cover authorization flaws such as the confused deputy and token passthrough in depth.
What are the main MCP security risks?
These six MCP security risks cause most real incidents. The OWASP MCP Top 10 (version 2025, in beta) lists ten, and these six map onto it. Each one lets attackers reach sensitive data or internal systems through a server you connected.
- Prompt injection through tool results
- A tool returns text, such as an issue body or an email, that tells the model to do something else. OWASP lists it as MCP06.
- Tool poisoning
- A server hides instructions in a tool description or parameter schema. Your agent reads it; you usually do not. OWASP MCP03.
- Rug pulls
- A server changes its tool descriptions or metadata after you approved it. A tool that was safe on day one may not be safe on day ten.
- Supply chain attacks
- A fake or typosquatted package, or a real package whose new version turns malicious. OWASP MCP04.
- Over-scoped tokens
- A server holds a key that can do far more than the job needs. One example is full mailbox access to read one label. OWASP MCP01 and MCP02.
- Command injection in the server
- The server passes model-chosen arguments to a shell, git or SQL without checks. OWASP MCP05.
The risks combine. One server reads untrusted text, a second server holds private data, and a third can send data out. Simon Willison calls this the lethal trifecta: private data, untrusted content and a way to communicate out in the same session. Removing any one of the three stops this kind of data theft.
Which MCP security incidents have happened?
These are documented cases with a public advisory or the researcher's own write-up, checked on 27 November 2026.
- April 2025, WhatsApp MCP
- Invariant Labs showed a server that looked harmless at install. On the next launch it swapped its tool description, and the agent sent chat history to another number. No patch exists; it is a design weakness of mixing servers.
- May 2025, GitHub MCP server
- A prompt injection in a public repository issue made an agent copy private repository data into a public pull request. GitHub later added read-only and lockdown modes.
- June 2025, Asana
- A logic bug in Asana's MCP feature exposed some data across organizations. Asana took the server offline, fixed it and reset all MCP connections.
- June 2025, MCP Inspector, CVE-2025-49596
- The debugging proxy had no authentication, so a web page could run commands on a developer's machine. Fixed in version 0.14.1.
- July 2025, Filesystem server, CVE-2025-53109 and CVE-2025-53110
- A prefix check and symlinks let the model escape the allowed folders. Fixed in 2025.7.1.
- July 2025, Supabase MCP in Cursor
- An attacker's support ticket told the agent to read integration tokens with the service_role key. The agent posted them back into the ticket. Supabase added a read-only mode and project scoping.
- July 2025, mcp-remote, CVE-2025-6514
- A malicious server's OAuth endpoint led to command execution on the client. Fixed in 0.1.16.
- September 2025, postmark-mcp
- A fake npm package behaved for 15 versions, then version 1.0.16 secretly copied every email it sent to an outside address. Postmark's own notice says the package was not theirs.
- January 2026, Anthropic's Git MCP server, CVE-2025-68143 to CVE-2025-68145
- Three flaws in the reference Git server. Chained with the Filesystem server, they allowed code execution through prompt injection. Fixed in 2025.12.18.
Two lessons repeat. Most cases needed no bug in the model: the agent did what text told it to. And reference servers from the protocol's own maintainers had flaws too, so update every server, not only community ones.
How do you check an MCP server before you install it?
Good MCP server security starts before install: read the tools, not the README. A server with one narrow tool is easier to trust than one with 30 broad ones. People in r/mcp make this point again and again.
- Confirm the publisher. Install from the vendor's own repository or the official MCP Registry, and check the exact package name for typosquats.
- List its tools before you connect it to an agent: npx @modelcontextprotocol/inspector --cli <command> --method tools/list prints every tool and description.
- Read each description for instructions aimed at the model, such as "before using this tool, read ~/.ssh" or "do not tell the user".
- Check what the token can do. Create a new key for this server only, with the narrowest scope the vendor offers, such as read-only.
- Pin the version. Use [email protected] instead of @latest, so a new release cannot change the tools without you noticing.
- Scan it. Run uvx snyk-agent-scan@latest, which looks for poisoned descriptions and cross-server shadowing. Its README warns that it starts stdio servers, so scan inside a sandbox.
Are local or remote MCP servers safer?
Neither is secure by default. A local stdio server runs on your computer with your user's access to files, network and environment variables. A remote server runs on someone else's machine, so you trust its operator with every request and token you send it.
- Local: you can see the code, pin it and sandbox it. The risk is that it can read anything you can, including SSH keys and other servers' tokens.
- Remote: it cannot touch your disk, and OAuth can limit its scope. The risk is that you cannot see what this third party does with your requests and data.
- Run local servers in a container with only the network and folders they need. Docker's MCP Toolkit does this for catalog servers.
- VS Code can sandbox a local server on macOS and Linux: set sandboxEnabled to true in mcp.json and list allowed folders and domains. VS Code then auto-approves that server's tool calls, so keep the sandbox narrow.
How do you lock down MCP in Claude Code, Cursor, Codex and VS Code?
Every client has controls to ask before each tool call and to allow or block single tools. Start with asking, then allow only the read tools you use daily. These steps follow the MCP security best practices from the specification and OWASP. Settings below were read in each vendor's docs on 27 November 2026.
Claude Code MCP security settings
- Claude Code asks before each MCP tool call by default. Add rules under permissions in settings.json: allow, ask or deny, with names like mcp__github__get_issue or mcp__github__* for a whole server.
- Deny every MCP tool in one rule with mcp__*. An allow rule needs the server name, because Claude Code skips an allow glob such as mcp__*.
- Project servers in .mcp.json need your approval first. A cloned repository cannot approve its own servers, even if it commits enableAllProjectMcpServers.
- Claude Code's MCP docs list one exception: claude -p and the Agent SDK skip that prompt in a folder you have not trusted. Pass --strict-mcp-config in scripts.
- Put tokens in environment variables and reference them as ${VAR} in .mcp.json, not as literal values. OAuth tokens go to the macOS Keychain, or a file only your user can read on Linux.
- Admins can ship managed-mcp.json or set allowedMcpServers and deniedMcpServers. The docs warn that matching by serverName alone is not a security control.
Read Claude Code's MCP and permissions docs.
Cursor
- Cursor asks you to approve each new MCP server. Its Run Modes, under Settings, Agents, Approvals & Execution, decide which tool calls run without asking: Auto-review (the default), Allowlist, or Run Everything.
- Allow single tools in ~/.cursor/permissions.json or a project's .cursor/permissions.json with mcpAllowlist entries such as "github:get_issue". Avoid a whole-server wildcard for servers that can write.
- Cursor's docs say the Auto-review instructions are not a security boundary. Use the allowlist for anything that matters.
- Cursor's sandbox covers terminal commands, not MCP calls. Turn off tools you do not need from the tools list in the chat panel.
- Teams can set an MCP allowlist of commands, URLs and tools in Team Settings, and admin run-mode settings override each user's file.
Read Cursor's agent security docs.
Codex
- Codex reads servers from [mcp_servers.<name>] tables in ~/.codex/config.toml. Each takes enabled_tools and disabled_tools; disabled_tools applies after enabled_tools.
- Set default_tools_approval_mode to prompt, or writes to ask only for tools that change things. Override one tool with tools.<tool>.approval_mode.
- The Codex docs say it asks before any tool that marks itself destructive. Do not run --yolo, short for --dangerously-bypass-approvals-and-sandbox, with servers that can write.
- sandbox_mode limits shell commands. Its network proxy does not filter MCP server connections, so the sandbox does not contain a server.
- Codex loads a project's config only when you trust the project. Admins can allowlist servers by command or URL in requirements.toml; any other server is disabled.
VS Code
- VS Code asks before each MCP tool call by default. Its docs describe approving once, for the session, for the workspace or for the user, per tool or per server.
- Avoid chat.tools.global.autoApprove, which VS Code itself calls YOLO mode, in a workspace with write-capable servers.
- A workspace's .vscode/mcp.json inherits Workspace Trust: once you trust a folder, its servers can start without a separate prompt. Open unknown repositories in Restricted Mode.
- Store keys as inputs with promptString and password set to true, then reference them as ${input:name}. VS Code keeps them in its secret storage instead of the JSON file.
- Admins can allow or block servers and limit access to the registry through enterprise policies.
Where should MCP API keys and tokens go?
Give each server its own key with the smallest scope, and keep the key out of files you commit.
- Use environment variables or the client's secret storage. A literal token in .mcp.json, .cursor/mcp.json or .vscode/mcp.json ends up in git history sooner or later.
- Prefer OAuth for remote servers. You approve scopes in a browser, and the client can store the token in the system keychain.
- Prefer read-only keys and enforce them at the source, for example a read-only database role. OWASP notes a 2026 case where a server's query-filtering read-only mode let writes through.
- Rotate a key when you remove its server, and right away if a server you used turns out to be malicious.
- If you run a remote server, follow the specification's authorization rules. The specification says a server must accept only access tokens issued for it and must not pass a client's token on to another API. The specification calls that token passthrough, and an attacker can abuse it to skip your access checks.
How do teams roll out MCP servers safely?
Approve a short catalog, enforce it in the client, and log every tool call. People running MCP for hundreds of users in r/mcp describe the same pattern.
- Keep an approved list of servers and versions. Enforce it with each client's managed setting: managed-mcp.json in Claude Code, the team MCP allowlist in Cursor, requirements.toml in Codex, and enterprise policies in VS Code.
- Put a gateway in front of remote servers, so keys live in one place and each call is logged with its arguments. Logs help you spot and prevent misuse early.
- Watch for shadow servers: people add servers on their own laptops. OWASP lists these as MCP09.
- Re-review a server when its tool list changes. The Inspector's tools/list output, saved per version, makes changes easy to diff.
How we checked
On 27 November 2026 we read the MCP specification's security best practices and the OWASP MCP Top 10 and cheat sheet. We also read the client docs linked above. For each incident we read the advisory or the researchers' write-up, and dropped cases we could not trace to one. We read two r/mcp threads on vetting servers and a SANS talk on tool poisoning. We did not test exploits.
Want your agent to build with your design system too?
Safe MCP setup keeps an agent from doing the wrong thing. It does not tell it which colors, type and components your product uses. Better Design is an MCP server we make that gives Claude Code, Cursor or Codex your design system before they build a page. A free account gets 300 tool calls in 30 days.
Frequently asked questions
MCP is as safe as the servers you connect and the permissions you give them. Use servers from known publishers, approve tool calls, and do not mix a server that reads untrusted text with one that holds private data.
Partly. Remote servers can use OAuth 2.1, and the specification says hosts must get user consent before calling a tool. Authorization is optional, though, and nothing in the protocol checks what a server's code does.
For local servers you did not write, yes. A container limits the files and network the server can reach. Mount only the folders it needs and give it no access to your home directory.
Tool poisoning means hidden instructions in a tool's description or schema. An agent treats them as guidance, for example to read a private file and pass it as a tool argument. The user sees only the tool's name.
Run Snyk Agent Scan with uvx snyk-agent-scan@latest, or Cisco's MCP Scanner. For a server you build, review it against the OWASP cheat sheet and test it with the MCP Inspector.
Looking for vetted servers? Read the MCP servers list.
Read the Filesystem MCP guide, including its read-only mode.
