MCP Security Best Practices: Securing the Model Context Protocol in 2026
MCP servers give AI agents direct access to tools, data, and credentials, and in early 2026 researchers catalogued thousands of internet-exposed MCP servers, roughly half without any authentication. The core best practices are: authenticate every server, isolate each one with least privilege, maintain an allow-list of approved servers, and audit which agents connect to which servers from which machines. The visibility gap is the hard part: Nexus captures MCP connections per terminal and session, so you know exactly which agents are talking to which servers.
Nexus is an AI-agent governance and observability platform by Swfte. Below: why MCP became an attack surface, the ten-point checklist, the MCP-specific threats in plain English, and where the visibility gap actually lives.
Why MCP is now an attack surface
The Model Context Protocol won: it is the default way agents reach tools, databases, and services. Adoption at that speed always outruns hardening, and 2026 made the gap measurable. In January and February alone, more than 30 CVEs were filed against MCP servers, clients, and infrastructure: including CVE-2025-6514, a CVSS 9.6 remote code execution flaw in mcp-remote, a component thousands of setups relied on to reach remote servers. Meanwhile researchers cataloguing internet-exposed MCP servers found roughly half accepting connections with no authentication at all.
On top of the conventional vulnerability surface sit two threats specific to the protocol's design: prompt injection through content servers return, and tool poisoning through the descriptions agents use to choose tools. MCP is no less securable than any other integration layer, but it has to be secured on purpose, and mostly it has not been.
The 10 MCP security best practices
The checklist. Practices 1–8 harden the servers; 9 and 10 are where most programs fall short, because they require seeing and controlling live agent behavior.
- 01Authenticate every server. No MCP server should accept unauthenticated connections: local or remote.
- 02Run servers isolated with least privilege. Each server gets its own process, its own scope, and only the access its tools genuinely need.
- 03Maintain a curated allow-list of approved servers in source control, so additions are reviewed like any other change.
- 04Vet third-party servers like dependencies. Read the code or the vendor's security posture before it touches a developer machine.
- 05Scope credentials per server. One server, one credential, minimal reach: never a shared god-token across servers.
- 06Log tool calls with redaction discipline: capture what was called and by whom, without writing secrets or sensitive payloads into logs.
- 07Treat tool descriptions as untrusted input. Descriptions flow into the model's context and are a prompt-injection vector.
- 08Pin and update server versions. Unpinned servers silently become whatever the registry serves next.
- 09Monitor which agents connect to which servers, from which machines: a live inventory, not a config-file assumption.
- 10Enforce policy before the tool call, not after. A blocked action is security; a logged one is forensics.
MCP threats explained
Prompt injection
MCP tool output and descriptions flow into the model's context. Content a server returns (a web page, a document, a database row) can carry instructions the agent then follows, redirecting it toward actions nobody asked for. Any server that touches untrusted content is an injection path.
Tool poisoning
A malicious or compromised server can lie about what its tools do: an innocuous-sounding description hiding a destructive action, or a tool that changes behavior after it has been approved. Because agents choose tools based on descriptions, the description itself is attack surface.
Credential sprawl
Each MCP server typically holds its own credentials: API keys, tokens, database access. Multiplied across servers and developer machines, that is a large population of unmanaged secrets, each one a potential foothold with no rotation schedule and no owner.
Rogue and shadow MCP servers
The server a developer added to their local config yesterday never went through review. It runs with their permissions, connects to their agent, and appears in no inventory. Shadow servers are the MCP-specific face of shadow AI, and they are invisible to SaaS-side security tools.
Connection failures have their own playbook, see troubleshooting MCP server errors in the errors hub.
Where the visibility gap is
Every practice on the checklist assumes you know which servers exist and which agents use them. That assumption fails at the endpoint. Gateways see the traffic that routes through them: nothing more. The MCP server a developer added to their local Claude Code config yesterday routes through nothing: it runs on their machine, authenticates with their credentials, and appears in no gateway log, no OAuth grant, no SSO event.
Config-file audits do not close the gap either: they show what is declared on the machines you can inspect, not what is actually invoked, and they are stale the moment they finish. Closing the gap requires capture at the point of execution (per terminal, per session) where the agent actually makes the connection. That is the plane where agent observability operates, and it is why MCP inventory is an endpoint problem, not a network one.
How Nexus secures MCP usage
Nexus instruments the agent side of the protocol. Its runtime hooks capture every tool action per session and per terminal, so which agents connected to which servers is a recorded fact with user, repo, and terminal attribution: including servers nobody registered. Policy is evaluated before the tool call executes: disallowed actions are denied in-flight with a stated reason, which turns the allow-list from a document into an enforced control. In the console, connectors and non-human identities appear in one inventory, so shadow servers surface as findings instead of surprises.
This is the enforcement half of a broader AI agent governance program; for the agent Nexus integrates with most deeply, see Claude Code security. For the routing layer itself, see the MCP gateway guide.
MCP security vs. MCP gateway: do you need both?
They solve different halves of the problem. An MCP gateway is a routing and management layer: one endpoint in front of many servers, with centralized auth, rate limiting, and logging for the traffic that flows through it. MCP security, as this page defines it, is the full set of controls: including the connections that never touch a gateway, which in practice means most local developer setups.
A reasonable architecture uses both: a gateway to consolidate and control sanctioned remote servers, and endpoint-level capture and enforcement for the ground truth of what agents actually do. If you are choosing between retrieval architectures first, start with RAG vs. MCP.
MCP security FAQ
What is MCP security?
MCP security is the set of controls protecting the Model Context Protocol connections between AI agents and the tools, data sources, and credentials they use. Because MCP servers execute real actions on behalf of agents, securing them means authentication, isolation, allow-listing, and continuous auditing of who connects to what.
What are the biggest MCP security risks?
The recurring ones are unauthenticated servers exposed to the internet, prompt injection and tool poisoning through untrusted tool descriptions, credential sprawl across servers, and shadow MCP servers that developers add locally without review. Early 2026 saw more than 30 CVEs filed against MCP servers, clients, and infrastructure, so unpatched components are a live threat too.
How do I know which MCP servers my developers are actually using?
Config files only tell you what's declared on machines you can inspect; they miss what's actually invoked. Nexus captures tool actions at the Claude Code hook level, per terminal and per session, giving you a ground-truth record of which agents connected to which servers: including ones nobody registered.
Should MCP servers be on an allow-list?
Yes. Keep a curated list of approved servers in source control, vet additions the way you vet new dependencies, and enforce the list at execution time so an unapproved server is blocked rather than merely flagged. Anthropic itself notes it does not audit MCP servers, so the vetting responsibility is yours.
Can Nexus block a risky MCP tool call before it runs?
Yes: Nexus evaluates policy in the PreToolUse hook, before the action executes, and returns a deny with a stated reason when a call violates policy. Enforcement is synchronous and local, so it cannot be bypassed by a network failure, while capture is fail-open so a down collector never blocks legitimate work.
Related
- MCP gateway: routing and managing MCP servers
- Claude Code security: governing the agent in your terminal
- AI agent governance: inventory, policy, and audit
- Agent observability: monitoring AI agents that act
- Swfte Nexus: AI-agent governance, observability & savings
- Troubleshooting MCP server errors
- RAG vs. MCP
Know every MCP connection in your org
Per agent, per terminal, per session. Nexus traces and enforces MCP usage where gateways can't see.
Open-core capture layer · Pre-execution policy blocking · Metadata-only privacy tier by default