Get featured

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." 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)". Its own comparison: "Think of MCP like a USB-C port for AI applications."

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

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

Shared project file with no secrets in it (NOT TESTED). Claude Code expands environment variables in .mcp.json, including in url and headers, 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", 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. claude mcp list "shows a health status next to each server it lists, such as ✔ Connected , ! Needs authentication , or ✘ Failed to connect ." A project server from .mcp.json can show as "Pending approval" 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 ."

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

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

Approvals: "Cursor asks for approval before using MCP tools by default."

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)." The same setup is shared: "The ChatGPT desktop app, Codex CLI, and IDE extension share this configuration."

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", and bearer_token_env_var is the "Environment variable name for a bearer token to send in Authorization". Both keep the real token out of the file.

Check that it connected. "Run codex mcp list to see configured servers." In the terminal UI, "use /mcp to see your active MCP servers." 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."

Tool limits: per the docs, each server can set enabled_tools, disabled_tools and default_tools_approval_mode (per the docs, 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." 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."

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", and shows "password": true in its example:

{
  "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 ." The docs say to "Review workspace MCP configuration before you trust a repository because local MCP servers can run code on your machine."

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

Safety notes

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

Keep tokens out of committed config. 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." Cursor says to "Use environment variables for Client ID and Client Secret instead of hardcoding them." Codex can save an OAuth client secret in config.toml, and OpenAI says to "Keep that file private and out of version control." 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" and "Limit API keys : Use restricted API keys with minimal required permissions". 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.