Nexus Void AI Research

MCP, Model Context Protocol, MCP Server Security, AI Agent Security, Prompt Injection, Tool Poisoning, OAuth, How-to

MCP Security: Risks and How to Secure an MCP Server (2026)

MCP security explained: tool poisoning, rogue servers and token risks, plus a step-by-step guide and checklist to secure an MCP server you build.

MCP security is protecting AI agents that use the Model Context Protocol (MCP), the open standard for connecting models like Claude to external tools and data, from attacks that abuse those connections. The main risks are tool poisoning, prompt injection through tool results, rogue or compromised MCP servers, over-broad permissions and leaked tokens. To secure an MCP server, authenticate every client, validate that tokens were issued to your server, expose narrow tools with strict input schemas, treat everything you return as untrusted, and run with least privilege.

Last updated 20 November 2026.

MCP is now the default way coding agents like Claude Code, Cursor and Amazon Kiro reach the outside world, so its security has moved from niche to essential. Introduced by Anthropic and widely adopted, MCP lets an agent discover and call tools exposed by MCP servers, each described in natural language so the model knows when to use it. That natural-language trust is the crux: the channel that tells the agent what a tool does can also carry instructions the agent obeys, which is why MCP inherits the whole family of prompt injection problems. For the wider picture of agent risks, see the security risks of Claude Code, Cursor and Codex.

This page covers both sides: the risks of using MCP, and a step-by-step guide to securing an MCP server you build.

What are the main MCP security risks?

The risks cluster around trust: the agent trusts tool descriptions, tool results and the servers themselves.

Risk

What it means

Real example

Tool poisoning

Malicious instructions hidden in a tool's description or metadata

Instructions split across a description and a result so the agent stitches them together

Prompt injection via results

A tool returns attacker-controlled text the agent then acts on

A hidden pull request comment hijacking an agent through Azure DevOps MCP

Rogue or compromised servers

A malicious server, or a trusted one updated to add hidden behavior

GhostSplice malicious MCP servers exfiltrating agent data

Malicious workspace config

A repository that ships MCP configuration the agent loads automatically

Amazon Kiro exfiltrating local data from a crafted workspace

Excessive permissions

An agent or token granted far more access than the task needs

Broad scopes like files:* or admin:* granted up front

Token passthrough

A server forwarding client tokens to downstream APIs without validating them

Breaks audit trails and lets stolen tokens be reused

Malicious packages

An agent installing a typosquatted or hallucinated package through a tool

Slopsquatting attacks on AI coding agents

What does the MCP specification say about security?

The official MCP security best practices document names the attacks implementers must defend against, including:

  • Confused deputy: MCP proxy servers that use a static OAuth client ID can be tricked into handing authorization codes to an attacker. Servers must get per-client consent.

  • Token passthrough: explicitly forbidden. MCP servers must not accept tokens that were not issued to them.

  • Server-side request forgery (SSRF): a malicious server can point a client at internal addresses such as cloud metadata endpoints. Clients should block private IP ranges.

  • Local MCP server compromise: a one-click server install can run arbitrary commands. Clients must show the exact command and get consent, and should sandbox servers.

  • Scope minimization: start with minimal scopes and step up only when needed.

How do you use MCP safely with coding agents?

For teams using MCP with coding agents:

  • Connect only servers you have reviewed. Treat every MCP server like a dependency: know who maintains it and pin the version.

  • Least privilege. Give each server and token only the tools, directories and scopes the task needs; never a production database or cloud admin role.

  • Treat tool output as untrusted input. Content a tool returns (web pages, issues, PR comments, documents) can contain instructions.

  • Require approval for high-impact actions: writing files outside the project, running shell commands, sending data externally, installing packages.

  • Sandbox local servers. Run them with restricted file system and network access, and review the exact launch command.

  • Review workspace MCP config. Check .mcp.json and similar files in any repository you open before your agent loads them.

  • Keep secrets out of reach. Do not let agents read .env files or credential stores they do not need.

  • Check packages before install. Hallucinated package names are a known attack path (research on package hallucination); see how to detect malicious npm packages.

  • Log and review what agents do, especially tool calls that touch secrets or the network.

