Table of contents

MCP Security: 10 Key Elements to Secure and Critical Best Practices

MCP Security: 10 Key Elements to Secure and Critical Best Practices - Blog MCP security

What is model context protocol security?

Model Context Protocol (MCP) security refers to the measures and practices that safeguard the integrity, confidentiality, and proper function of communication between large language models (LLMs) and the various tools, plugins, data sources, and APIs they interact with. As LLMs expand their capabilities through protocols like MCP, they gain the ability to execute actions in the real world, access sensitive data, and invoke third-party extensions. Ensuring the security of these interactions is critical to prevent exploitation, data leakage, and unauthorized actions originating from or directed at the model.

MCP security concerns go beyond traditional application security since models process both input prompts from users and context from tool APIs, making them susceptible to novel attacks such as prompt injection and tool output manipulation. The interconnected nature of MCPs introduces multiple trust boundaries, and any weak link can have cascading effects on security and privacy. A security approach must anticipate not only technical vulnerabilities but also the dynamic and often unpredictable behavior of LLM agents and the ecosystem they connect to.

This is part of a series of articles about AI security.

Key MCP security issues and risks

Prompt injection and tool poisoning

Prompt injection occurs when attackers craft inputs, either user-facing or hidden within external content, that manipulate the model into performing unintended actions. These inputs might appear benign but are designed to trigger specific behaviors when interpreted by the LLM. For example, an attacker could embed a hidden instruction in a document or email, which, when processed by the assistant, results in data exfiltration or system actions the user didn’t intend.

Tool poisoning is another threat. It involves manipulating MCP tool metadata, such as descriptions and parameters, to deceive the model into executing malicious actions. Because tools are often trusted by default, subtle changes in metadata can go unnoticed while still compromising system integrity.

Untrusted servers

MCP servers can be run locally or hosted in the cloud, and both forms introduce risks if the server is compromised or maliciously built. An attacker could deploy a seemingly legitimate MCP server, then later update its tools to perform harmful actions, such as accessing confidential data or rerouting sensitive information.

This also applies to server updates: If tool behavior changes silently after installation, users or agents could unknowingly trigger dangerous operations. Rogue servers can also exploit naming collisions, where deceptive tool names are used to impersonate trusted functionality.

Expanded attack surface

MCP broadens the attack surface by connecting LLMs to multiple services through APIs, tools, and data sources. Each integration becomes a new potential entry point for attackers. If any connected service is misconfigured or compromised, it could be used as a vector to manipulate the model, steal data, or trigger actions in other services.

This interconnectedness means a single vulnerability, whether in prompt handling, server logic, or tool metadata, can propagate, affecting multiple systems and services. The risk multiplies as more services are integrated into the model’s operational scope.

Lack of authorization

Improper implementation of authorization logic in MCP servers creates conditions for the “confused deputy” problem. In this scenario, an MCP server may act on behalf of a user with broader privileges than the user should have. If the server isn’t correctly verifying the user’s identity and access rights, actions could be taken using the server’s elevated privileges rather than those of the requesting user.

Although MCP uses OAuth for authorization, gaps in specification and inconsistent practices across implementations lead to vulnerabilities. Without strict enforcement of scoped access, models may invoke actions they shouldn’t be allowed to perform.

Over-permissive access

MCP tools often request broad scopes for convenience, such as full access to Gmail or Drive, even when only read permissions are needed. This over-permissiveness increases the impact of a breach, as compromised tools can access or modify large volumes of sensitive data across services.

Beyond external threats, this also enables privilege abuse by internal users or misbehaving agents, who may use excess permissions in unintended or unauthorized ways.

Supply chain risks

MCP servers and tools are composed of code and dependencies that may themselves be vulnerable. Attackers could insert malicious logic into dependencies or modify the codebase of a server component, compromising every user of that server.

To reduce these risks, MCP developers must adopt secure software development practices, including static analysis, software composition analysis, dependency verification, and signed builds. If an MCP server is deployed in the cloud, it should support cryptographic verification so clients can validate its identity.

10 key elements to secure in an MCP architecture

Securing an MCP architecture requires protecting every boundary where models, tools, users, and external systems interact. MCP introduces execution paths that combine natural language, code, and privileged APIs. Each element below represents a control point where failures can lead to unauthorized actions, data exposure, or systemic compromise.

  1. Authentication and authorization controls: MCP clients and servers must mutually authenticate and strictly validate OAuth tokens. Tokens must be audience-restricted, scoped, and issued specifically for the MCP server. Authorization decisions must be enforced server-side to prevent confused-deputy behavior and privilege escalation.
  2. Input and output validation: All inputs to the model, including user prompts and tool responses, must be treated as untrusted. Servers should inspect and sanitize inputs to detect prompt injection patterns or malformed structures. Model outputs must be validated before reuse as tool inputs or downstream context.
  3. Tool and metadata integrity: Tool definitions, descriptions, and parameters directly influence model behavior. These artifacts must be protected against tampering using signed manifests or trusted registries. Any change in tool behavior or metadata should trigger review and reauthorization.
  4. Logging, monitoring, and auditing: Every tool invocation should generate a structured audit record containing identity, scopes, parameters, and results. Logs must be tamper-resistant and centrally stored to support incident response. Continuous monitoring enables detection of anomalous or abusive patterns.
  5. Network and deployment isolation: MCP servers should operate in isolated network segments with minimal access to internal services. A compromised MCP server must not enable lateral movement. Local servers should be sandboxed with restricted filesystem, process, and network privileges.
  6. Supply chain and dependency security: MCP servers depend on third-party libraries and tools that may change over time. Dependencies should be scanned for vulnerabilities, version-pinned, and verified through signed builds. CI/CD pipelines must be protected to prevent injection of malicious code.
  7. Rate limiting and abuse prevention: MCP endpoints must enforce request limits per client, user, and tool. Rate limiting reduces the impact of automated attacks, model probing, and denial-of-service attempts. Usage thresholds must be enforced independently of model logic.
  8. Secure transport and encryption: All MCP communications must use encrypted channels such as TLS to protect data in transit. Sensitive configuration, tokens, and logs should be encrypted at rest. Key management and rotation policies limit blast radius after compromise.
  9. Continuous security testing: MCP implementations must be regularly tested using adversarial prompts, fuzzing, and penetration testing. Tests should cover prompt injection, tool misuse, and authorization bypass scenarios. Security testing must be repeated after updates to tools or models.
  10. Governance and compliance controls: MCP systems often process regulated or sensitive data. Clear policies are required for data retention, access logging, and user consent. Governance ensures MCP behavior aligns with legal, privacy, and organizational requirements.

