The Short Answer
To secure a public MCP server, authenticate every tool that costs you money, never pass a client's token through to another service, validate the Origin header and refuse methods you do not serve, meter anonymous use by a correctly restored address, guard every tool that fetches a URL against requests to private networks, and return errors an assistant can act on. Then assume most of your traffic will be machines that never call a tool at all, and make sure answering them costs almost nothing.
The one sentence version
Treat a public MCP server like a public API with an unusually chatty crowd: strong authentication where it matters, cheap answers for everything else, and logs that tell you which is which.
What a Public MCP Server Actually Receives
We run a public MCP endpoint for a voice product, listed in the official MCP registry since September and in an assistant's app directory since October. Over the 25 days from 3 to 27 November 2026, its own log recorded 91,461 sessions opened, 232,885 routine protocol messages and 25,301 tool calls, from 301 differently named clients on 10,687 addresses. The split between who connects and who actually uses the tools is the first thing to understand about securing one.
| Client | Sessions opened | Tool calls |
|---|---|---|
| A coding agent's client | 19,383 | 119 |
| A monitoring service | 17,999 | Fewer than 25 |
| Claude | 17,212 | 6,613 |
| ChatGPT | 16,605 | 17,252 |
| Everyone else: monitors, directories, scanners, scripts | About 37,000 | About 1,200 |
Two assistants made 94 percent of the tool calls. Monitors, directories and probes opened tens of thousands of sessions and called almost nothing; one monitoring service alone opened 17,999 sessions in 25 days. A coding agent's client reconnected so often that it opened 163 sessions for every tool call. None of this is an attack. It is simply what a listed endpoint attracts, and it means the cheapest possible handling of a session that does nothing is a security feature in itself.
The rest of the traffic is less polite. In the same period, 31,116 protocol messages, 13 percent, were malformed or asked for methods the server does not offer, and were answered with an error. Some were clients guessing at methods the protocol does not define. Others were directories testing how the server behaves under bad input, with method names like does-not-exist and a tool named nonexistent, each called dozens of times.
Four Kinds of Visitor
A threat model for a public MCP server starts by naming who shows up. Each group needs a different answer, and most security mistakes come from treating all four the same.
Assistants acting for people
Claude, ChatGPT and coding agents calling tools because a person asked. They need fast, correct answers and clear errors.
Monitors and directories
Services that list servers or check they are alive. They open sessions, list tools and leave. Answer them cheaply.
Probes and scanners
Clients testing unknown methods, missing tools and protected endpoints. Give them small errors and nothing else.
People seeking free compute
Anyone hoping to run your paid features without paying. Limits and authentication exist for them.
Rule 1: Authenticate What Costs Money
Decide which tools are free to call anonymously and which are not, and enforce the line in the server rather than in the tool description. On our server, basic text to speech with free voices works without an account inside small limits, because that is what lets an assistant demonstrate the product in a single chat. Everything heavier, multi voice dialogue, scripted tracks and transcription, requires a key or a signed in connection.
Give anonymous callers a small, metered tier
Ours allows 2,000 characters per call and per day, 10 calls a minute, and a shared daily pool so a crowd cannot drain it.
Let key holders act as themselves
A caller with a key or an OAuth token is charged against their own plan, with their own limits, as if they used the product directly.
Answer protected tools with a proper challenge
When an anonymous client calls a protected tool, return status 401 with a WWW-Authenticate header so the client can start sign in, not a vague text error.
The challenge is not theoretical. In 25 days, protected tools were called without credentials about 200 times, 153 of them from Claude sessions where the person had not connected an account yet. A payment scanner probed them six times. Every one got the same correct challenge and nothing else. Our guide to MCP servers for business covers the commercial side of choosing what to give away.
Rule 2: Never Pass Tokens Through
The MCP specification is blunt about this: token passthrough is forbidden, and a server must not accept any token that was not issued for that server. The tempting shortcut is to take whatever token the client sends and forward it to your own backend API. Doing so lets a token issued for something else, by someone else, act inside your system, and it erases the audit trail of who did what.
Our server runs its own OAuth 2.1 flow with PKCE and issues its own tokens. The consent step asks the person for their product API key, and the token the server issues is bound to a hash of that key, so it is useless anywhere else and stops working if the key is revoked. Behind the server, each call reaches the product's API with the person's own credentials, never with a token the client supplied.
The specification adds two related requirements worth copying exactly. A server that implements authorization must verify every inbound request, not just the first one in a session, and must not use sessions for authentication. If you issue session identifiers at all, make them secure random values that cannot be guessed or enumerated.
Rule 3: Validate Origin and Refuse What You Do Not Serve
The transport section of the specification requires servers using the streamable transport to validate the Origin header on every incoming connection, and to answer 403 Forbidden when the header is present and invalid. That rule exists to stop DNS rebinding, where a web page in someone's browser tricks it into talking to a server the page should never reach. It matters most for servers that run on a person's own computer, which the specification says should listen only on 127.0.0.1, never on every network interface.
Method handling deserves the same care. Our endpoint answers only POST. Early on, a GET request held a connection open indefinitely, which is a cheap way for anyone to tie up server resources. GET and DELETE now answer 405 straight away. Check your own endpoint with every method, including ones you never use, and make each unsupported one fail fast.
Rule 4: Meter by Address, and Get the Address Right
Anonymous limits only work if the address you meter is the caller's real address. Most public servers sit behind a CDN or a reverse proxy, which means the connecting address is the proxy's. The fix is to restore the real address from the proxy's header, and the trap is trusting that header from anyone. Our proxy overwrites any forwarded address header with the address it actually received the connection from, so a client cannot claim a fresh address on every call to escape its limit. We tested that by sending forged headers ourselves.
The same verification logic applies to crawlers and agents that claim a famous name. Our guide on verifying Googlebot and AI crawlers explains how to check names against published address ranges, which is also how you tell a real assistant platform from an imitation of one.
Rule 5: Guard Every Tool That Fetches a URL
Any tool that accepts a link and fetches it, an audio file to transcribe, a page to summarize, an image to process, can be turned into a way to make your server request things it should not. This is server side request forgery. An attacker supplies a link that points at your internal network or at the cloud metadata service, and your server fetches it with its own privileges.
Resolve the host name before fetching
Look up the address the link points to and check it, rather than checking the text of the link.
Block private and special ranges
Refuse loopback, private networks, link local addresses including 169.254.0.0/16 where cloud metadata lives, and private IPv6 ranges.
Check again after every redirect
A public link can redirect to a private address. Apply the same check to each hop, or refuse redirects.
Limit size, time and content type
Cap the download size and duration, and accept only the content types the tool needs.
The specification's security guidance lists the same ranges. We tested the guard on our transcription tool before it went public, and we recommend testing yours with links that point at your own internal addresses.
Rule 6: Treat Long Jobs and Retries as Normal
Assistants are impatient clients. If a tool takes too long, the request can be cut off by a proxy, and the assistant may simply try again. Our CDN ends any request at 100 seconds, so long transcriptions became jobs: the tool waits up to 40 seconds, and if the work is not finished it returns a job identifier that the assistant checks with a second tool. Nothing times out, and nothing is started twice by accident.
Retries are the other half of the problem. We have seen an assistant send the same long render again after the first had already finished, which billed the person twice for one result. Make expensive operations safe to repeat: recognize a duplicate request within a short window and return the existing result instead of doing the work again.
Rule 7: Return Errors the Model Can Act On
An error message from an MCP tool is read by a language model, which then decides what to tell the person. A misleading error becomes a misleading answer. Our product's API used the same status for two different situations, a per minute rate limit and a used up monthly allowance, and the MCP server translated both into wait a moment and try again. In 14 days, 6 people received 45 wrong answers telling them to retry something that could not succeed until the month reset or they changed plan. The fix, shipped on 17 November, gives each case its own plain sentence and tells the model exactly what the person can do.
A useful test for every error
Read each error message as if you were the assistant with no other context. If the message does not tell you whether to retry, wait, sign in or upgrade, rewrite it until it does.
Rule 8: Answer Probes Cheaply
Probes will arrive within minutes of a listing. When we published to the registry, directory crawlers connected within 20 minutes. Since then, clients have called unknown methods thousands of times. None of that needs special defence, only discipline: answer unknown methods and tools with a short standard error, never echo input back, never include stack traces or internal paths, and make sure an error path does no more work than a successful one.
Keep the server out of web search as well. The endpoint is not a page, and a robots file that disallows everything on the endpoint's host keeps search engines from indexing error responses. Directories and assistant platforms find servers through registries and listings, not through web search.
Consent Pages for OAuth
If your server runs an OAuth flow, its consent page is a target. The specification's security guidance sets clear requirements for servers that sit in front of another authorization service: the consent page must identify the requesting client by name, show the permissions being requested and the address the tokens will be sent to, protect against cross site request forgery, and refuse to be framed by other sites so it cannot be overlaid with a fake button. Those are good rules for any consent page. Ours asks for exactly one thing, the person's product key.
What to Log, and What Not To
Every number in this guide came from one log line per event: the method, the tool name, the client name from the opening handshake, the status, whether a key was used, and the duration. That is enough to see abuse, measure real use and debug failures. What we never log is the content people send, the text they ask to have spoken or the keys themselves. A log that holds secrets becomes the most valuable thing to steal.
Counting tool calls separately from sessions is also how you avoid fooling yourself about adoption, a point we make in our guide to getting your product into ChatGPT. Sessions measure attention from machines; tool calls measure use by people.
A Launch Checklist
| Area | Check before listing the server | How to test |
|---|---|---|
| Authentication | Paid tools refuse anonymous calls with a 401 challenge | Call each protected tool with no credentials |
| Tokens | Only tokens issued by this server are accepted | Send a token from another service |
| Origin | Invalid Origin headers get 403 | Send a request with a foreign Origin |
| Methods | Unsupported methods fail fast | Send GET, PUT and DELETE to the endpoint |
| Addresses | Forged forwarding headers are ignored | Send a fake address header and watch the limit |
| Fetching tools | Private and metadata addresses are refused | Submit links to internal addresses |
| Long work | Nothing runs past the proxy timeout | Run the slowest tool with the largest input |
| Errors | Each error says what the person can do | Read every message as the assistant would |
| Logs | No content and no keys in logs | Search a day of logs for a test key |
Our guide to product feeds for AI agents covers the read only side of serving agents, where many of the same rules apply with lower stakes.
The Bottom Line
A public MCP server spends most of its life answering machines that never call a tool, a small share answering assistants that act for real people, and a steady trickle answering probes. Secure it like a public API: authenticate what costs money, accept only your own tokens, validate Origin, refuse what you do not serve, meter real addresses, guard every fetch, make long work resumable and repeated work harmless, and write errors for the model that will read them. Then let your own log, not your listing count, tell you who is really using it.
