Make your MCP server safe to install: a 13-item checklist
The short version
A safe MCP server is one that can do very little, even when it is wrong or someone is attacking it. A copycat "postmark-mcp" package on npm copied the real Postmark server, behaved for fifteen versions, then shipped version 1.0.16 with one added line that quietly copied every email to its author. A clean history is not proof of safety.
So work in this order: take power away first, then harden the connection, then lock down the supply chain.
Items marked (spec) are MUST/SHOULD rules in the MCP specification (2025-06-18). Items marked (advice) are good practice, not spec rules.
| # | Fix | Why and how |
|---|---|---|
| 1 | Give every token the smallest scope it needs (spec) | Start with read-only discovery scopes and ask for more only when a tool needs it. Never publish wildcard scopes like *, all or full-access. A leaked broad token reaches everything |
| 2 | Never hand a tool a shell (advice) | A tool that runs arbitrary commands turns any prompt injection into code execution. Offer narrow tools (list_files, read_file) instead. Command injection is a real class of MCP bugs, for example CVE-2025-6514 in mcp-remote (fixed in 0.1.16) |
| 3 | Validate every input (spec) | Servers MUST validate all tool inputs: types, lengths, allowed values, paths |
| 4 | Lock file access to one folder (spec, sandboxing) | Resolve paths and reject anything outside the root. Run the server in a container or with restricted file-system access |
| 5 | Ask before anything destructive (spec) | There SHOULD always be a human in the loop. Mark destructive tools as such (the destructiveHint annotation) and require a confirmation |
| 6 | Refuse tokens not issued for your server (spec) | Servers MUST NOT accept tokens that were not explicitly issued for them. No token passthrough to downstream APIs |
| 7 | Bind to localhost (spec) | A local HTTP server SHOULD bind to 127.0.0.1, not 0.0.0.0 |
| 8 | Check the Origin header (spec) | Streamable HTTP servers MUST validate Origin on every connection, which blocks DNS-rebinding attacks from websites |
| 9 | Require auth on every connection (spec) | Servers SHOULD implement proper authentication. For local-only servers, prefer stdio, which only the client can reach |
| 10 | Rate limit every tool (spec) | Servers MUST rate limit tool invocations |
| 11 | Pin every dependency (advice) | Exact versions plus a lockfile, and npm audit in CI. Publish tagged releases so users can pin yours too |
| 12 | Freeze tool descriptions between versions (advice) | The model reads descriptions. Changing one silently is what researchers call a "rug pull". Treat a description change as a version bump with a changelog line. Clients may not warn users when a description changes |
| 13 | Log every tool call (spec, client-side SHOULD) | Who called what, with which arguments (redacted), and what came back. Log scope elevations too |
Copy these prompts
Paste this into Claude Code (or any AI that can see your repo).
1. Audit your server against the checklist
I am building an MCP server and want it safe to install. Audit this repo against the 13-item checklist below. For each item say DONE, MISSING or NOT APPLICABLE, point to the file and line, and propose the smallest change. Do not change anything until I approve. Items: smallest scope per token (no wildcard scopes); no tool that runs shell commands; every tool input validated; file access limited to one root folder; destructive tools ask for confirmation; reject tokens not issued for this server; HTTP binds to 127.0.0.1; Origin header checked; authentication on every connection; rate limit per tool; dependencies pinned with a lockfile; tool descriptions unchanged between versions without a version bump; every tool call logged with redacted arguments. Flag anything you are unsure about instead of guessing.
If you are building an MCP server
Also worth doing:
- Sanitize tool outputs (spec: servers MUST).
- Use secure random session IDs and never use a session as authentication (spec: MUST NOT).
- Match redirect URIs by exact string, and use a server-owned consent page, if you run an OAuth proxy (spec: MUST).
- If your server fetches URLs, block private ranges and cloud metadata (169.254.169.254).
Honest caveats:
- The MUST/SHOULD wording is for the 2025-06-18 version of the spec. Check the current spec for your protocol version.
- "Less power" does not replace the checks. It makes a mistake in them cost less.
- Items 2, 11 and 12 are practice, not spec rules. The rug-pull idea comes from third-party research, and client behaviour varies.
- The postmark-mcp incident was a malicious publisher, not a bug. Pinning protects the people who install your server and your own dependencies, but it cannot stop a publisher you chose to trust from turning bad.
Run this on your codebase
Open your MCP server repo in Claude Code and paste the audit prompt above. Read the DONE / MISSING / NOT APPLICABLE list, approve the smallest fixes one at a time, and start with items 1 and 2, because taking power away pays off the most.
Sources: the MCP specification (2025-06-18) pages "Security Best Practices", "Transports" and "Tools"; Postmark's 25 Sep 2025 warning and The Register's report of the fake postmark-mcp package (29 Sep 2025); JFrog's advisory for CVE-2025-6514. Checked 2026-11-08.