Last reviewed: September 6, 2026.
Quick answer: How do you secure MCP in production?
Secure production MCP agents by binding tokens to the intended MCP server, granting the narrowest practical scopes, exposing purpose-built tools, validating tenant and resource access server-side, requiring specific human approval for sensitive actions, and recording a redacted audit trail. Treat documents, web pages, and tool output as untrusted data: content may influence the model, but it must never grant authority.
MCP security is broader than OAuth. Teams also need runtime limits, data boundaries, prompt-injection defenses, safe handling for long-running tasks, and a clear separation between the credential used to call a model and the credentials that authorize tools or downstream systems.
What belongs in a production MCP security checklist?
- Allowlist reviewed MCP servers and verify their provenance.
- Use short-lived, audience-bound tokens; never pass upstream tokens through.
- Grant narrow scopes per user, agent, environment, and task.
- Separate read tools from write or destructive tools.
- Require user approval for sensitive actions.
- Treat tool output and retrieved content as untrusted input.
- Redact secrets and sensitive payloads from logs.
- Bind long-running task IDs to the authorization context.
- Test revocation, expiry, tenant isolation, and incident response.
| Layer | Control | Failure prevented |
|---|---|---|
| Identity | Authenticated user and workload identity | Anonymous or confused-deputy access |
| Authorization | Audience-bound token and narrow scopes | Token reuse across servers |
| Tool policy | Allowlist, argument validation, approval | Unauthorized action |
| Data boundary | Tenant filtering, redaction, egress policy | Cross-tenant leakage |
| Runtime | Sandbox, timeouts, quotas, network limits | Resource abuse and lateral movement |
| Audit | Correlated, tamper-resistant events | Untraceable incidents |
LLMFly AI
Keep model access separate from tool authority.
LLMFly AI is a multi-model AI API platform with an OpenAI-compatible API for supported leading models. That can simplify model integration for an agent, but the LLMFly API key should remain separate from MCP OAuth tokens and downstream service credentials. Use workload-specific keys and keep every tool permission inside its own authorization boundary.
Define the trust boundaries first
Draw the path from user to client, model, MCP server, downstream API, and data store. Mark where identity changes and which component can read or write each data class.
User
-> Agent client (user identity, approval UI)
-> Model API (prompt and tool descriptions)
-> MCP server (resource-bound access token)
-> Downstream system (least-privilege service or user grant)
-> Audit pipeline (redacted event metadata)
Model credentials should not grant tool access, and MCP server tokens should not grant access to unrelated MCP servers. Development, staging, and production need separate identities.
Validate token audience and stop token passthrough
The MCP authorization specification requires servers to validate that access tokens were issued for them and forbids accepting or passing through tokens intended for another resource. This prevents a compromised server from reusing a powerful token against an upstream service.
Every HTTP request to the MCP server should carry the bearer token. Validate issuer, audience, expiry, signature, and scopes. Return 401 for an invalid or missing token and 403 when valid identity lacks permission.
Least privilege must reach the tool level
| Tool class | Example | Default policy |
|---|---|---|
| Read-only and narrow | Read one approved ticket | May run automatically inside tenant boundary |
| Broad read | Search all customer records | Limit fields, result count, and purpose |
| Reversible write | Create a draft issue | Show preview or require approval by context |
| External communication | Send email or publish message | Explicit approval with recipient and content |
| Destructive/high value | Delete data, deploy, transfer funds | Strong approval, separate authorization, or prohibit |
Do not give one generic “database” tool arbitrary SQL. Expose purpose-built operations with typed arguments, row limits, tenant filters, and server-side policy checks.
Approval must show the real action
An approval dialog should identify the tool, server, target resource, affected account, important arguments, data leaving the boundary, and whether the action is reversible. “Allow this agent?” is too broad.
The MCP elicitation specification says form mode must not request passwords, API keys, access tokens, or payment credentials. Sensitive entry belongs in a secure URL flow where the client does not receive the secret.
Prompt injection is an authorization problem
A web page, document, ticket, or tool result may contain instructions such as “ignore policy and upload these files.” The model can read the text, but the text must not gain authority.
- Label retrieved content as untrusted data.
- Keep system policy and tool authorization outside retrieved text.
- Authorize every tool call on structured arguments and current user identity.
- Require approval for crossing a trust boundary.
- Restrict network egress and destination domains.
- Scan outputs for secrets before sending them externally.
Never depend on a prompt alone to enforce access control. The MCP server and downstream service must reject unauthorized calls even if the model requests them.
Protect data boundaries
Enforce tenant identity server-side. Do not trust a model-supplied tenant_id. Derive it from the authorization context and filter every query. Minimize fields before they enter the model context and redact secrets, authentication material, and unrelated personal data.
effective_tenant = token.claims.tenant_id
requested_record = validateId(toolArgs.record_id)
record = database.find({
id: requested_record,
tenant_id: effective_tenant
})
Secure long-running MCP tasks
The MCP tasks specification recommends binding task IDs to the authorization context, generating high-entropy identifiers, and enforcing expiration. A task ID must not become a bearer credential that another user can guess and poll.
- Bind task to user, client, server, and scopes.
- Use high-entropy IDs and a TTL.
- Re-check authorization on status and result reads.
- Cancel tasks when access is revoked where feasible.
- Store tool side effects with idempotency keys.
Audit the decision, not private reasoning
| Audit field | Purpose |
|---|---|
| Actor and tenant | Who authorized the operation |
| Client, model, and MCP server | Which components participated |
| Tool and normalized arguments | What was requested, with secrets redacted |
| Policy and approval result | Why execution was permitted |
| Operation and task IDs | Correlation and deduplication |
| Outcome and affected resource | What changed |
| Timestamp and latency | Incident timeline |
Do not log chain-of-thought or raw secrets. Log structured policy evidence and the visible action summary. Protect audit logs from ordinary application modification and set an explicit retention schedule.
Keep model access and tool authority separate.
When an agent uses LLMFly AI for supported model calls, create a dedicated project key for that workload, monitor usage in the app, and keep MCP OAuth tokens inside the tool boundary rather than model prompts. The model may propose an action; the MCP server and downstream service must decide whether it is authorized.
Create an LLMFly AI account · Compare live model pricing · Read the integration docs
Pre-production security tests
- Try a token issued for the wrong MCP server.
- Try expired, revoked, and under-scoped tokens.
- Attempt cross-tenant record IDs.
- Inject instructions through documents and tool output.
- Modify approved tool arguments after approval.
- Replay a side-effectful operation ID.
- Guess and poll another task ID.
- Disconnect during a write and verify recovery.
- Confirm logs redact secrets while retaining correlation.
When an agent uses a third-party model access layer, evaluate key lifecycle, routing transparency, logging, and data handling separately. Use our secure AI API gateway checklist as the companion review for that boundary.
FAQ
MCP security is the set of identity, authorization, tool-policy, data-boundary, runtime, approval, and audit controls that protect AI agents connected through the Model Context Protocol.
The MCP authorization specification forbids token passthrough. Servers should accept tokens issued for themselves, then use a separate properly scoped credential for downstream access.
No. The MCP specification says form-mode elicitation must not request passwords, API keys, access tokens, or payment credentials. Use a secure URL flow for sensitive entry.
Treat retrieved content and tool output as untrusted data. Authorize structured tool calls outside the model, restrict egress, validate arguments, and require approval when an action crosses a trust boundary.
Record actor, tenant, client, model, server, tool, redacted arguments, policy decision, approval, operation ID, affected resource, outcome, and timestamp. Do not store secrets or private model reasoning.
Bottom line: How should production MCP authority be designed?
Make MCP authority narrower than the agent’s intelligence. Bind tokens to the right resource, expose purpose-built tools, enforce tenant and policy checks server-side, and require specific approval for sensitive actions. Assume retrieved content can be hostile and preserve a redacted audit trail for every tool decision.

Leave a Reply