All articles

MCP server security: real risks and a 10-minute check

In short. MCP server security comes down to one fact: a server runs with real access to your files, accounts and network. The MCP specification names concrete attack paths, from malicious startup commands on local servers to token passthrough and server-side request forgery. Claude Code asks before using project servers in interactive sessions, but not in non-interactive runs. Before connecting any server, spend ten minutes on its command, publisher, reach, scope and the outside content it reads.

A workbench in Nice with a row of brass padlocks, some open and some closed, a ring of keys and a small notebook with empty columns, soft light through shutters
Every server you connect gets a key; the question is which doors it opens.

The Model Context Protocol made it easy to give an AI client new tools: a database, a ticket system, a browser, a file store. Installing a server often takes one line. That ease is also the risk, because each server receives real permissions, and the assistant that calls it reads text you did not write. This guide explains what the specification itself says about attacks, how Claude Code decides when a server loads, what a short review looks like for a small team, and when the right answer is not to connect the server at all. If you are setting up your first servers, start with our guide to MCP server setup.

What can actually go wrong?

The MCP security best practices list concrete attacks rather than vague warnings. Five matter most for small teams.

Local server compromise. Local servers are binaries downloaded and executed on the same machine as the client. The specification describes an attacker hiding a malicious startup command in a configuration, or shipping a payload inside the server, with risks that include arbitrary code execution and data exfiltration. A server you install runs with your privileges.

Token passthrough. Some servers accept a token from the client and forward it to a downstream API. The specification calls this an anti-pattern and states that MCP servers must not accept any tokens that were not explicitly issued for the MCP server. Passthrough breaks audit trails and lets a stolen token travel further.

Confused deputy. A proxy server that uses one static client ID with a third-party API can be tricked into skipping the user’s consent. The required fix is per-client consent before forwarding to the third party.

Server-side request forgery. A malicious server can supply URLs that point the client at internal addresses, including cloud metadata endpoints. Clients deployed on servers should block private ranges and validate redirects.

Over-broad scopes. A token carrying wide scopes turns one leak into access to everything. The specification recommends a minimal initial scope set and elevation only when a privileged operation is first attempted.

How does Claude Code decide when a server loads?

Through scopes and approval. The Claude Code MCP documentation describes three scopes. A local server loads only in the project where you added it and stays private to you. A project server is stored in .mcp.json at the project root and shared through version control. A user server is available across all your projects.

For project servers, Claude Code prompts for approval in interactive sessions before using servers from .mcp.json. That prompt is the main defence against a repository that ships its own servers. The documentation is explicit about the gap: in non-interactive runs, such as claude -p, Agent SDK sessions and some cloud sessions, Claude Code cannot show the prompt and loads project servers without asking. To keep a server out in those runs, use the disabledMcpjsonServers setting, --setting-sources or --strict-mcp-config. A cloned repository in an untrusted folder also cannot approve its own servers by committing approval settings.

The same page carries a plain warning: verify you trust each server before connecting it, because servers that fetch external content can expose you to prompt injection. A server that reads web pages, emails or tickets brings text into the conversation that someone else wrote.

What does a review look like? A worked example

Here is an invented three-person team, to show the method rather than a typical result. They want four servers. For each one we note the transport, what it can reach, which named risk applies and what they decide.

Server Transport Reach Main risk Decision
Project files local, stdio one project folder local compromise allow, project scope, pinned version
Ticket system remote, HTTP all tickets, write access prompt injection from ticket text allow read-only token, approve writes by hand
Web browser local the open internet prompt injection, SSRF allow only in a separate profile, no saved logins
Database proxy remote, HTTP production database token passthrough, broad scope refuse until it uses its own scoped token

Four servers, four different answers. Only one is refused outright, and it is the one that would pass the team’s own database token through to another service. The ticket system stays, but with a read-only token, because ticket text written by customers is exactly the outside content that can carry instructions.

A wooden desk in Nice with four small labelled boxes without readable text, one closed with a brass latch, a magnifying glass and a pencil, afternoon light
Four servers, four decisions: allow, restrict, isolate or refuse.

