Packs

How to set up MCP servers in Claude Code, Cursor and Codex

Guide · checked against the docs on

MCP servers let your AI coding tool reach things outside your project, like docs, a database or a design tool. Claude Code, Cursor, Codex and GitHub Copilot in VS Code all support MCP, but each one keeps its settings in a different file and uses different commands. This guide shows where each tool keeps its MCP setup, how to add a server for one project or for all of them, and how to check that it connected. Everything here comes from each vendor's own docs, read on October 15, 2026. Version-specific details are marked per the docs, checked Oct 2026.

Not affiliated with or endorsed by Anthropic, Anysphere (Cursor), OpenAI, GitHub, Microsoft or the Model Context Protocol project. Check each vendor's current docs before relying on these details.

The example configs below are NOT TESTED. We copied their shape from the vendors' docs and swapped in placeholders like YOUR_TOKEN. We didn't run any MCP server for this guide.

Our tool pages: Claude Code | Cursor | OpenAI Codex | GitHub Copilot | Model Context Protocol

What MCP is

The MCP site calls it "an open-source standard for connecting AI applications to external systems." (checked Oct 2026) It says AI apps can use it to connect to "data sources (e.g. local files, databases), tools (e.g. search engines, calculators) and workflows (e.g. specialized prompts)" (checked Oct 2026). Its own comparison: "Think of MCP like a USB-C port for AI applications." (checked Oct 2026)

Two kinds of server come up in all four tools:

Quick table (per the docs, checked Oct 2026)

ToolProject configGlobal configAdd from the terminalCheck it connected
Claude Code.mcp.json in the project root (--scope project)~/.claude.json (--scope user)claude mcp addclaude mcp list, claude mcp get <name>, or /mcp inside Claude Code
Cursor.cursor/mcp.json in the project~/.cursor/mcp.jsonNo terminal command in the docs; add servers from Customize or edit mcp.jsonCustomize in the sidebar; Output panel > "MCP Logs"
OpenAI Codex.codex/config.toml (trusted projects only)~/.codex/config.tomlcodex mcp addcodex mcp list, or /mcp in the Codex TUI
Copilot in VS Code.vscode/mcp.json (or .mcp.json at the workspace root)mcp.json in your VS Code user profile, or ~/.copilot/mcp-config.jsoncode --add-mcp"MCP: List Servers" > Show Output

One rule for all four: a project config file (.mcp.json, .cursor/mcp.json, .codex/config.toml, .vscode/mcp.json) lives in your repo and usually gets committed. Our advice, not a vendor quote: put keys and tokens in environment variables, and never write them into that file.

Claude Code

Anthropic's Claude Code MCP docs list three scopes:

The docs say "Each command writes to local scope unless you add --scope project or --scope user." (checked Oct 2026)

Add a remote server (NOT TESTED):

claude mcp add --transport http my-server https://mcp.example.com/mcp \
  --header "Authorization: Bearer YOUR_TOKEN"

Add a local server (NOT TESTED):

claude mcp add --transport stdio --env API_KEY=YOUR_API_KEY my-local-server -- npx -y your-mcp-server-package

The -- matters. Per the docs, "Everything after -- is passed to the server untouched." (checked Oct 2026)

Shared project file with no secrets in it (NOT TESTED). Claude Code expands environment variables in .mcp.json, so the token stays on each person's machine:

{
  "mcpServers": {
    "api-server": {
      "type": "http",
      "url": "https://mcp.example.com/mcp",
      "headers": {
        "Authorization": "Bearer ${YOUR_TOKEN_ENV_VAR}"
      }
    }
  }
}

The docs warn that "A JSON entry that has a url but no type is a configuration error" (checked Oct 2026), because Claude Code treats an entry with no type as a local stdio server.

Check that it connected. The docs list claude mcp list, claude mcp get <name>, claude mcp remove <name>, and /mcp inside Claude Code. Per the docs, claude mcp list shows a health status next to each server, such as Connected, Needs authentication, or Failed to connect. A project server from .mcp.json can show as "Pending approval" (checked Oct 2026) until you approve it in Claude Code.

Cursor

Cursor's MCP docs say you can "Install and manage MCP servers from the Customize page or configure them in mcp.json." (checked Oct 2026)

Local server (NOT TESTED):

{
  "mcpServers": {
    "my-local-server": {
      "type": "stdio",
      "command": "npx",
      "args": ["-y", "your-mcp-server-package"],
      "env": {
        "API_KEY": "${env:YOUR_API_KEY_ENV_VAR}"
      }
    }
  }
}

Remote server (NOT TESTED):

{
  "mcpServers": {
    "my-remote-server": {
      "url": "https://mcp.example.com/mcp",
      "headers": {
        "Authorization": "Bearer ${env:YOUR_TOKEN_ENV_VAR}"
      }
    }
  }
}

Cursor fills in ${env:NAME} and a few other variables in the command, args, env, url and headers fields. Cursor also supports one-click installs: "Click \"Add to Cursor\" on a marketplace entry to install it and authenticate with OAuth." (checked Oct 2026)

Check that it connected. You can "Enable or disable MCP servers from Customize in the sidebar." (checked Oct 2026) To debug, the docs say to "Open the Output panel in Cursor" (checked Oct 2026) and pick "MCP Logs", where you can "Check for connection errors, authentication issues, or server crashes". (checked Oct 2026)

Approvals: "Cursor asks for approval before using MCP tools by default." (checked Oct 2026)

OpenAI Codex