The OWASP Top 10 for LLM applications and the NIST AI Risk Management Framework cover the broader risk classes.

How do you secure an MCP server? Step by step

If you are building an MCP server, these steps follow the specification's requirements and the general rules of API security.

Step 1: Pick the right transport and bind it safely

  • stdio servers run as a local process launched by the client. They inherit the user's permissions, so keep them small, read credentials from environment variables rather than files in the project, and document exactly what they can access.

  • Streamable HTTP servers are network services. The specification requires them to validate the Origin header to prevent DNS rebinding attacks, and local servers should bind to 127.0.0.1 rather than all interfaces.

  • Use TLS for any remote server.

Step 2: Authenticate every client

For HTTP servers, the MCP authorization specification builds on OAuth 2.1: the MCP server acts as an OAuth resource server and publishes protected resource metadata so clients can discover the authorization server. In practice:

  • Require a valid access token on every request; never run a remote server unauthenticated.

  • Validate the audience: accept only tokens issued specifically for your server. Clients use resource indicators so tokens are bound to the intended server.

  • Never pass the client's token through to downstream APIs. If your server calls other APIs, obtain its own tokens for them.

  • Get per-client consent if your server proxies to a third-party authorization server.

  • Keep scopes minimal and request more only when a tool needs them.

See how to secure API endpoints for the general API controls that apply.

Step 3: Design narrow tools with strict schemas

The safest tool does one thing:

  • Prefer specific tools (get_invoice(invoice_id)) over general ones (run_sql(query), run_shell(cmd), fetch_url(url)).

  • Define a strict input schema for every tool, with types, lengths, enums and patterns, and validate on the server; never trust that the model sent valid arguments.

  • Authorize per call: check that the authenticated user may access the specific record the tool touches, exactly as in any API. Missing checks here are IDOR.

  • Separate read and write tools, and mark tools with side effects so clients can ask the user for confirmation.

  • Write short, factual tool descriptions. Do not include instructions to the model beyond what the tool does.

Step 4: Treat everything you return as untrusted

  • Label untrusted content returned from web pages, documents, tickets or emails as data, and keep it out of tool descriptions.

  • Return only the fields the task needs, not whole records, to limit what an injected instruction could exfiltrate.

  • Never return secrets, tokens or internal configuration in tool results.

Step 5: Block SSRF and command injection

  • If a tool fetches URLs, allow-list hosts, block private, loopback and cloud metadata addresses after DNS resolution, and re-check redirects; see how to prevent SSRF.

  • Never build shell commands or SQL from tool arguments; use parameterised APIs; see how to prevent SQL injection.

Step 6: Limit, log and update

  • Rate-limit tool calls per client and cap result sizes and execution time.

  • Log every tool call with the client, user, tool, arguments (redacted) and result status, so you can investigate misuse.

  • Pin and scan your dependencies, sign releases, and publish a changelog so users can see when tool behaviour changes.

MCP server security checklist

Check

Done when

Transport safe

Origin validated; local servers bound to localhost; TLS for remote

Authenticated

Every request needs a valid token issued for this server

No token passthrough

Downstream calls use the server's own credentials

Minimal scopes

Scopes match the tools; step-up when needed

Narrow tools

No general shell, SQL or fetch tools without strict limits

Strict schemas

Every argument validated server-side

Per-call authorization

Tools check access to the specific record

Untrusted output labelled

Third-party content marked as data; minimal fields returned

SSRF and injection blocked

URL validation; parameterised queries and commands

Limits and logs

Rate limits, size caps, tool-call audit log

How does ARGUS use MCP safely?

