# 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.

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) |
| --- | --- | --- |
| Runs | A process on your Mac | On the vendor’s host |
| Add in Claude Code | `claude mcp add [options] <name> -- <command> [args...]` | `claude mcp add --transport http <name> <url>` |
| Add in Codex | `codex mcp add <name> -- <command>` | `codex mcp add <name> --url <url>` |
| Sign in | Environment variables you pass | OAuth through `/mcp` or `claude mcp login <name>`, or `codex mcp login <name>` |
| Main exposure | Files, shell and keys on your Mac | The 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

```json
{
  "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

```toml
[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

- Code and DevOps: [GitHub](https://www.excellent.so/guides/github-mcp-server), [Git](https://www.excellent.so/guides/git-mcp-server), [GitLab](https://www.excellent.so/guides/gitlab-mcp-server), [Azure DevOps](https://www.excellent.so/guides/azure-devops-mcp-server), [Docker](https://www.excellent.so/guides/docker-mcp-server), [Playwright](https://www.excellent.so/guides/playwright-mcp-server), [Chrome DevTools](https://www.excellent.so/guides/chrome-devtools-mcp-server), [Context7](https://www.excellent.so/guides/context7-mcp-server), [Filesystem](https://www.excellent.so/guides/filesystem-mcp-server)
- Cloud and data: [AWS](https://www.excellent.so/guides/aws-mcp-server), [Azure](https://www.excellent.so/guides/azure-mcp-server), [Datadog](https://www.excellent.so/guides/datadog-mcp-server), [Grafana](https://www.excellent.so/guides/grafana-mcp-server), [Splunk](https://www.excellent.so/guides/splunk-mcp-server), [Snowflake](https://www.excellent.so/guides/snowflake-mcp-server), [Databricks](https://www.excellent.so/guides/databricks-mcp-server), [Postgres](https://www.excellent.so/guides/postgres-mcp-server)
- Work apps: [Slack](https://www.excellent.so/guides/slack-mcp-server), [Atlassian and Jira](https://www.excellent.so/guides/atlassian-mcp-server), [Salesforce](https://www.excellent.so/guides/salesforce-mcp-server), [ServiceNow](https://www.excellent.so/guides/servicenow-mcp-server), [Notion](https://www.excellent.so/guides/notion-mcp-server), [Linear](https://www.excellent.so/guides/linear-mcp-server), [Gmail](https://www.excellent.so/guides/gmail-mcp-server), [Google Workspace](https://www.excellent.so/guides/google-workspace-mcp-server), [Figma](https://www.excellent.so/guides/figma-mcp-server)
- Other: [n8n](https://www.excellent.so/guides/n8n-mcp-server), [Obsidian](https://www.excellent.so/guides/obsidian-mcp-server), [Blender](https://www.excellent.so/guides/blender-mcp-server), [Home Assistant](https://www.excellent.so/guides/home-assistant-mcp-server)

The settings behind these rules are in [Claude Code and Codex security controls](https://www.excellent.so/guides/claude-code-codex-security-controls).

Checked against the vendor documentation on November 25, 2026. [Claude Code MCP](https://code.claude.com/docs/en/mcp) · [Claude Code permissions](https://code.claude.com/docs/en/permissions) · [Codex MCP](https://developers.openai.com/codex/mcp) · [Slack MCP](https://docs.slack.dev/ai/mcp-server)

## 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](https://www.excellent.so/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](https://www.excellent.so/r/sample).

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](https://www.excellent.so/agents) · [Pricing](https://www.excellent.so/pricing). Pro is US-only for now.

Source: https://www.excellent.so/guides/mcp-server-security