What if you run your own remote server?

Then the server-side rules apply to you. The specification says MCP servers that implement authorization must verify all inbound requests and must not use sessions for authentication. Session IDs must be secure and non-deterministic, generated with a secure random number generator, and should be bound to user-specific information, so a guessed ID cannot be used to act as someone else. If your server forwards requests to another API, it must use its own token for that API and ask each client for consent, rather than letting one approval cover everyone. These are not advanced features; they are the minimum before a server leaves a developer’s laptop.

What is the 10-minute check?

Before connecting any server, answer five questions in writing:

  • Command or URL. Read the exact command, with all arguments, or the exact URL. The specification asks clients to show the full command without truncation for a reason.
  • Publisher. Who maintains it, how often it is updated and whether you can pin a version.
  • Reach. Which files, network destinations and accounts it can touch. Narrow it before you start, not after.
  • Scope. Local, project or user. Choose the narrowest one that works; a server you need in one project should not load in all of them.
  • Outside content. Whether it fetches web pages, emails, tickets or documents written by others. If it does, treat everything it returns as untrusted input.

Write the answers next to the configuration. When someone asks in six months why a server is there, the reason is already recorded.

How do hooks and permissions fit in?

MCP review decides which servers exist. Hooks and permission rules decide what happens when they are called. A PreToolUse hook can block a risky tool call before it runs, and permission rules can require approval for writes. Our guide to Claude Code hooks shows how to write and test one. For deciding which work belongs in a subagent and which in a skill, see Claude Code agents vs skills.

When should you not connect a server at all?

When it needs more access than the task, when nobody can say who maintains it, when it would forward your credentials to someone else, or when the data involved should never leave your machine. In the last case the question is not which server but where the model runs; our guide to private AI for business covers that route.

How can we help?

We review MCP setups for small teams: we list the servers, their reach and scopes, write the five answers for each, set up hooks and permission rules where they help and document the result. You decide what stays.

Send us the list of servers you use or plan to use. We reply in writing within 48 hours.

Questions

Is a local MCP server safer than a remote one?

Not automatically. The MCP specification warns that local servers are binaries running on your machine and may have direct access to your system. A malicious startup command or package runs with the same privileges as the client, so a local server needs as much scrutiny as a remote one.

Does Claude Code ask before using a server from .mcp.json?

In interactive sessions, yes: Claude Code prompts for approval before using project-scoped servers from .mcp.json. In non-interactive runs such as claude -p or Agent SDK sessions it cannot show that prompt and loads them without asking, so you must exclude unwanted servers in settings.

Can an MCP server just forward my token to another API?

It should not. The specification calls this token passthrough, an anti-pattern, and says MCP servers must not accept any tokens that were not explicitly issued for the MCP server.

What is the quickest check before connecting a server?

Read the exact command or URL, check who publishes it, see what files, network and accounts it can reach, choose the narrowest scope, and decide whether it fetches outside content that could carry prompt injection.

Contact

One person reads this inbox — the same person who builds what you order.

Describe your task

Tell us what you have and what result you need — even a single small task. No brief required: within 48 hours you get a plan and a price in writing, a question, or an honest “not a fit”.

Include the situation, files or links, deadline, language, privacy limits and budget boundary if you have one.

File (optional)
No file chosen

A brief, a photo, a spreadsheet — whatever explains the task faster than words. Up to 8 MB, stored with our hosting provider. Please don't send sensitive personal or medical documents through the site.

Sending creates no order and no payment. We reply within 48 hours. Prefer email? contact@castel.studio

Talk to us

Prefer a call or a messenger? Write or call — the studio's founder answers.

Connect on LinkedIn

Prefer a freelance platform?

Order the same work there, with the platform's secure payment.

A one-person AI studio in Nice. Whoever answers your message is the one who does the work — no account managers in between. Files are processed on our own machine, not in someone else's cloud.

Nice 06100, France · Open in maps →

SIREN 103 115 705

Describe your task