Dev blog · Guides · 2026-11-18 · updated 2026-11-26
How to install MCP servers in Claude Code and Codex (2026 guide)
MCP (Model Context Protocol) servers give your coding agent new abilities: reading GitHub issues, driving a browser, querying Postgres, searching current docs. Claude Code and Codex both support them, but each has its own commands and its own config file. This guide covers both, end to end. For Cursor, GitHub Copilot, Gemini CLI and Claude Desktop, see the companion guide. On Windows or Linux, read the Windows guide or the Linux guide too: each has one fix that saves an hour.
The short version:
# Claude Code
claude mcp add context7 -- npx -y @upstash/context7-mcp
# Codex
codex mcp add context7 -- npx -y @upstash/context7-mcp
Then start a new session. Everything below explains the options, the config files, remote servers, and what to do when a server won’t start.
Local or remote?
There are two kinds of MCP server, and they install differently.
| Local (stdio) | Remote (HTTP) | |
|---|---|---|
| Where it runs | On your computer, started by your agent | On the publisher’s servers |
| How you add it | A command, like npx -y … or uvx … |
A URL |
| Needs | Node.js or Python, depending on the server | Usually a sign-in or an API key |
| Examples | Playwright, Filesystem, Git | Context7, Linear, Notion, Figma |
If a server’s README gives you a URL ending in /mcp, it’s remote. If it gives you an npx or uvx command, it’s local.
Claude Code
Add a local server
claude mcp add <name> -- <command> [args...]
The -- separates Claude Code’s own options from the server’s command. Pass API keys with --env:
claude mcp add --env AIRTABLE_API_KEY=your_key airtable -- npx -y airtable-mcp-server
Add a remote server
claude mcp add --transport http notion https://mcp.notion.com/mcp
If the server needs a key instead of a sign-in, add a header:
claude mcp add --transport http my-api https://api.example.com/mcp --header "Authorization: Bearer your-token"
Servers that sign you in with OAuth will open a browser the first time. You can also run /mcp inside a session, or claude mcp login <name> from the terminal. The older SSE transport (--transport sse) still works, but Anthropic has deprecated it in favour of HTTP.
Choose a scope
By default a server is added for the current project, only for you. The --scope flag changes that:
| Scope | Where it works | Shared with your team | Stored in |
|---|---|---|---|
local (default) |
This project | No | ~/.claude.json, under the project’s path |
project |
This project | Yes, via git | .mcp.json in the repo root |
user |
Every project | No | ~/.claude.json |
claude mcp add --scope user context7 -- npx -y @upstash/context7-mcp
Use project for servers your whole team should have, and user for personal tools you want everywhere.
Share a server with .mcp.json
A project-scoped server lives in a .mcp.json file you can commit:
{
"mcpServers": {
"context7": {
"command": "npx",
"args": ["-y", "@upstash/context7-mcp"]
},
"my-api": {
"type": "http",
"url": "${API_BASE_URL:-https://api.example.com}/mcp",
"headers": { "Authorization": "Bearer ${API_KEY}" }
}
}
}
Keep keys out of the file: ${VAR} and ${VAR:-default} are filled in from each person’s environment. The first time a teammate opens the project, Claude Code asks them to approve these servers. Until they do, claude mcp list shows them as pending.
Manage servers
claude mcp list # every server and whether it's connected
claude mcp get <name> # one server's details
claude mcp remove <name> # remove it (add --scope if it exists in several)
Inside a session, /mcp shows status and handles sign-ins.
Codex
Add a local server
codex mcp add <name> -- <command> [args...]
codex mcp add airtable --env AIRTABLE_API_KEY=your_key -- npx -y airtable-mcp-server
Add a remote server
codex mcp add notion --url https://mcp.notion.com/mcp
codex mcp login notion
Or edit config.toml
Codex keeps its servers in ~/.codex/config.toml. A trusted project can also have its own .codex/config.toml. Each server is a table:
[mcp_servers.context7]
command = "npx"
args = ["-y", "@upstash/context7-mcp"]
[mcp_servers.airtable]
command = "npx"
args = ["-y", "airtable-mcp-server"]
startup_timeout_sec = 20
[mcp_servers.airtable.env]
AIRTABLE_API_KEY = "your_key"
[mcp_servers.figma]
url = "https://mcp.figma.com/mcp"
bearer_token_env_var = "FIGMA_OAUTH_TOKEN"
Useful keys:
envsets variables for a local server.cwdsets its working folder.startup_timeout_sec(default 10) andtool_timeout_sec(default 60) give slow servers more time.enabled = falseturns a server off without deleting it.- For remote servers,
bearer_token_env_varnames an environment variable that holds your token, andhttp_headersadds fixed headers.
Check what’s loaded with codex mcp list, or /mcp inside a session.
When a server won’t start
It doesn’t show up at all. MCP servers load when a session starts. Quit and start a new session after adding one.
“Failed to connect”. Run the server’s command yourself in a terminal (for example npx -y @upstash/context7-mcp). If it errors there, the problem is the server or a missing runtime, not your agent. Local servers need Node.js for npx and Python with uv for uvx.
It works in your terminal but not in the agent. Your agent may not see the same PATH. Use the full path to npx or uvx, or install them where the agent can find them.
It’s slow to start. The first npx run downloads the package. In Codex, raise startup_timeout_sec.
It says it needs authentication. Run /mcp in the session, or claude mcp login <name> / codex mcp login <name>.
On Windows, Node servers that do nothing. Some Windows setups can’t launch npx directly from an agent’s config. Wrapping the command as cmd /c npx -y <package> is the usual fix.
Keep your MCP servers safe
A local MCP server is a program running with your permissions, and its tool descriptions are text your agent reads and trusts. Before installing one:
- Prefer verified publishers and repositories with real adoption.
- Pin a version (
@upstash/context7-mcp@1.2.3) so the code can’t change after you’ve looked at it. - Be wary of servers that ask for far more access than their job needs.
- Never paste API keys into a
.mcp.jsonyou commit. Use${VAR}instead.
More in Are Claude Code skills and plugins safe?
The one-click way
Calyban is a free desktop app that does everything above for you. Search for what you need (“GitHub”, “browser”, “Postgres”, or just “help me test my app”), press Install, and choose everywhere or one project folder. It:
- writes the right format for Claude Code (
~/.claude.jsonor.mcp.json) or Codex (config.toml), - asks for any API key and stores it only in your agent’s own config on your computer,
- handles the Windows launcher quirk,
- runs a safety check first, backs up your config, and gives you Undo.
The catalog lists over a thousand MCP servers, each with its own install page and the exact commands above filled in.
FAQ
Do I need Claude Desktop to use MCP servers with Claude Code? No. Claude Code and Claude Desktop have separate configs. Claude Code can import Desktop’s servers with claude mcp add-from-claude-desktop. Setting up Desktop itself is covered here.
Can Claude Code and Codex share the same servers? Not automatically. Each agent reads its own config, so you add a server to each. Calyban can install one into both.
Where are my Claude Code MCP servers stored? In ~/.claude.json for local and user scope, and in .mcp.json at the repo root for project scope.
Where are my Codex MCP servers stored? In ~/.codex/config.toml, plus .codex/config.toml in trusted projects.
Which MCP servers should I install first? See the best MCP servers for Claude Code and Codex. If you’re new to all this, start with what an MCP server actually is.