OpenAI's Codex MCP docs say "Codex stores MCP configuration in config.toml alongside other Codex configuration settings. By default this is ~/.codex/config.toml, but you can also scope MCP servers to a project with .codex/config.toml (trusted projects only)." (checked Oct 2026) The same setup is shared: "The ChatGPT desktop app, Codex CLI, and IDE extension share this configuration." (checked Oct 2026)

Add a local server from the terminal (NOT TESTED):

codex mcp add my-local-server --env API_KEY=YOUR_API_KEY -- npx -y your-mcp-server-package

Or edit config.toml (example layout built from the field names in OpenAI's docs, NOT TESTED). Each server gets its own [mcp_servers.<server-name>] table:

[mcp_servers.my-local-server]
command = "npx"
args = ["-y", "your-mcp-server-package"]
env_vars = ["YOUR_API_KEY_ENV_VAR"]

[mcp_servers.my-remote-server]
url = "https://mcp.example.com/mcp"
bearer_token_env_var = "YOUR_TOKEN_ENV_VAR"

env_vars lists environment variables Codex should "allow and forward" (checked Oct 2026), and bearer_token_env_var is the "Environment variable name for a bearer token to send in Authorization" (checked Oct 2026). Both keep the real token out of the file.

Check that it connected. "Run codex mcp list to see configured servers." (checked Oct 2026) In the terminal UI, "use /mcp to see your active MCP servers." (checked Oct 2026) For OAuth servers, run codex mcp login <server-name>. In the IDE extension and the ChatGPT desktop app, MCP servers are under settings, and "The server list shows which servers are enabled and which require OAuth." (checked Oct 2026)

Tool limits: per the docs, each server can set enabled_tools, disabled_tools and default_tools_approval_mode (checked Oct 2026).

GitHub Copilot in VS Code

VS Code's MCP server docs list several places for the config (per the docs, checked Oct 2026):

The docs say "Include workspace configuration in source control to share MCP servers with your team." (checked Oct 2026) So the same rule applies: keys go in environment variables or prompts, never in the committed file. VS Code's docs say "Avoid hardcoding sensitive information like API keys. Use input variables or environment files instead." (checked Oct 2026)

Workspace server in .vscode/mcp.json (NOT TESTED). The inputs block below asks you for the token instead of storing it in the file. VS Code's MCP configuration reference lists the input type promptString, which "opens an input box to ask the user for a free-text value" (checked Oct 2026), and lists a password field that hides typed input for API keys and passwords:

{
  "inputs": [
    { "type": "promptString", "id": "your-token", "description": "YOUR_TOKEN for the server", "password": true }
  ],
  "servers": {
    "my-remote-server": {
      "type": "http",
      "url": "https://mcp.example.com/mcp",
      "headers": { "Authorization": "Bearer ${input:your-token}" }
    }
  }
}

Add from the terminal (NOT TESTED). The docs show code --add-mcp with a JSON server config, which adds the server to your user profile:

code --add-mcp "{\"name\":\"my-server\",\"command\":\"uvx\",\"args\":[\"your-mcp-server-package\"]}"

You can also use the "MCP: Add Server" command, or install from the MCP server gallery in the Extensions view.

Trust. "Workspace MCP servers inherit Workspace Trust." (checked Oct 2026) The docs say to "Review workspace MCP configuration before you trust a repository because local MCP servers can run code on your machine." (checked Oct 2026)

Check that it connected. If a server has a problem, VS Code "shows an error indicator in the Chat view." (checked Oct 2026) To see logs, "run MCP: List Servers from the Command Palette, select the server, and then choose Show Output" (checked Oct 2026).

Safety notes

Only add servers you trust. Cursor's docs say "Only install MCP servers from trusted developers and repositories" (checked Oct 2026) and warn that "MCP servers can access external services and execute code on your behalf." (checked Oct 2026) VS Code's docs say "Local MCP servers can run arbitrary code on your machine. Only add servers from trusted sources" (checked Oct 2026). Anthropic's docs say "Verify you trust each server before connecting it. Servers that fetch external content can expose you to prompt injection risk." (checked Oct 2026)

Connect database servers with read-only access where you can. Supabase's MCP server has a read_only=true option that will "Execute all queries as a read-only Postgres user" (checked Oct 2026), and Supabase says production projects "can contain sensitive data. Before connecting one, scope the server to that project, enable read-only mode, restrict the available feature groups, and review the security risks." (checked Oct 2026)

Keep tokens out of committed config. Our advice, not a vendor quote: Claude Code's project .mcp.json lives in your repo and is meant for version control, so keys go in environment variables and never in that file. The same goes for Cursor's .cursor/mcp.json, Codex's .codex/config.toml and VS Code's .vscode/mcp.json whenever you commit them.

Anthropic suggests local scope for "servers with credentials you don't want in version control." (checked Oct 2026) Cursor says to "Use environment variables for Client ID and Client Secret instead of hardcoding them." (checked Oct 2026) Codex can save an OAuth client secret in config.toml, and OpenAI says to "Keep that file private and out of version control." (checked Oct 2026) For more on keeping secrets out of what your agent reads, see our AGENTS.md and CLAUDE.md guide.

Review permissions. Cursor's docs say "Review permissions: Check what data and APIs the server will access" (checked Oct 2026) and "Limit API keys: Use restricted API keys with minimal required permissions" (checked Oct 2026). Our advice, not a vendor quote: leave tool approvals on until you know what a server does.

Not affiliated with or endorsed by Anthropic, Anysphere (Cursor), OpenAI, GitHub, Microsoft or the Model Context Protocol project. Check each vendor's current docs before relying on these details.