MCP Security: How to Secure AI Tools, Servers and Data Access
How to secure Model Context Protocol deployments: OAuth-based authorization, audience-bound tokens, no token passthrough, least-privilege tools, consent, tool poisoning, prompt injection, local server risks and audit trails.
Quick answer
Securing MCP means getting identity, tools, data and supply chain right. For remote servers, follow the specification's OAuth 2.1-based authorization: PKCE with S256, the resource parameter so tokens are bound to your server, strict audience and scope validation on every request, short-lived tokens and no token passthrough to upstream APIs. Expose narrow, least-privilege tools with validated arguments and approvals for consequential actions, treat tool descriptions and results as untrusted input, install only vetted servers and pin versions, isolate tenants and log every call.
Where This Fits
MCP basics are in the MCP guide and implementation in how to build an MCP server. Injection attacks generally are covered in prompt injection prevention, and agent-level controls in AI agent guardrails.
The MCP Threat Model
| Threat | Example | Primary control |
|---|---|---|
| Token misuse | Server accepts a token issued for another service | Audience validation |
| Token passthrough | Server forwards client token to an upstream API | Separate upstream credentials |
| Confused deputy | Proxy server uses its authority for an attacker | Per-client user consent |
| Over-broad tools | A 'run SQL' tool reachable by any user | Narrow tools, least privilege |
| Tool poisoning | Malicious instructions in tool descriptions | Vetted servers, metadata review |
| Injection via results | Retrieved document tells the model to exfiltrate data | Treat results as data, limit tools |
| Malicious local server | Installed package reads local credentials | Trusted sources, pinned versions, sandboxing |
Authorization Done Right
The MCP authorization security considerations set clear requirements. Clients must use PKCE (with S256 where possible) and include the resource parameter defined in RFC 8707, so tokens are bound to the intended MCP server. Servers must validate that every token was issued specifically for them and reject others. Servers that call upstream APIs act as their own OAuth clients and must not pass through the token they received. Authorization servers should issue short-lived tokens and rotate refresh tokens for public clients, and clients must validate the issuer parameter to prevent mix-up attacks.
Client Registration and Consent
The 2026-07-28 revision prefers Client ID Metadata Documents for client registration and deprecates Dynamic Client Registration (still allowed for compatibility). Authorization servers fetching client metadata should guard against server-side request forgery, warn on localhost-only redirect URIs and clearly show the redirect host during consent. MCP proxy servers that use a static client ID with third-party authorization servers must obtain user consent for each dynamically registered client, which prevents the confused deputy problem.
Tool Design and Least Privilege
Framework-neutral guidance for function calling is in AI tool security, and agent identities in AI agent access control.
- Expose task-level tools, not generic query or command execution
- Separate read and write tools, with different scopes
- Validate every argument against strict schemas and business rules
- Enforce permissions server-side using the authenticated user's identity
- Require approval for actions that send, spend, delete or change customer-facing data
- Rate-limit per user and tool
- Return minimal data in results, redacting sensitive fields
Exposing systems to AI clients through MCP?
ZSpace Labs builds and reviews MCP servers against the current specification's authorization and security requirements.
Prompt Injection and Tool Poisoning
Models read tool descriptions and tool results, and both can carry instructions. A malicious server can hide directives in descriptions; a document or web page returned by a tool can tell the model to call another tool with sensitive data. Hosts should show users which servers and tools are active and ask for approval on sensitive calls; servers should never assume the model's request reflects the user's intent. Limit what any single model session can do across servers. See prompt injection prevention.
Supply Chain and Local Servers
Local stdio servers run as processes with the user's permissions. Install servers only from trusted publishers, review their code or provenance, pin versions, and update deliberately. In organizations, maintain an approved list of servers and block others. Consider sandboxing local servers with restricted file system and network access.
Data Protection and Tenant Isolation
Multi-tenant MCP servers must scope every query to the authenticated tenant and user. Minimize the data returned to models, which may be sent to third-party model providers. Respect data residency requirements and document which data flows through MCP in your privacy records.
Logging, Monitoring and Incident Response
Log every request: authenticated user, client, tool, arguments (redacted), result status, latency and upstream calls, with trace context. Alert on unusual patterns such as bursts of write calls, access across tenants or repeated authorization failures. Be able to revoke tokens, disable tools and block clients quickly.
Advantages and Limitations of MCP's Security Model
MCP's specification gives remote servers a clear, standards-based authorization model, which is better than ad hoc API keys pasted into assistants. It cannot stop a model from being manipulated, a user from approving a harmful action, or a malicious local server from abusing the permissions it runs with. Defence in depth (narrow tools, server-side permissions, approvals, monitoring) is still required.
MCP Security Checklist
- 1. Implement authorization per the current specification for remote servers
- 2. Validate audience and scopes on every request; no token passthrough
- 3. Design narrow, least-privilege tools with schema validation
- 4. Enforce permissions and limits server-side
- 5. Require approvals for consequential actions
- 6. Vet and pin servers, especially local ones
- 7. Isolate tenants and minimize data
- 8. Log, monitor and rehearse revocation
Hardening Local MCP Servers
- Install only from trusted publishers and pinned versions; review changes on upgrade
- Run with the least file system and network access possible (containers or OS sandboxing)
- Never embed long-lived high-privilege tokens in local configuration files
- Prefer read-only modes where servers offer them
- Review what each server's tools can do before enabling them in an assistant
- Remove servers that are no longer used
Governance: An Approved Server Catalogue
Organizations should keep a catalogue of approved MCP servers with owner, purpose, data classes, tools, authentication method and permitted clients, and block or warn on unapproved servers on managed devices. New servers go through a light security review: who publishes it, what it can access, how it authenticates, whether it passes tokens through and how it logs. This is the MCP equivalent of approving browser extensions or SaaS integrations; see security review practices for the general approach.
Worked Example
An illustrative scenario, not a client case: a company's internal MCP server for HR data initially accepted any valid token from its identity provider. A review finds tokens issued for other internal apps work too. The team adds audience validation, per-tool scopes (employees can read only their own records, HR staff can read their department) and logging, and removes a generic search tool that could reach salary fields.
Common Mistakes
- Accepting tokens without audience checks
- Passing user tokens to upstream APIs
- Generic tools with broad data access
- Installing community servers without review
- No approval for write actions
- No logs of tool calls
Want an MCP security review?
Talk to ZSpace Labs about secure MCP and agent development and identity and API security.
Conclusion
MCP security is standard security applied carefully to a new kind of client: audience-bound tokens, no passthrough, least-privilege tools, untrusted inputs, vetted servers and full audit trails. Related: MCP guide, prompt injection prevention and guardrails.
Common questions
Token misuse (accepting tokens meant for other services or passing tokens through), over-broad tools, malicious or compromised servers, tool descriptions crafted to manipulate models, prompt injection through tool results, local servers with excessive system access, and missing audit trails.