ARGUS exposes its own checks over MCP so coding agents can use them as a guardrail, and is built to follow the rules above.

  1. Authenticated, scoped access. The ARGUS MCP server uses Streamable HTTP with a bearer API key. Keys are scoped (read, scan, triage or full) and can be narrowed further, so an agent that only needs to check its own changes gets only that. No key scope can delete projects or change settings, members, billing or keys. Read tools require project membership, and write tools require the matching permission.

  2. Pre-install package checks. Before an agent installs a package, it can call scan_package with the name, ecosystem and version and get an allow, warn or block verdict with reasons: known vulnerabilities, malicious-package advisories, typosquats and lookalikes, and whether the package actually exists, which catches names an agent hallucinated. It covers npm, PyPI, Maven, Go, crates.io, RubyGems, NuGet and Packagist.

  3. Diff checks before commit. scan_diff runs full static analysis on the changed files, secret detection, and dependency checks on any changed manifest, so an agent can check its own changes. It fails closed: anything it cannot read is reported as a blocking finding marked incomplete, never as a clean result.

  4. Narrow tools. Twelve purpose-built tools, such as explain_finding, get_fix and check_reachability, rather than general shell or database access, with a rate limit of 30 calls per organisation per minute on the scanning tools.

  5. Pull request review. ARGUS also reviews every pull request the agent opens, so a risky change can wait behind a required check.

Documented clients include Claude Code, Cursor and GitHub Copilot in VS Code. See where ARGUS fits in an AI coding workflow, or scan a repository free.

To test MCP servers and the agents that call them as an attacker would, Nexus Void AI also runs VAPT on web applications, APIs and AI-built apps, with every finding scored and retested after you fix it. Get a VAPT quote.

Frequently asked questions

Is MCP itself insecure?

No. MCP is a protocol with a published security model. The risks come from how agents trust tools, from malicious or over-permissioned servers, and from implementations that skip the specification's requirements, such as token validation and Origin checks.

What is tool poisoning?

Tool poisoning is hiding malicious instructions in an MCP tool's description or metadata so the agent is influenced before or during tool use. It is a form of indirect prompt injection, and it is why you should review and pin the MCP servers you connect.

How do I secure an MCP server?

Authenticate every client and accept only tokens issued for your server, never pass tokens through, keep scopes minimal, validate the Origin header and bind local servers to localhost, expose narrow tools with strict input schemas and per-call authorization, treat returned content as untrusted, block SSRF and injection, and rate-limit and log tool calls.

How does MCP authentication work?

For HTTP transports, the MCP authorization specification uses OAuth 2.1. The MCP server is an OAuth resource server that publishes metadata pointing to its authorization server; clients obtain access tokens bound to that specific server, and the server must validate that each token was issued for it. stdio servers usually read credentials from the environment.

Are local MCP servers safe?

Only as safe as the code they run and the permissions they have. A local stdio server runs with your user's access to files, credentials and the network. Install servers only from sources you trust, review the exact launch command, pin versions and sandbox them where possible.

What is token passthrough in MCP?

Token passthrough is when an MCP server accepts a token from the client and forwards it to a downstream API without checking that the token was issued for the server. The specification forbids it, because it bypasses controls, breaks audit trails and lets stolen tokens be reused.

How do I stop an MCP server from being used for SSRF?

If a tool fetches URLs, allow-list hosts and schemes, resolve hostnames and block private, loopback, link-local and cloud metadata addresses, connect to the validated IP, and re-check redirects. Prefer tools that call specific APIs over general URL-fetch tools.

Do MCP attacks get CVEs?

Sometimes, when a specific client or server has a bug. Many MCP attacks are design-level abuses of trust rather than software bugs, so they carry no CVE and will not appear in vulnerability feeds, which is why configuration review and least privilege matter.

Our read

MCP is the connective tissue of the agent era, and its security reduces to one hard truth: an agent trusts the tools you connect as much as it trusts you. That makes choosing servers and scoping permissions security decisions, not configuration details. If you build servers, treat each tool like a public API endpoint with an unpredictable caller. If you use them, connect deliberately, scope tightly, and check what a poisoned tool could reach before an agent touches real secrets.

Related reading: How to prevent prompt injection · AI agent security in 2026 · Vibe coding security checklist

DATA SOURCES

MCP security best practices: https://modelcontextprotocol.io/specification/draft/basic/security_best_practices ; OWASP Top 10 for LLM Applications: https://genai.owasp.org/llm-top-10/ ; NIST AI RMF: https://www.nist.gov/itl/ai-risk-management-framework

Liked this post? Share it:

Related posts