MCP security best practices: how to lock down MCP servers for AI agents
Every MCP server you connect is code that runs with your permissions. Here are twelve controls to lock them down in 30 days.
Every MCP server you connect is code that runs with your permissions. Here are twelve controls to lock them down in 30 days.
The Model Context Protocol (MCP) is the standard interface through which AI applications reach tools and data. An MCP client inside an application such as Claude, Cursor, Visual Studio Code or an agent your team has built connects to MCP servers, and each server exposes tools the model can call: read a repository, query a database, send an email, open a browser. Anthropic introduced the protocol in November 2024 (NSA, May 2026), and it has since become the most widely adopted way for agents to connect to the systems a company runs on.
That position has made MCP a security boundary in its own right. OWASP now maintains an MCP Top 10. In 2026 alone, the National Security Agency published design guidance for MCP deployments, the Coalition for Secure AI published an auditable MCP security framework, the protocol’s maintainers shipped a specification revision that rewrote sessions and tightened authorization, and researchers disclosed command-execution, credential-theft and server-side request forgery (SSRF) flaws in the official SDKs and in widely used servers. Enterprise security reviews have started to ask about MCP by name.
This guide sets out twelve MCP security best practices that apply to companies that use MCP servers, build them, or both. Each practice is tied to the primary sources it comes from: the MCP specification and its security best practices, the OWASP MCP Top 10, the OWASP MCP Security Cheat Sheet, the NSA’s Cybersecurity Information Sheet, and the incidents that shaped them. It closes with a 30-day plan and the questions enterprise buyers now ask.
Our earlier post, Your MCP Server Passed Review, Then It Changed, examines one problem in depth: approved servers that change after review. This guide covers the whole lifecycle and links to that post where the detail lives.
MCP security best practices at a glance
Securing MCP comes down to controlling five boundaries: which servers a client is allowed to run, what those servers put into the model’s context, what a local server process can reach, which tokens a remote server accepts, and what each server can do upstream. In practice that means twelve controls: an inventory, an enforced allowlist, pinned and verified versions, OAuth 2.1 as the specification defines it, no token passthrough, one scoped credential per server, sandboxed local servers, tool output treated as untrusted, server-side input and egress validation, human approval for consequential actions, complete tool-call logging, and prompt patching of MCP SDKs and servers.
If you need to start somewhere this week, read every MCP configuration file in your company, write down what each server can reach, and remove the ones nobody owns. The 30-day plan below takes it from there.
How MCP works, and where the trust boundaries are
MCP defines three roles. The host is the application the user works in. The client is the component inside the host that holds a connection to one server. The server exposes tools, resources and prompts. Servers reach the client over one of two standard transports:
- stdio. The client launches the server as a local child process, using a command and arguments taken from its configuration file, and exchanges JSON-RPC messages over standard input and output. The server runs with the operating system permissions of the user who launched the client.
- Streamable HTTP. The server runs as a network service, locally or remotely. For HTTP transports the authorization specification defines an OAuth 2.1 profile. The specification states that stdio implementations should not follow it and should take credentials from the environment instead.
The 2026-07-28 revision, published on July 28, 2026 by maintainers David Soria Parra and Den Delimarsky, made the protocol’s core stateless. It retired the initialize handshake and the Mcp-Session-Id header, so each request now carries its protocol version, client identity and capabilities. It requires Streamable HTTP requests to include Mcp-Method and Mcp-Name headers so gateways and web application firewalls can route and filter on them, formally deprecates Dynamic Client Registration in favor of Client ID Metadata Documents, and requires clients to validate the authorization server’s issuer before redeeming a code when the server supports it. Roots, Sampling and protocol Logging are deprecated, and the legacy HTTP+SSE transport has a one-year offramp. Several of the practices below depend on these changes.
The security problem follows from the architecture. A tool call crosses five boundaries, and each one needs its own control:
- Configuration. Whatever the client’s configuration names is what runs. For a stdio server that is an arbitrary command on the user’s machine.
- Context. Tool names, descriptions, schemas and results are all text the model reads, and the model cannot reliably distinguish data from instructions.
- Process. A local server inherits the user’s files, environment variables, SSH keys, cloud credentials and network access unless something takes them away.
- Token. A remote server must be able to tell that a token was issued for it, by the authorization server it trusts, to the client presenting it.
- Upstream. The server acts on other systems with some credential. How broad that credential is determines what a compromised or manipulated server can do.
The OWASP MCP Top 10
The OWASP MCP Top 10, led by Vandana Verma Sehgal, is the most widely used taxonomy of MCP risks. Its entries carry a 2025 designation and the project describes itself as in its beta release and pilot-testing phase, so expect revisions. The table lists each entry with the practice in this guide that addresses it.
| ID | Risk | What it looks like in practice | Primary practice |
|---|---|---|---|
| MCP01 | Token Mismanagement & Secret Exposure | Long-lived tokens in configuration files, secrets in tool arguments or logs | 5 |
| MCP02 | Privilege Escalation via Scope Creep | A server’s permissions grow beyond what its tools need | 5, 9 |
| MCP03 | Tool Poisoning | Hidden instructions in tool descriptions, schemas or outputs | 3, 7 |
| MCP04 | Software Supply Chain Attacks & Dependency Tampering | A malicious package version, or a compromised dependency | 3, 11 |
| MCP05 | Command Injection & Execution | Untrusted input reaches a shell, a query or a launch command | 6, 8 |
| MCP06 | Prompt Injection via Contextual Payloads | Text in a ticket, web page or document redirects the agent | 7 |
| MCP07 | Insufficient Authentication & Authorization | Unauthenticated endpoints, tokens accepted without audience checks | 4 |
| MCP08 | Lack of Audit and Telemetry | No record of which tool was called, with what arguments, by whom | 10 |
| MCP09 | Shadow MCP Servers | Servers installed by individuals outside any review | 1, 2 |
| MCP10 | Context Injection & Over-Sharing | Data from one user, task or tenant reaching another | 7, server requirements |
Risk names as published on the OWASP project page, checked November 2026.
MCP security incidents, 2025–2026
The practices in this guide respond to specific failures. The table summarizes the incidents and disclosures most often cited in MCP guidance, in chronological order. Each has a primary source.
| Disclosed | Incident | What failed | Source |
|---|---|---|---|
| April 2025 | Tool poisoning, shadowing and rug pulls demonstrated against Cursor | Hidden instructions in tool descriptions; descriptions changed after approval | Invariant Labs |
| May 2025 | GitHub MCP “toxic agent flow”: a public issue causes private repository data to be published | Prompt injection combined with a token that could read every repository | Invariant Labs |
| June 2025 | MCP Inspector remote code execution, CVE-2025-49596 (CVSS 9.4) | Developer tool listening without authentication, reachable from a browser | Oligo Security |
| June 2025 | Asana takes its MCP server offline from June 5 to June 17 after a bug that could expose data to other organizations’ users | Tenant isolation in a multi-tenant server | The Register |
| July 2025 | mcp-remote remote code execution, CVE-2025-6514 (CVSS 9.6) | A malicious server’s authorization endpoint passed to the operating system | JFrog |
| July 2025 | Filesystem server sandbox escapes, CVE-2025-53109 and CVE-2025-53110 | Prefix-based path checks and symlink handling | Cymulate |
| September 2025 | postmark-mcp package adds a hidden BCC to every email it sends | A trusted package turned malicious in a later version | Snyk |
| October 2025 | Smithery hosting platform: path traversal exposes a deployment token for over 3,000 hosted servers | Build configuration not confined; an overprivileged platform credential | GitGuardian |
| April 2026 | OX Security: the stdio transport executes whatever command it is configured with, across the official SDKs | Configuration that untrusted input can influence | Cloud Security Alliance |
| August 2026 | Grafana MCP: session IDs checked only for format; SSRF in a generic API tool, CVE-2026-19516 | Session handling and unrestricted outbound requests | Pillar Security |
| September 2026 | LiteLLM MCP gateway accepts any bearer token, CVE-2026-59822, which Wiz reports CISA added to its Known Exploited Vulnerabilities catalog | Token validation that failed open | Wiz |
| September 2026 | Official MCP Python SDK can send OAuth credentials to an attacker’s token endpoint | Issuer not bound on a fallback discovery path | Cycode |
| October 2026 | OpenCode on Windows: a malicious server’s authorization URL executes code during sign-in | Server-supplied URL passed into a PowerShell command | Pillar Security |
| October 2026 | Reference server server-everything exposes the full process environment to any web page | HTTP transport bound to all interfaces with wildcard CORS and no authentication | GitHub advisory |
Two patterns stand out. First, most of these are ordinary web and supply-chain weaknesses (missing authentication, SSRF, command injection, unvalidated redirects, malicious package updates) appearing in a new layer that many teams have not yet brought under their existing controls. Second, the protocol-specific failures concentrate where the model meets untrusted text, and no server-side patch removes that risk; it has to be contained by permissions and isolation.
Measurement studies point the same way. In July 2025 Knostic identified 1,862 MCP servers exposed to the internet and manually checked 119 of them; all 119 listed their tools without requiring authentication (Knostic). In October 2026 researchers from Pennsylvania State University, Dartmouth College and Université de Montpellier fuzzed 273 open-source MCP servers exposing 3,405 tools and found verified bugs in 343 tools across 118 servers (arXiv 2610.13651).
Twelve MCP security best practices
The practices are ordered roughly by when a company should adopt them. The first three establish control over what runs. The next three govern identity, credentials and isolation. Practices 7 through 9 address the model itself, and the last three keep the program working over time.
1. Maintain an inventory of every MCP server and client
You cannot control servers you do not know about. Shadow MCP servers are their own entry in the OWASP list (MCP09), and the NSA’s guidance recommends maintaining “an inventory of all deployed MCP agents and tools with versioning, patch history, and known concerns” (NSA, May 2026).
An MCP inventory has three parts:
- Servers configured on developer machines. Each client keeps its own configuration. Common locations include
~/.cursor/mcp.json,.vscode/mcp.jsonin a repository, the Claude Desktop and Claude Code configuration files, and project-level files committed to repositories. Collect them with your endpoint management tool, or with a script that reads the known paths. For each server, record the command or URL, the version, who installed it, what credential it holds and what that credential can reach. - Servers your product runs or connects to. Include internal servers, third-party remote servers and any MCP gateway or proxy in the request path.
- MCP SDKs in your dependency tree. Several 2026 advisories were in the official SDKs rather than in any particular server. The Cloud Security Alliance’s November 2026 research note recommends inventorying “every MCP SDK dependency, including transitive ones” (CSA, November 9, 2026).
The NSA also recommends regularly scanning the network for unauthenticated or unauthorized MCP servers, and names open-source scanners for the purpose. Use differential reports, because local servers move between ports.
Assign every server an owner. A server without an owner is the one that will still be running, with a valid credential, a year after the project that needed it ended. Our 30-minute AI credential inventory is a worksheet for the credential half of this exercise.
2. Enforce an allowlist in managed client configuration
Once you know what is in use, decide what is allowed and enforce it where users cannot override it. Major clients now support centrally managed MCP policy:
- Claude Code reads a
managed-mcp.jsonfile from a system location (for example/etc/claude-code/managed-mcp.jsonon Linux). When the file is present, “Users can’t add, modify, or use any other MCP servers,” including servers passed on the command line. Administrators can also setallowedMcpServersanddeniedMcpServersin managed settings. The documentation warns that matching on a server’s name “is not a security control” and that enforcement should match onserverUrlorserverCommand, and that withoutallowManagedMcpServersOnly, allowlists from every settings scope merge, including the user’s own (Claude Code docs). - GitHub Copilot supports enterprise allowlists and denylists for MCP servers, a policy that restricts access to servers in a designated registry, and a registry URL setting (GitHub Docs).
- VS Code asks users to review trust, sign-in and tool approval requests, and warns that “Local MCP servers can run code on your machine”; server availability can also be limited by organization policy (VS Code docs).
Three details matter when you write the allowlist:
- Match on what executes, not what it is called. A name is a label that anyone can reuse. Match on the exact launch command with its pinned version, or on the exact HTTPS URL.
- A registry listing is not a security review. The official MCP Registry, which is still in preview, verifies namespace ownership through GitHub, DNS or HTTP challenges and hosts metadata; its documentation states that it “focuses on namespace authentication and metadata hosting” and leaves security scanning to package registries and downstream aggregators (MCP Registry). In OX Security’s April 2026 research, nine of eleven MCP marketplaces accepted a proof-of-concept malicious listing without review (VentureBeat, May 1, 2026).
- Do not put secrets in managed configuration. Anthropic’s documentation notes that any user on the machine can read
managed-mcp.json, so API keys do not belong in itsenvblocks.
3. Pin versions and verify tool definitions
An approval applies to a specific version of a server and a specific set of tool definitions. Both can change without notice. Invariant Labs, which named the “rug pull” in April 2025, recommended that clients pin server versions and verify tool descriptions with “a hash or checksum” (Invariant Labs). The OWASP cheat sheet goes further and recommends hashing the full definition, including inputSchema, outputSchema and annotations, because instructions can be hidden in parameter descriptions as easily as in the tool description (OWASP).
Pin the package version in the launch command, and the image digest for containers:
{
"mcpServers": {
"github": {
"command": "docker",
"args": ["run", "-i", "--rm", "ghcr.io/github/github-mcp-server@sha256:<digest>"]
},
"docs-search": {
"command": "npx",
"args": ["-y", "example-docs-mcp@1.4.2"]
}
}
}
An unversioned npx -y package resolves to whatever is newest on the next launch, which is how the postmark-mcp change reached users: Snyk found that the malicious behavior began around version 1.0.16, after earlier versions had behaved as advertised (Snyk, September 25, 2025).
For tool definitions, record a canonical hash of each tool’s name, description, schemas and annotations at approval, recompute it on every connection and every list_changed notification, and require review when it changes. The drift post covers the canonicalization, the hash file and how to grade changes so that harmless rewording does not interrupt engineers. Updates should then arrive the way dependency updates do: as a pull request that someone reviews.
4. Implement the MCP authorization specification as written
For any remote MCP server that exposes non-public data, authentication is required, and the specification defines how to do it. The current requirements, from the 2026-07-28 authorization specification and its security considerations, are:
| Requirement | Who | Specification language |
|---|---|---|
| OAuth 2.1 authorization server | Authorization server | MUST implement OAuth 2.1 |
| Protected Resource Metadata (RFC 9728) | MCP server | MUST implement; clients MUST use it to discover the authorization server |
PKCE with S256 | Client | MUST implement, MUST use S256 when technically capable, MUST refuse to proceed if support is not advertised |
| Resource indicator (RFC 8707) | Client | MUST send resource naming the MCP server in authorization and token requests |
| Issuer validation (RFC 9207) | Client | MUST validate iss before redeeming the code when the authorization server advertises support; the specification expects to make it mandatory in a future revision |
| Client identification | Client | Client ID Metadata Documents preferred; Dynamic Client Registration is deprecated |
| Token transport | Client | Authorization: Bearer header on every request; MUST NOT place tokens in the query string |
| Audience validation | MCP server | MUST validate that tokens were issued for it and reject those that were not |
| HTTPS | All | Authorization endpoints MUST use HTTPS; redirect URIs MUST be localhost or HTTPS |
| Refresh token rotation | Authorization server | MUST rotate refresh tokens for public clients |
Several 2026 disclosures sit directly on these lines. The Python SDK flaw disclosed by Cycode on September 28 let a malicious server skip the issuer check by answering the first discovery request with a 404; it was fixed in mcp 1.30.0 and 2.2.0 (Cycode). FastMCP’s machine-to-machine providers had the same class of problem, fixed in 4.1.2 with a new issuer parameter, and the advisory notes that upgrading alone is not sufficient: you must set the issuer and rotate any secret that may have reached an untrusted endpoint (GitHub advisory). LiteLLM’s MCP gateway returned an empty authenticated user when token validation failed, so, in Wiz’s words, “Any Bearer token (even just a single character, e.g., x) grants full MCP access” (Wiz, August 2026).
Clients also need to treat every URL a server supplies as untrusted. The specification’s security best practices require clients to accept only http and https authorization URLs, reject other schemes, and never open URLs through a shell (MCP security best practices). CVE-2025-6514 in mcp-remote and the October 2026 OpenCode flaw were both failures of that rule, eighteen months apart.
For companies that run an identity provider, the Enterprise-Managed Authorization extension, stable since June 18, 2026, lets the identity provider issue an Identity Assertion JWT Authorization Grant (ID-JAG) at single sign-on, which the client exchanges for an MCP access token without a per-server consent screen. Access decisions then follow group membership and conditional access rules in the identity provider, and so does the audit trail. Okta was the first supported provider.
5. Never pass tokens through, and give each server its own scoped credential
The specification is unambiguous: “MCP servers MUST NOT accept any tokens that were not explicitly issued for the MCP server,” and a server must not pass the token it received from the client to an upstream API (MCP security best practices). Passthrough bypasses the server’s own controls, leaves the upstream service unable to attribute the action, and allows a token stolen from one service to be replayed against another.
The upstream side of each server needs its own credential, and that credential is where most of an MCP server’s risk sits. Apply four rules:
- One credential per server. Never share a token across servers. When one server is compromised, you rotate one credential, and your logs show which server acted. Our post Your Agents Share One API Key covers why shared keys break accountability.
- Narrowest scope that does the job. Read-only by default, limited to named repositories, projects or tables. The GitHub incident in May 2025 worked because the agent’s token could read private repositories and write to public ones; Invariant’s recommended policy was to allow access to only one repository per session (Invariant Labs).
- Short-lived where the service allows it. Prefer OAuth tokens with expiry over long-lived personal access tokens, and rotate what cannot expire.
- Stored in a credential store, not in configuration. The OWASP cheat sheet recommends operating system credential stores and says OAuth tokens should never be stored in plaintext configuration (OWASP).
For remote servers, request minimal scopes first and elevate only when the server returns an insufficient_scope challenge, which the specification supports through step-up authorization. Note one behavior the specification documents: when a server’s initial challenge omits a scope value, clients fall back to requesting every scope in scopes_supported, so servers should always state the scope they need.
At higher assurance levels, the Coalition for Secure AI’s MCP Security framework makes sender-constrained tokens (DPoP or mutual TLS) a hard requirement for its Production level, so that a stolen token cannot be used from another machine.
6. Treat every local server as code execution, and sandbox it
A stdio server is a program your MCP client runs with your permissions. In April 2026 OX Security showed what that means when an attacker can influence the configuration. Across the official SDKs for Python, TypeScript, Java and Rust, the stdio transport runs the configured command before checking whether it is a valid MCP server; the Cloud Security Alliance summarized the behavior as “execute-first, validate-never” (CSA, April 20, 2026). OX reported more than ten high or critical CVEs in products that let unauthenticated users, allowlist bypasses, prompt injections or marketplace listings reach that configuration, and estimated up to 200,000 vulnerable instances, a figure extrapolated from roughly 7,000 publicly reachable servers. Anthropic described the behavior as “expected” and updated its security guidance rather than the protocol (VentureBeat).
Whatever view one takes of the design decision, the operational conclusion is the same: the integrity of MCP configuration is a security control, and local servers need containment.
- Protect the configuration. Nothing the model can write to, and no unauthenticated interface, should be able to add or change an MCP server definition. The specification’s best practices require that clients offering one-click local installation show the exact command without truncation, identify it as potentially dangerous and require explicit approval.
- Sandbox local servers. Run them in containers or under operating system sandboxing that denies access to the home directory, environment variables and network by default, then allow only what each server needs. The NSA names AppContainers on Windows, seccomp, AppArmor and SELinux. Docker’s MCP Gateway runs servers in containers that do not inherit the host environment, with
no-new-privileges, resource limits, read-only bind mounts by default, signature verification for itsmcp/images and secret scanning of arguments and responses; its documentation notes that network egress “is not globally denied by default,” so set--block-networkor per-server host allowlists explicitly (Docker MCP Gateway). - Lock down local HTTP servers. A server listening on a local port can be reached from web pages in the user’s browser. MCP Inspector (CVE-2025-49596) and, in October 2026, the reference
server-everythingserver, which bound to all interfaces with wildcard CORS and offered a tool that returned the entire process environment, both failed this way (GitHub advisory). Bind to127.0.0.1, validate theOriginandHostheaders, require a token, or use stdio. The CSA’s November note lists DNS rebinding and cross-site POSTs against localhost servers as one of three recurring classes of SDK advisory.
Our post Your Sandbox Is Adorable discusses where sandboxes for agents tend to fall short, and the drift post gives configurations for several sandboxing options.
7. Treat tool descriptions and tool results as untrusted input
Everything a server returns, including its tool list, enters the model’s context, and the model cannot reliably separate instructions from data. Invariant Labs demonstrated in April 2025 that a tool description could direct an agent to read ~/.ssh/id_rsa and pass it as a tool argument, and that one server’s description could redirect the use of another server’s tools (Invariant Labs). Tool results carry the same risk: a GitHub issue, a Jira ticket, a web page or a database row can contain instructions.
On episode 100 of our podcast, Xia Hua, co-founder and CEO of Traceforce, used her company’s open-source scanner to show a prompt injection finding in one of the most widely installed servers.
“For example, Playwright is hands down one of the most popular ones.”
Xia Hua, at 13:04
The useful framing is Simon Willison’s “lethal trifecta”: an agent that combines “Access to your private data,” “Exposure to untrusted content” and “The ability to externally communicate” can be manipulated into sending that data to an attacker (Simon Willison, June 16, 2025). With MCP, the three capabilities often arrive from three different servers connected to the same session. The controls follow from that:
- Break the trifecta per session. Avoid configurations in which a server with private data, a server that reads untrusted content and a server that can send data out are all available to the same agent at the same time. Where that combination is necessary, require approval for the outbound step (practice 9).
- Do not rely on annotations or labels for security. Tool annotations such as
readOnlyHintanddestructiveHintare useful for interface design, but the maintainers’ own guidance says “Every property is a hint,” that “An untrusted server can lie,” and that for guarantees you should use “network controls or sandboxing, not a boolean hint” (MCP blog, March 16, 2026). - Isolate servers from one another. The OWASP cheat sheet recommends treating each server as an independent security domain and preventing one server’s descriptions from affecting another’s tools, typically through a proxy or gateway.
- Treat wrapping and filtering as partial measures. Supabase, after research showed its MCP server could be steered by instructions stored in database rows, added read-only and project-scoped modes, restricted tool groups and wrapped query results with warnings to the model. Its CISO wrote that the wrapping “reduced” the risk but did not eliminate it, and concluded: “Never connect AI agents directly to production data” (Supabase, September 16, 2025).
8. Validate inputs and restrict outbound requests on the server
The model chooses tool arguments, and an attacker who can influence the model can influence the arguments. Server code therefore has to validate every argument as if it came from an anonymous user on the internet. Two weakness classes account for most server-side findings:
- Command, query and path injection (MCP05). Never pass arguments into a shell, and use parameterized queries and canonicalized paths. The filesystem server’s 2025 flaws came from a path check that used a string prefix comparison, so a directory named
allow_dir_sensitive_credentialspassed a check forallow_dir(Cymulate). - Server-side request forgery. Any tool that fetches a URL, or lets the caller choose a host, can be turned against internal services and cloud metadata endpoints. CVE-2026-14540 affected the generic HTTP tool in Google’s mcp-toolbox, versions 0.3.0 through 1.4.0, whose client had no restrictive redirect policy and “lacks target IP validation” (GitHub advisory). In Grafana’s MCP server, a spoofable header turned a generic API tool into an SSRF proxy (CVE-2026-19516, CVSS 9.1) (Pillar Security).
The controls are standard, applied consistently:
- Define strict JSON Schemas for every tool, with
additionalProperties: false,patternconstraints on strings and explicit size limits. The NSA recommends validating parameters against schemas, ranges and context. - For tools that fetch URLs, use an allowlist of hosts, resolve and check the destination address against private, loopback and link-local ranges, re-check after every redirect, and pin the resolved address to defeat DNS rebinding. The OWASP cheat sheet’s rule is to never fetch “arbitrary URLs provided by the LLM without strict allowlist validation.”
- Route server egress through a proxy that enforces those rules centrally. The NSA names filtering proxies and enterprise data loss prevention for this purpose.
- Limit the size of tool results and the rate of tool calls per client.
9. Require human approval for consequential actions, and enforce it outside the model
Approval prompts are a control only if they are enforced by code the model cannot influence and shown in a form a person can evaluate. The OWASP cheat sheet recommends confirmation for destructive, financial and data-sharing operations, showing the full parameters, and states: “Never auto-approve tool calls, especially in multi-server setups.” It also recommends enforcing spending limits outside the model’s context. Invariant’s 2025 demonstrations worked in part because Cursor’s confirmation dialog did not display the full arguments.
Approval fatigue is the practical limit. People who are asked to approve every call stop reading the prompts, which is the subject of our post The Human in the Loop Is Going Away. The better design reserves approval for a short list of consequential actions (writes to production, payments, sending data outside the company, deleting anything, changing permissions) and makes everything else safe by construction through read-only credentials and sandboxing. Are You Actually Going to Give the Agent Write Access? discusses how to make that decision for each system.
10. Log every tool call in a form you can investigate
Lack of audit and telemetry is MCP08 in the OWASP list, and both the NSA and OWASP recommend logging every tool invocation with its parameters, the identity behind it and a timestamp, and sending the logs to your SIEM. A useful MCP log answers four questions within minutes: which agent or user called which tool on which server, with what arguments, using which credential, and what came back.
OpenTelemetry’s semantic conventions for MCP, still marked as in development, give a common schema: spans named for the method and target, a required mcp.method.name attribute, gen_ai.tool.name for tool calls, error.type set to tool_error when a tool reports failure, and opt-in attributes for tool arguments and results (OpenTelemetry). Claude Code, for example, includes MCP server and tool names in its OpenTelemetry tool events when OTEL_LOG_TOOL_DETAILS=1 is set (Claude Code docs).
Redact secrets and personal data before logs leave the host, and alert on the events that matter most: a new server appearing in any configuration, a tool definition changing, a tool call that fails authorization, and unusual volumes of calls from one agent.
11. Track advisories, and patch MCP SDKs and servers promptly
The MCP ecosystem now produces security advisories at the pace of a mature framework. The Cloud Security Alliance counted a series of high-severity advisories in the official SDKs between December 2025 and October 2026 that share one root cause, trusting an unverified signal about who a party is, across three classes: browser-reachable localhost servers, OAuth issuers that were not bound, and messages routed to the wrong client. Its recommended baseline is at least @modelcontextprotocol/sdk 1.32.0 for TypeScript, mcp 1.30.0 or 2.2.0 for Python, and go-sdk 1.4.1 for Go (CSA, November 9, 2026).
Three details from recent advisories show why patching needs a person reading the advisory, not only a version bump:
- Upgrading may not be enough. FastMCP’s fix requires you to set a new
issuerparameter and rotate exposed secrets. - Version ordering can hide the fix. The
server-everythingadvisory warns that the patched 2.0.1 sorts below the earlier date-based versions, so package managers will not offer it as an upgrade. - Some fixes ship without an advisory. OpenCode fixed its sign-in flaw in version 1.18.33 as a refactor and did not request a CVE, because its policy treats user-configured MCP servers as outside its trust boundary (The Hacker News, October 2026).
Subscribe to the GitHub security advisories for the SDKs and servers you run, include MCP packages in your software composition analysis, and treat MCP-related entries in CISA’s Known Exploited Vulnerabilities catalog as emergency changes.
12. Centralize enforcement in a gateway once you run MCP in production
Managed client configuration works for a team of engineers using a handful of vetted servers. When MCP becomes part of your product, or when many users and agents share servers that touch sensitive data, the controls above are easier to enforce in one place. The Coalition for Secure AI’s MCP Security framework, version 2.0, defines four cumulative assurance levels, Sandbox, Internal, Production and Regulated, across eight control dimensions, and recommends that at the Production and Regulated levels enforcement be centralized in a gateway that performs token validation, policy evaluation, workload identity exchange and audit logging (CoSAI, September 25, 2026).
The 2026-07-28 specification makes gateways more practical. With sessions removed and the method and tool name carried in the Mcp-Method and Mcp-Name headers, a gateway or web application firewall can route and filter requests without parsing the JSON-RPC body or keeping session affinity. Options include Docker’s MCP Gateway, Cloudflare’s MCP server portals, which centralize multiple MCP servers “onto a single HTTP endpoint,” Amazon Bedrock AgentCore Gateway and a number of open-source and commercial gateways. Evaluate any of them against the same practices: does it validate audiences, refuse passthrough, isolate servers from one another, block secrets in arguments and responses, and log every call?
A gateway is also a single point of failure and a high-value target. LiteLLM’s gateway is the example: one authentication bug exposed every server behind it, and attackers exploited it (Wiz). Give the gateway the same scrutiny as your identity provider.
Additional requirements for teams that build MCP servers
If your company publishes an MCP server, for customers or for internal use, the practices above apply to your users. The following apply to you.
- Authenticate every request and validate the audience. Implement Protected Resource Metadata, accept only tokens issued for your server, return
401for invalid tokens and403withinsufficient_scopewhen more scope is needed, and never forward the client’s token. - Do not treat state handles as authentication. The 2026-07-28 specification replaces sessions with explicit handles that a tool returns and the model passes back. Its best practices state that servers must not treat possession of a handle as authentication, and should generate handles that cannot be guessed and bind them server-side to the authenticated user. Grafana’s session spoofing is the cautionary example.
- Isolate tenants and clients. Asana’s June 2025 incident was a tenant isolation failure in a multi-tenant MCP server. The CSA’s November note also describes SDK flaws in which shared server or transport instances routed one client’s messages to another; refactor to per-request or per-session instances.
- Scope your own upstream access. Offer read-only and resource-scoped modes, as Supabase did, and make the restrictive mode the default.
- Keep tool descriptions accurate and stable. Changes to descriptions and schemas trigger re-review at well-run customers. Version them, publish a changelog and avoid unnecessary edits.
- Validate inputs and restrict egress as described in practice 8, and test with adversarial inputs. A penetration test of an MCP server should include prompt injection through tool results, SSRF through every URL-accepting tool, authorization bypass and cross-tenant access.
- Publish a security policy that covers MCP. State whether you treat malicious servers or malicious clients as in scope, how to report vulnerabilities and how you will announce fixes. The OpenCode case shows the cost of leaving users to discover a fix in release notes.
Mapping the practices to OWASP, the NSA and CoSAI
Enterprise buyers and auditors increasingly reference these three documents. The table shows where each practice in this guide corresponds.
| Practice | OWASP MCP Top 10 | NSA CSI recommendation (May 2026) | CoSAI v2.0 control dimension |
|---|---|---|---|
| 1. Inventory | MCP09 | Track and patch vulnerabilities; scan the local network | Supply chain and lifecycle |
| 2. Allowlist | MCP09, MCP04 | Choose supported MCP projects | Supply chain and lifecycle |
| 3. Pin and verify | MCP03, MCP04 | Choose supported MCP projects | Tool, input and output integrity |
| 4. Authorization specification | MCP07 | Design for boundaries; sign and verify messages | Identity and authentication |
| 5. No passthrough, scoped credentials | MCP01, MCP02 | Design for boundaries | Authorization and delegation |
| 6. Sandbox local servers | MCP05 | Constrain and sandbox tool execution | Isolation and sandboxing |
| 7. Untrusted context | MCP03, MCP06, MCP10 | Filter and monitor output pipelines | Tool, input and output integrity |
| 8. Input and egress validation | MCP05 | Validate parameters; design for boundaries | Transport and network security |
| 9. Human approval | MCP02 | (Discussed as a concern: poor approval workflows) | Authorization and delegation |
| 10. Logging | MCP08 | Instrument for logging and detection | Logging and observability |
| 11. Patching | MCP04 | Track and patch MCP-related vulnerabilities | Supply chain and lifecycle |
| 12. Gateway | MCP07, MCP08 | Design for boundaries | State and discovery security; identity and authentication |
Sources: OWASP MCP Top 10, NSA Cybersecurity Information Sheet, May 2026 and press release, CoSAI MCP Security v2.0. The mapping is ours.
The NSA document, titled Model Context Protocol (MCP): Security Design Considerations for AI-Driven Automation, was published on May 20, 2026 by the agency’s Artificial Intelligence Security Center, whose announcement states that “Adopters are advised to proceed with caution.” It is written for National Security Systems and the Defense Industrial Base but is cleared for broad sharing, and defense-sector buyers are likely to use it as a checklist.
For companies with a SOC 2 report, the same controls produce evidence for existing criteria: the inventory and allowlist support logical access controls (CC6.1), logging and alerting support system monitoring (CC7.2), and pinning with reviewed updates supports change management (CC8.1). Adding MCP servers to the system description and the vendor inventory is usually the first change an auditor will ask about.
A 30-day implementation plan
Most startups can put the core of this program in place in four weeks without slowing engineering, provided each week ends with something concrete.
Week 1: Inventory. Collect MCP configuration from every developer machine and repository, list the servers your product runs or calls, record SDK versions from your lockfiles, and scan internal networks for exposed MCP endpoints. Assign an owner to every server and record the credential each one holds. Output: an inventory spreadsheet.
Week 2: Restrict. Decide which servers are approved, remove the rest, and deploy managed configuration that enforces the allowlist by command or URL. Pin every version and image digest. Replace shared or broad tokens with one read-only credential per server, stored in a credential store. Output: the managed configuration and a credential register.
Week 3: Contain. Move local servers into containers or operating system sandboxes with network and file access denied by default. Bind any local HTTP server to 127.0.0.1 with authentication. Identify the tools that write, send or delete, and require approval for them. Output: the sandbox policy and the approval list.
Week 4: Observe. Turn on tool-call logging with OpenTelemetry and forward it to your SIEM. Add alerts for new servers, changed tool definitions and authorization failures. Subscribe to advisories for every SDK and server in the inventory, and set up a lightweight review process for new server requests. Output: dashboards, alerts and a documented review process.
After the first month, the work becomes maintenance: reviewing new servers, applying updates through pull requests, and re-running the inventory each quarter.
What enterprise buyers ask about MCP
Security questionnaires from larger customers now include MCP-specific questions, particularly for AI products and developer tools. Expect versions of the following:
- Which MCP servers does your product use or expose, and who maintains each one?
- How are server versions controlled, and how would you detect a change to an approved server’s tools?
- How do your MCP servers authenticate clients, and do they validate token audience?
- What can each server’s credential access, and is that access read-only?
- Where do local servers run, and what network and file access do they have?
- Which agent actions require human approval?
- Are tool calls logged, for how long, and can you produce the log for a given customer’s data?
The inventory, managed configuration, credential register, sandbox policy and logs from the 30-day plan answer each of these directly. Our posts on the five questionnaire questions your first enterprise buyer will ask about AI agents and the AI security questions buyers will ask in 2027 cover the wider set, and Shadow AI covers the governance around tools employees adopt on their own.
Where YSecurity can help
Our Secure MCP Program puts the practices in this guide into place: an inventory of every agent and MCP server with the credentials each holds, an enforced allowlist with pinning, scoped and short-lived credentials, sandboxed execution, approval gates on destructive actions, and logging with an incident playbook for agent misbehavior. AI Access Control Audits review what every agent and server can reach. For teams that build MCP servers or AI products, AI Red Teaming and penetration testing test for prompt injection through tool results, SSRF, authorization bypass and cross-tenant access, and Secure AI SDLC builds those checks into development.
When a buyer’s questionnaire arrives before the program is finished, Sales Support helps you answer accurately, including what is in place and what is planned. We bill in 15-minute increments with no retainers.
Summary
MCP security is not a new discipline so much as established practice applied to a new layer: know what runs, allow only what you have reviewed, authenticate and validate tokens properly, give every component the least privilege it needs, isolate what you cannot fully trust, and log enough to reconstruct what happened. The protocol-specific element is that the model reads everything the servers return, so containment has to come from permissions and isolation rather than from the model’s judgment. The specification, the OWASP MCP Top 10, the NSA’s guidance and the CoSAI framework now agree on most of the controls, which makes this a good time to adopt them, before an enterprise buyer or an incident sets the schedule.
MCP security best practices, frequently asked questions
- What is MCP security?
- MCP security is the set of controls that govern how AI applications connect to tools and data through the Model Context Protocol. It covers which MCP servers a client may connect to and at which versions, how remote servers authenticate clients and validate tokens, what credentials each server holds, how local servers are isolated from the host, how tool descriptions and tool results are treated before they reach the model, which actions require human approval, and how every tool call is logged.
- What are the most important MCP security best practices?
- Keep an inventory of every MCP server and client in use; enforce an allowlist of approved servers in managed client configuration; pin server versions and verify tool definitions; implement the MCP authorization specification for remote servers, including PKCE, resource indicators and audience validation; never pass tokens through to upstream APIs; give each server its own narrowly scoped credential; sandbox local servers; treat tool descriptions and results as untrusted input; validate inputs and restrict outbound requests on the server; require approval for consequential actions; log every tool call; and patch MCP SDKs promptly.
- What is the OWASP MCP Top 10?
- The OWASP MCP Top 10 is an OWASP project, led by Vandana Verma Sehgal and currently released as a beta, that lists the ten most significant security risks in Model Context Protocol deployments. The 2025 entries are MCP01 Token Mismanagement and Secret Exposure, MCP02 Privilege Escalation via Scope Creep, MCP03 Tool Poisoning, MCP04 Software Supply Chain Attacks and Dependency Tampering, MCP05 Command Injection and Execution, MCP06 Prompt Injection via Contextual Payloads, MCP07 Insufficient Authentication and Authorization, MCP08 Lack of Audit and Telemetry, MCP09 Shadow MCP Servers, and MCP10 Context Injection and Over-Sharing.
- Is the MCP stdio transport secure?
- The stdio transport launches a local server by executing the command written in the client's configuration, with the permissions of the user who runs the client. It does not restrict what that command can do. In April 2026 OX Security showed that an attacker who can influence that configuration, through an exposed configuration interface, a malicious registry listing or a prompt injection that edits a configuration file, can run arbitrary commands. Anthropic described the behavior as expected. The practical position is that stdio is acceptable for vetted, pinned servers whose launch commands come from a reviewed allowlist, run inside a sandbox, and that no untrusted input should be able to write MCP configuration.
- How does authorization work in MCP?
- For remote servers on HTTP transports, the MCP authorization specification builds on OAuth 2.1. The server publishes Protected Resource Metadata (RFC 9728) that names its authorization server. The client identifies itself, preferably with a Client ID Metadata Document, runs an authorization code flow with PKCE using S256, and includes a resource parameter (RFC 8707) that names the MCP server. The 2026-07-28 revision requires the client to validate the issuer in the authorization response when the server supports RFC 9207. The client sends the access token in the Authorization header on every request, and the server must reject any token that was not issued for it.
- What is token passthrough in MCP, and why is it prohibited?
- Token passthrough is when an MCP server accepts a token from the client and forwards it unchanged to an upstream API, or accepts a token that was issued for some other service. The MCP specification states that servers must not accept tokens that were not explicitly issued for them and must not pass the client's token through. Passthrough bypasses the server's own authorization checks, breaks audit trails because the upstream service cannot tell who is acting, and lets a token stolen from one service be replayed against another.
- What is MCP tool poisoning?
- Tool poisoning is an attack in which instructions are hidden in an MCP tool's description, parameter schema or output, where the model reads them but the user usually does not. Invariant Labs described it in April 2025, along with two variants: shadowing, in which one server's tool description changes how the agent uses another server's tools, and the rug pull, in which a server changes its tool definitions after a user has approved it. Defenses include pinning and hashing tool definitions, reviewing the full schema rather than only the description, isolating servers from one another and treating every tool result as untrusted data.
- Do we need an MCP gateway?
- A small team with a handful of vetted servers can enforce most controls in managed client configuration. A gateway becomes worthwhile when many users or agents share servers, when servers run in production with sensitive data, or when you need one place to validate tokens, apply policy, block secrets in arguments and responses, and log every call. The Coalition for Secure AI's MCP Security framework recommends centralized enforcement in a gateway at its Production and Regulated assurance levels.
- How should a startup start with MCP security?
- Start with an inventory: read every MCP configuration file on developer machines and in your product, list the servers, their versions, their owners and the credentials they hold, and scan your network for exposed MCP endpoints. Then enforce an allowlist through managed configuration, pin versions and give each server its own read-only credential. Sandbox local servers, require approval before any write action, and turn on tool-call logging. Most startups can complete those steps in about 30 days.