MCP security best practices

1. Limit MCP permission scopes to the minimal necessary actions

Granting broad OAuth scopes up front (e.g., files:*, admin:*) increases the impact of a token compromise and complicates revocation. Instead, MCP implementations should follow a progressive scope model. Start with a baseline set of low-risk scopes such as mcp:tools-basic, and request elevated scopes only when necessary using targeted WWW-Authenticate challenges.

This minimizes user friction during initial setup, reduces privilege chaining risk, and improves audit clarity. Servers should support reduced-scope tokens and log all elevation attempts with scope details and correlation IDs. Clients should also cache denied scopes to prevent repeated elevation loops. Avoid inflating scopes in scopes_supported, as this leads to normalized over-permissioning and abandonment of consent prompts.

2. Enforce strict server verification for all MCP endpoints

MCP servers must not forward tokens unless they are explicitly issued for the MCP server itself. Accepting arbitrary access tokens (token passthrough) undermines the server’s ability to enforce rate limits, request validation, and auditing. It also introduces trust boundary violations, since downstream APIs may trust the wrong identity or behavioral assumptions.

To prevent this, the MCP server should:

  • Verify that the aud (audience) and other token claims match its own identity
  • Reject tokens not scoped for the MCP server
  • Avoid reusing tokens across services without verification

3. Apply input validation on both user prompts and model outputs

Unvalidated inputs pose a risk on both ingress and egress in MCP interactions. Prompt injection can occur through user input or tool responses, and malicious payloads may propagate across contexts if model output is treated as trusted input.

To mitigate this, MCP servers should:

  • Validate incoming user prompts for known injection patterns or special tokens
  • Inspect tool outputs before feeding them back into the model or exposing them to other systems
  • Sanitize or reject unexpected responses that may trigger unintended behavior in downstream components

4. Log all tool invocations with tamper-resistant storage

Robust logging is essential for accountability, incident investigation, and forensic response. Every invocation of a tool via an MCP server should be recorded with associated metadata, including:

  • The MCP client and user identity
  • Tool name and parameters
  • Requested scopes
  • Timestamp and result

Logs should be stored in secure, tamper-resistant systems, such as append-only logs or write-once storage, with integrity checks and access controls. Without trustworthy logs, it becomes difficult to trace misuse or audit sensitive operations.

5. Regularly audit installed MCP tools and extensions

Tools in an MCP environment may change after installation—updates may introduce new behaviors, permissions, or vulnerabilities. Attackers can exploit this by altering metadata (e.g., tool descriptions or parameters) or injecting malicious logic via dependencies or dynamic configuration.

MCP server operators should:

  • Perform scheduled audits of all installed tools and extensions
  • Re-validate declared permissions and descriptions against actual behavior
  • Use static analysis and dependency scanning to detect changes or added risk
  • Pin versions to prevent silent updates
  • Monitor tool registry changes and trigger alerts on unexpected modifications

6. Isolate MCP servers from sensitive internal networks

MCP servers should not be deployed in environments with unrestricted access to sensitive internal services. A compromised server could serve as a bridgehead for broader network intrusion.

To reduce risk:

  • Deploy MCP servers in isolated network segments with strict ingress and egress controls
  • If using local MCP servers, sandbox them with minimal privileges (e.g., restricted file system and network access)
  • Use platform-specific sandboxing methods like containers, chroot jails, or app sandboxes
  • Require authentication for any local HTTP transports, or prefer stdio or Unix domain sockets with limited access

Local MCP servers should also display explicit consent dialogs before executing any configuration commands. The dialog must show the full command, warn about potential risk (e.g., execution of rm -rf or curl to exfiltrate data), and allow users to cancel. This protects against unintentional code execution or malicious startup payloads.

Increase visibility and control over the AI components in your applications

Recent resources

MCP Security: 10 Key Elements to Secure and Critical Best Practices - Blog image agent configuration scanning

Securing the New Control Plane: Introducing Static Scanning for AI Agent Configurations

Announcing the launch of AI Agent Configuration Scanning.

Read more
MCP Security: 10 Key Elements to Secure and Critical Best Practices - Blog cover AI Security Maturity Checklist

Introducing Mend.io’s AI Security Maturity Survey + Compliance Checklist available today

A new tool to help security teams quantify AI risk and prepare for 2026 regulations.

Read more
MCP Security: 10 Key Elements to Secure and Critical Best Practices - LLM Red Teaming Blog Image

LLM Red Teaming: Threats, Testing Process & Best Practices

A practical guide to LLM red teaming.

Read more

AI Security & Compliance Assessment

Map your maturity against the global standards. Receive a personalized readiness report in under 5 minutes.