Skip to content
← All guides

MCP server security: how to vet and limit any server

Check what an MCP server can reach, then limit it in Claude Code and Codex with exact permission rules, config keys and a short vetting checklist.

5 min read

MCP server security comes down to what a server’s tools can reach, what content flows back into the model, and who controls the server after you approve it. In Claude Code, limit tools with mcp__<server>__<tool> permission rules. In Codex, use enabled_tools, disabled_tools and approval modes under [mcp_servers.<name>] in config.toml. Read each server’s own guide below before you connect it, because a token that is fine for one task can reach far more than the task needs.

The main risks

  • Prompt injection through tool output. Claude Code’s docs say to verify you trust each server, and that servers that fetch external content can expose you to prompt injection risk. An issue, a Slack message or a web page can carry instructions the model reads as part of its work.
  • Over-broad tokens. Many servers act with the full rights of your login or token. The server’s tools then reach whatever that credential reaches, including write and delete operations.
  • Tool poisoning and rug-pull updates. The model reads a server’s tool names and descriptions. If a server or the package behind it changes after you approve it, the model reads something you never reviewed. Commands such as npx -y pkg@latest fetch whatever is current on each start.
  • Local servers run as you. A stdio server is a process on your Mac with your user’s files and environment. A remote server runs elsewhere, but it still holds your OAuth grant.

Local and remote servers

Local (stdio)Remote (HTTP)
RunsA process on your MacOn the vendor’s host
Add in Claude Codeclaude mcp add [options] <name> -- <command> [args...]claude mcp add --transport http <name> <url>
Add in Codexcodex mcp add <name> -- <command>codex mcp add <name> --url <url>
Sign inEnvironment variables you passOAuth through /mcp or claude mcp login <name>, or codex mcp login <name>
Main exposureFiles, shell and keys on your MacThe scopes you grant at the vendor

Claude Code stores local and user scope servers in ~/.claude.json and project scope servers in .mcp.json at the project root. It asks before using project servers from .mcp.json in interactive sessions. Add a server to disabledMcpjsonServers to block it in every session type.

Limit a server in Claude Code

{
  "permissions": {
    "deny": ["mcp__github__delete_file"],
    "ask": ["mcp__github__*"]
  }
}

mcp__<server>__* matches every tool from a server, and mcp__<server>__<tool> matches one. Rules run in the order deny, ask, allow. Allow rules for MCP tools can’t take parentheses specifiers. Put rules in ~/.claude/settings.json for every project or .claude/settings.json for one project. /mcp shows connected servers.

Limit a server in Codex

[mcp_servers.github]
url = "https://api.githubcopilot.com/mcp/"
bearer_token_env_var = "GITHUB_PAT_TOKEN"
enabled_tools = ["get_file_contents", "issue_read"]
default_tools_approval_mode = "prompt"

enabled_tools is an allow list, and disabled_tools is a deny list applied after it. default_tools_approval_mode takes auto, prompt, writes or approve, and tools.<tool>.approval_mode overrides it per tool. Set enabled = false to switch a server off without deleting it. Project config in .codex/config.toml applies to trusted projects only. codex mcp list shows what is configured.

Checklist before you add a server

  1. Find who maintains it, and prefer the vendor’s own server.
  2. Pin a version instead of @latest where the server runs from a package.
  3. Use OAuth or a token with the narrowest scopes, never a shared admin credential.
  4. Choose read-only mode or a smaller toolset if the server offers one.
  5. Deny delete and administrative tools by name.
  6. Ask before any write tool runs.
  7. Treat what the server reads as untrusted input.
  8. Re-check claude mcp list or codex mcp list after updates.

Guides for specific servers

The settings behind these rules are in Claude Code and Codex security controls.

Checked against the vendor documentation on November 25, 2026. Claude Code MCP · Claude Code permissions · Codex MCP · Slack MCP

What Excellent covers

Excellent does not inspect MCP servers themselves. Its free scan reads supported logs on the Mac and reports findings for review. It reads the session logs of Claude Code, Codex, Grok Build, GitHub Copilot CLI, Gemini CLI and Qwen Code, so it can show what an agent did after it called a tool. It does not read Cursor’s, OpenClaw’s or Claude Cowork’s logs. For a local report without installing an app, run the free scan. Its script uses Python 3.9 or later when your Mac has it and the shell when it doesn’t, reads the logs locally and makes no network requests. See a sample report.

Excellent Pro adds checks before supported actions. Claude Code can display an ask prompt. With Codex, an Excellent “ask” refuses the action and tells the agent to ask you. Commands sent into an already running Codex shell fall outside that check. Agent coverage · Pricing. Pro is US-only for now.

Related guides

View all