Actively exploited Attackers exploit Acronis Backup plugin for cPanel; users of version 1.9.4 are told to downgrade CVSS 7.5 · Published Dec 4, 05:40 UTC What to do now ›

Guide Intermediate 40 min Last reviewed Tested on Checked against the MCP specification, revision 2026-07-28

How to secure MCP servers: a practical hardening guide

MCP servers give AI agents real access to files, systems and accounts. This guide turns the Model Context Protocol's own security rules into six concrete steps: inventory, approvals, least privilege, transport and tokens, updates, and logging.

Prerequisites

  • An AI application or coding assistant that uses MCP servers
  • Admin access to the machines or containers where those servers run
On this page (8 steps)
News graphic with the label 'Guide, intermediate', the title 'Secure MCP servers' and the line 'Six steps for AI agent tools', above an illustration of a shield around the connection between an AI agent and a tool, with green check marks
Illustration: AI Security Times

The Model Context Protocol (MCP) lets AI applications call tools: read files, query databases, open tickets, run commands. Each MCP server runs with real permissions, and the AI decides when to use it. That makes MCP servers a security boundary, whether you planned for one or not. This guide turns the protocol’s own rules into six practical steps.

What the specification already says

The MCP specification (latest revision: 2026-07-28) contains a few rules worth knowing before you start:

  • “There SHOULD always be a human in the loop with the ability to deny tool invocations.”
  • “Clients MUST consider tool annotations to be untrusted unless they come from trusted servers.” Annotations are labels such as “read-only” that a server attaches to its tools.
  • Servers MUST validate all tool inputs, implement proper access controls, rate limit tool invocations and sanitize tool outputs.
  • Clients SHOULD ask for confirmation on sensitive operations, show tool inputs to the user before calling the server, validate tool results, use timeouts and log tool usage.

The steps below put those rules into practice.

Step 1: Inventory every MCP server

List every MCP server that your AI clients load. Each client keeps its own configuration, so check every assistant, IDE plugin and agent framework in use. For each server, write down:

  • who maintains it, and which version you run;
  • what it can reach: which folders, which networks, which accounts and API keys;
  • which of its tools only read, and which write, run commands or send data.

A server that nobody can explain is a server to remove.

Step 2: Turn off auto-approval for anything that writes, runs or sends

Many clients can approve some tool calls automatically. Limit that to tools that truly only read, and keep a human approval for everything else.

Do not trust a tool’s own label when you decide. In November 2026, AWS fixed CVE-2026-126816 in its Pricing MCP server, whose report tool could write files anywhere through a crafted output path. AWS noted that the tool “was also annotated as read-only, which can lead MCP clients to auto-approve it without user confirmation.”

Step 3: Give each server the least access it needs

  • Run servers under their own operating system account, or in a container, with access only to the folders they need.
  • Give each server its own API tokens, with the smallest scopes that work. The specification’s security best practices call this scope minimization.
  • Validate file paths inside the server. Do not rely on MCP “roots” to contain it. The specification says roots are “informational guidance rather than an access-control mechanism. The protocol does not enforce that servers stay within roots.” Roots are also deprecated as of the 2026-07-28 revision.

Step 4: Lock down transport and tokens

  • Local servers: the specification recommends the stdio transport, which talks only to the process that started the server. A local server listening on HTTP should require authentication.
  • Remote servers: use HTTPS. Clients should block requests to private and reserved IP ranges when following metadata URLs, to prevent server-side request forgery.
  • Tokens: “MCP servers MUST NOT accept any tokens that were not explicitly issued for the MCP server.” A server that forwards a user’s token to another service, known as token passthrough, breaks the audit trail and the access controls of that service.

Step 5: Treat every install like code you run

An MCP server is software with your permissions. The specification asks clients to show the exact command before a one-click install, to require explicit approval, and to run local servers in a sandbox. In addition:

  • pin server versions instead of pulling the latest automatically;
  • watch the maintainers’ security advisories, as you would for any dependency;
  • remove servers you no longer use.

Step 6: Log and review tool calls

Keep a log of which tool was called, with which inputs, by which user and agent. Review it for tools called at unusual times, file paths outside the expected folders, and outbound connections to unknown hosts. The log is also your evidence if something goes wrong.

Checklist

MCP hardening checklist
Area Check
Inventory Every server listed with owner, version and access
Approvals Auto-approve only for tools that truly only read
Annotations Never used as a security decision on their own
Least privilege Own account or container, scoped tokens, path checks in the server
Transport stdio for local servers; authentication on HTTP; HTTPS for remote
Tokens No token passthrough
Updates Pinned versions, advisories watched, unused servers removed
Logging Tool calls logged and reviewed

Changelog

  • First published.

References

  1. Model Context Protocol specification: ToolsSpecification
  2. Model Context Protocol specification: Security best practicesSpecification
  3. Model Context Protocol specification: RootsSpecification
  4. AWS Security Bulletin 2026-184-AWSVendor

Did a command not work as described? Report an error

Related guides

All guides ›