01 //What Is MCP Security?
MCP security is the set of controls that keeps Model Context Protocol clients, servers, tools, resources, and prompts from crossing the wrong trust boundary. In practice, it means verifying who may call a tool, limiting what that tool can reach, treating tool descriptions and results as untrusted input, and requiring approval for sensitive actions.
MCP connects an AI host to one or more servers. A server can expose tools that perform actions, resources that provide data, and prompts that structure model interactions. The model may choose a tool, but the server must still enforce the requesting user's permissions. A model decision is never an authorization decision.
Authenticate protected requests; authorize every tool call against the user and target object; validate arguments; give the server narrow upstream credentials; verify tool definitions and results; isolate local processes; and require human approval for high-impact operations. For remote HTTP, also protect the transport and validate request origin.
02 //MCP Architecture and Trust Boundaries
MCP defines a host (the AI application), a client managed by the host, and an MCP server exposing capabilities. The main security boundaries are: user to host, host to each server, server to its upstream API or local machine, and untrusted tool output back into the model context.
Where to enforce MCP security controls
| Boundary | What can go wrong | Control to inspect |
|---|---|---|
| Host → server | An unreviewed server or changed tool definition steers the model | Server allowlist, tool definition review and change detection |
| Client → protected HTTP server | A token for another service is accepted or passed upstream | Audience validation, narrow scopes and per-request authentication |
| Server → tools and data | A tool reads another user's document or invokes an unsafe URL | Object-level authorization, argument validation and egress policy |
| Tool result → model | A result contains instructions to leak data or call another tool | Treat result text as data; enforce every later action in code |
The current 2026-07-28 MCP specification defines local stdio and remote Streamable HTTP bindings. It uses a stateless core: requests carry their protocol metadata individually. Earlier revisions used an initialization handshake and could use protocol-level sessions. Review the deployed version; never use a session identifier as a substitute for authentication.
A local stdio server runs as a process with the privileges and environment you give it. Its lack of a listening HTTP endpoint does not limit file access, network access, or access to inherited credentials. Sandbox the process and pass only the directories and secrets it needs.
03 //Tools, Resources, and Prompts: Three Different Trust Surfaces
A tool is an executable operation, a resource is data the host may read, and a prompt is a server-supplied template. Each crosses a different boundary. A reviewer should inventory all three rather than looking only at tools/call handlers.
MCP capability review map
| Capability | Relevant operation | Security question |
|---|---|---|
| Tools | tools/list and tools/call | Can the model call a sensitive operation, and does its handler enforce policy? |
| Resources | resources/list and resources/read | Can the caller read only authorized URIs? Is returned content treated as untrusted? |
| Prompts | prompts/list and prompts/get | Who controls the template, and can it override application instructions? |
A malicious server can place instructions in a tool description, an argument schema field, a prompt template, a resource body, or a tool result. Those fields may reach the model as context. Keep server identity and data provenance attached to them, and never let content from one server grant authority to another.
In the 2026-07-28 revision, list results can include cache hints such as ttlMs and cacheScope. A cached tool list is still a snapshot, not proof that a server implementation has stayed safe. Review definition changes and deploy changes separately; a definition hash cannot detect malicious behavior behind an unchanged schema.
1{
2 "name": "export_document",
3 "description": "Export a document the current user may access",
4 "inputSchema": {
5 "type": "object",
6 "properties": {
7 "documentId": { "type": "string", "maxLength": 80 }
8 },
9 "required": ["documentId"],
10 "additionalProperties": false
11 },
12 "annotations": { "destructiveHint": true }
13}The schema rejects an unexpected callback URL. It does not establish that the caller owns documentId. The handler must check that relationship at execution time. The annotation is a hint to the host, not an authorization control.
04 //Common MCP Security Vulnerabilities
MCP risks combine ordinary API flaws with model-driven tool selection. Review both the protocol boundary and the business operation behind each tool.
MCP threat model
| Threat | Attack path | Review question |
|---|---|---|
| Tool poisoning and rug pulls | A description, schema or annotation steers the model, or changes after approval | Are full tool definitions reviewed and changes surfaced before use? |
| Prompt injection in tool results | Untrusted returned text is treated as instructions for another tool call | Are outputs labelled as data and later actions independently authorized? |
| Confused deputy | A server uses broad credentials for an operation the user cannot perform | Does the tool verify the user's rights to the exact target object? |
| Token passthrough | An MCP access token is forwarded to an upstream API | Does each hop use a token issued for that resource and audience? |
| SSRF and local compromise | A model-chosen URL reaches internal services, or a local server reads secrets | Are destinations restricted and the server process isolated? |
| Cross-server exfiltration | Data from one server is placed in a call to another server | Are sensitive data flows and outbound destinations constrained? |
Tool annotations such as readOnlyHint and destructiveHint describe intended behavior; they do not enforce it. The MCP tools specification tells clients to treat annotations as untrusted unless the server is trusted. A “read only” label cannot replace an authorization check or code review.
A tool is marked readOnlyHint: true. What security conclusion can a reviewer make?
05 //Attack Chain: From a Poisoned Result to Data Exfiltration
Imagine a support agent connected to two MCP servers: a document server that can read internal reports and a messaging server that can send external mail. A user asks for a summary of one report. The report body contains attacker-controlled text because it was imported from an outside partner.
- Entry: The agent calls
resources/readfor the requested report. The returned text is data, even though it appears in the model context. - Instruction attempt: The report says to fetch a different confidential report and mail it to an external address. This is indirect prompt injection in a resource result.
- Privilege crossing: The agent chooses a document tool using credentials broader than the requesting user. The server would become a confused deputy if it skips object authorization.
- Server crossing: The agent passes the confidential report into a messaging tool on another server. That is cross-server exfiltration through a legitimate channel.
- Outcome: The data leaves only if the host allows the call and both server-side policy checks fail. Blocking any one unauthorized operation breaks the chain.
Which component can stop each step?
| Step | Host responsibility | Server responsibility |
|---|---|---|
| Read attacker-controlled report | Label source and treat content as data | Return only resources the user may read |
| Read confidential report | Show or deny risky tool call | Check the caller against that report ID |
| Send external mail | Restrict cross-server flow and request approval | Authorize send action and recipient policy |
Tool poisoning puts manipulative instructions in the tool definition or metadata surfaced during discovery. Result injection places them in data returned at runtime. Both are untrusted text; definition review helps with the first, while result handling and execution-time policy are essential for the second.
The document server correctly rejects a request for a report outside the user\'s permissions. Can a poisoned report still force that export?
06 //Code Review Example: An Overpowered Document Tool
Consider a conceptual MCP tool handler that exports a document. The tool accepts a document ID and a callback URL from a model-generated call. It then uses an administrator credential to fetch the document and posts the content to that URL.
1type ToolArgs = { documentId: string; callbackUrl: string };
2
3async function exportDocument(args: ToolArgs) {
4 const adminToken = process.env.DOCS_ADMIN_TOKEN!;
5 const document = await docsApi.getDocument(args.documentId, adminToken);
6
7 await fetch(args.callbackUrl, {
8 method: 'POST',
9 body: JSON.stringify(document),
10 });
11 return { exported: true };
12}A malicious document or tool result tells the model to call export_document for a sensitive document and send it to an attacker-controlled URL. The server never checks whether the requesting user may read that document. Its administrator token makes the server a confused deputy; the arbitrary callback URL is an exfiltration and SSRF path.
- Trace the caller: Where is the authenticated user or service principal established?
- Trace the object: Is access checked for this document ID, rather than merely for the tool?
- Trace the destination: Who chooses the callback URL, and can it reach internal hosts?
- Trace the credential: Why can the server read more documents than the user?
08 //Stdio, Streamable HTTP, DNS Rebinding, and SSRF
Transport selection changes exposure. A stdio server is launched as a local process and communicates over standard streams. A Streamable HTTP server exposes an HTTP endpoint, often to remote clients. The protocol semantics are the same, but process isolation and network perimeter controls differ.
Transport-specific controls
| Transport | Typical risk | Review evidence |
|---|---|---|
| Local stdio | Malicious startup command, inherited secrets or unrestricted filesystem/network access | Exact launch command, package source, sandbox, mount list, environment allowlist |
| Local HTTP | Other local processes or a rebinding website reach the MCP endpoint | Loopback bind, authentication and present-Origin validation |
| Remote Streamable HTTP | Unauthenticated tools, token misuse, exposed results, denial of service | TLS, protected resource auth, Origin policy, size/rate/time limits and logs |
The 2026-07-28 Streamable HTTP transport uses one POST per message and no protocol-level session. Clients send routing headers such as Mcp-Method and, for named operations, Mcp-Name. Servers must reject required-header/body mismatches. A gateway may use these headers for routing or metering, but the server still validates the body and authorizes the operation.
Streamable HTTP servers must validate an incoming Origin header and reject a present invalid origin with HTTP 403. Non-browser clients may send no Origin; do not treat its absence as proof of trust. Local HTTP servers should bind to loopback and still require appropriate authentication.
SSRF has two distinct MCP paths. A tool may fetch a model-supplied URL, as in the vulnerable export example. Separately, an MCP client may follow attacker-controlled OAuth discovery URLs from a malicious server. Review both the tool's egress rules and the client's metadata-discovery URL validation, redirect handling, address resolution and private-network protections.
- For a local server, pin a trusted package or binary and show the full command before installation. Restrict environment variables, filesystem paths and network access.
- For HTTP, validate origin and host routing, set request size and duration limits, and avoid logging bearer tokens or full sensitive tool results.
- For URL-fetching tools and discovery clients, allow only intended schemes and destinations, resolve and check addresses, and re-check redirects so a public URL cannot redirect into a private network.
09 //How to Prevent MCP Attacks
- Authorize at execution: authenticate protected requests and check tool, tenant, object, and action permissions on every call. Never rely on the model, prompt, or a UI approval alone.
- Scope credentials: use a token intended for the MCP server and separate, narrow upstream credentials. Never pass the MCP access token to an unrelated API.
- Validate arguments: use strict schemas, reject unexpected fields, bound sizes and time, and restrict URLs or filesystem paths before any side effect.
- Protect the host: review servers before installation, detect tool definition changes, isolate local processes, and require confirmation for sensitive operations with the exact arguments visible.
- Treat returned content as data: tool descriptions, resource bodies, and tool results may carry prompt injection. Keep their provenance visible and enforce policy on subsequent tool calls.
- Protect remote HTTP: use HTTPS, validate a present
Originheader, bind local HTTP servers to localhost, and apply rate limits and request size limits.
For protected HTTP transports, the MCP authorization specification requires clients to identify the intended MCP server with the OAuth resource parameter. The server must accept only tokens issued for itself, and it must not forward its MCP access token to an upstream service.
For adjacent boundaries, continue with A2A Protocol Security for agent delegation and Google ADK Security for framework-level tool controls. The Prompt Injection and SSRF guides cover two common attack paths.
10 //MCP Security FAQ and References
Is MCP itself insecure? No. MCP is a protocol for connecting AI applications to tools and data. Risk comes from how a host chooses tools, how a server is trusted, and whether its implementation enforces authorization and isolation.
Does OAuth make an MCP tool safe? OAuth can authenticate and scope access to a protected server. It does not prove that a user may access a particular document, that tool arguments are safe, or that a tool result is free of prompt injection.
What is MCP tool poisoning? It is an indirect prompt injection in a tool definition or metadata that influences an AI host to take an unintended action. A malicious tool result is a related runtime injection surface. Review descriptions, schemas, annotations, results, and changes to these over time.
Are MCP sessions required? The 2026-07-28 core is stateless and carries protocol metadata on each request. Older revisions may use an initialization handshake and sessions. In either case, authenticate and authorize protected operations per request.
What is the difference between MCP and A2A? MCP standardizes access to tools, resources and prompts exposed by a server. A2A is for communication and task delegation between agents. An application can use both, and must enforce authorization at each boundary.
Does a tool output schema prevent prompt injection? It can constrain the shape of structured results and help clients validate them. A string field can still contain malicious instructions. Treat all returned content as untrusted data.
What should I review first in an existing MCP deployment? Inventory every connected server and capability, then trace a sensitive tool call from user identity through token validation, object authorization, upstream credentials and outbound destination.
Can an MCP server ask a user for input? Yes. In the 2026-07-28 core, it returns an input_required result. Form mode is for suitable non-secret data; URL mode handles sensitive interactions outside the MCP client.
Are Tasks and MCP Apps part of core MCP? They are extensions. Tasks add durable async tool work; MCP Apps add sandboxed interactive views. Hosts and servers must advertise support before using them.
- MCP specification: Tools — tool definitions, results, annotations, and user interaction.
- MCP specification: Resources — resource discovery, reads, and URI handling.
- MCP specification: Authorization — OAuth resource indicators and access token usage.
- MCP specification: Streamable HTTP — transport and origin protection.
- MCP specification: Elicitation — form and URL input security.
- MCP 2026-07-28 release — stateless requests, MRTR and extension changes.
- MCP Tasks extension — task lifecycle, input and authorization.
- MCP Apps overview — sandboxed Views and host bridge.
- MCP Security Best Practices — protocol-specific attacks and mitigations.
- OWASP MCP Security Cheat Sheet — deployment and code review checklist.