AI agents · OpenClaw · self-hosting · automation

Quick Answer

How to Secure an MCP Server in 2026: 9-Step Checklist

Published: • Updated:

The short answer

Secure an MCP server like any production API that can reach your credentials, then add two MCP-specific controls: never pass tokens through, and treat tool definitions as untrusted code. The checklist below follows the MCP specification’s security best practices and AWS’s MadPot findings published December 3, 2026.

Why it is urgent: AWS said the median time for an exploit to reach a newly deployed AI sensor fell from 19.5 hours in 2024 to 107 minutes in 2026, and its fastest first contact came 87 seconds after a sensor went live. On one decoy MCP server, a suspected autonomous agent used a credential-stealing tool 348 milliseconds after reading the tool list.

The 9-step checklist

#StepThreat it stops
1Keep it private by default; put public ones behind auth, WAF and a firewallOpportunistic scanning, compute abuse
2Require OAuth 2.1 authentication on every requestAnonymous tool calls
3Validate the token audience; never pass tokens throughToken passthrough, confused deputy
4Least-privilege scopes, elevated on demandLarge blast radius from a stolen token
5Secure state handles; a handle is not authenticationState handle hijacking
6Expose only the tools agents needCredential-dumping or command tools
7Short-lived, narrowly scoped cloud credentialsLateral movement
8Pin, review and lock tool definitionsTool poisoning, hidden instructions
9Log tool calls per identity and alert on anomaliesSlow detection

Steps in detail

1. Keep it off the internet unless it must be on it. AWS’s first recommendation is not to expose model servers or MCP servers without protection: restrict with security groups, put public endpoints behind a WAF and network firewall, and require authentication on every endpoint, including internal ones. Add every MCP server to your asset inventory and vulnerability scanning.

2. Authenticate every request. For remote (HTTP) servers, implement the MCP authorization spec, which builds on OAuth 2.1. The spec’s best-practice page says servers that implement authorization MUST verify all inbound requests. If you do not want to build this, see auth platforms for AI agents and MCP servers or put the server behind an MCP gateway.

3. No token passthrough. The spec is explicit: MCP servers MUST NOT accept tokens that were not explicitly issued for the MCP server. If your server calls a third-party API, it gets its own token for that API. If it proxies a third-party OAuth provider with a static client ID, implement per-client consent before forwarding, validate redirect_uri by exact match and use single-use state values; otherwise you have the confused-deputy hole the spec describes.

4. Minimise scopes. Start clients with a small, read-only scope set and issue targeted WWW-Authenticate scope challenges when a privileged tool is first called. Avoid wildcard scopes (*, all, full-access) and do not publish every scope in scopes_supported.

5. Treat state handles carefully. Since protocol version 2026-07-28, MCP is stateless and has no protocol-level sessions; servers that keep state mint a handle (a cart or workflow ID) passed back as a tool argument. Servers MUST NOT treat possession of a state handle as authentication and SHOULD use secure, non-deterministic handles. Bind handles server-side to the authenticated user.

6. Cut the tool list. Every tool is attack surface that an agent can understand in under a second. Remove debug, shell and credential tools from production builds; split read and write tools so read-only clients never see writes.

7. Give the server weak credentials. Use temporary credentials, not long-lived keys, and scope them to the resources the tools touch. AWS’s example: scope bedrock:InvokeModel to only the models an application needs. Guard against server-side request forgery if tools fetch URLs.

8. Lock tool definitions. Hidden instructions only work if an agent loads them. Inventory every MCP server your agents connect to, allow approved sources only, pin versions, review tool descriptions before adoption and after every update, then make the definitions read-only for the systems that serve them. In August 2026 AWS caught an attempt to plant fake tool definitions telling agents to send credentials to an outside server and to hide the message from the user.

9. Watch it. Log every tool call with the caller’s identity, learn normal volume per role and alert on new tools, Regions or spikes.

Local (stdio) servers

A local server is a program running with your privileges. Clients that offer one-click install MUST show the exact command, unabridged, and get explicit approval; the spec recommends running servers in a sandbox with minimal file and network access. Pair that with network egress controls for the agent itself.

Before you ship

  • curl the endpoint without a token: it must return 401.
  • Send a token issued for another audience: it must be rejected.
  • Diff your tool descriptions against the pinned version in CI.
  • Confirm the server’s cloud role cannot read secrets it does not need.

Building one from scratch? Start with how to deploy a remote MCP server.

Last verified: December 4, 2026.

Sources