Cheat sheet
MCP config cheat sheet
Where Claude Code, Codex and Cursor keep MCP server config, with copyable JSON and TOML for local and remote servers, secrets, scopes and OAuth commands.
Bookmark
Bookmarks are kept in your free account, so you can find this page again on any device.
Sign in to bookmarkOn this page
File locations and copyable snippets for adding MCP servers to the three coding agents our readers use most. Checked against each tool’s documentation on 20 November 2026. For the walkthrough with explanations, see Connect MCP servers to Claude Code, Codex and Cursor.
Where the config lives
| Client | Project (share via Git) | Personal | Format |
|---|---|---|---|
| Claude Code | .mcp.json (scope project) |
~/.claude.json (scopes local and user) |
JSON, mcpServers |
| Codex | .codex/config.toml (trusted projects only) |
~/.codex/config.toml |
TOML, [mcp_servers.<name>] |
| Cursor | .cursor/mcp.json |
~/.cursor/mcp.json |
JSON, mcpServers |
Add from the command line
# Claude Code: local (stdio) server; everything after -- is the command
claude mcp add context7 -- npx -y @upstash/context7-mcp
# Claude Code: remote server (Streamable HTTP)
claude mcp add --transport http sentry https://mcp.sentry.dev/mcp
# Claude Code: with an environment variable, shared with the team
claude mcp add --scope project --env API_KEY=xxx --transport stdio my-server -- npx -y my-mcp-server
# Codex: local and remote
codex mcp add context7 -- npx -y @upstash/context7-mcp
codex mcp add sentry --url https://mcp.sentry.dev/mcp
# Codex: with an environment variable
codex mcp add my-server --env API_KEY=xxx -- npx -y my-mcp-server
Cursor has no add command for project config; edit the JSON file or use its settings UI.
Claude Code: .mcp.json
{
"mcpServers": {
"context7": {
"command": "npx",
"args": ["-y", "@upstash/context7-mcp"]
},
"sentry": {
"type": "http",
"url": "https://mcp.sentry.dev/mcp"
},
"internal-api": {
"type": "http",
"url": "${API_BASE_URL:-https://api.example.com}/mcp",
"headers": { "Authorization": "Bearer ${INTERNAL_API_TOKEN}" }
}
}
}
- Remote entries need
"type": "http"("streamable-http"is accepted as an alias). Aurlwithouttypeis treated as stdio and skipped. ${VAR}and${VAR:-default}expand incommand,args,env,urlandheaders.- Servers published as Python packages use
"command": "uvx"in place ofnpx; the uv commands cheat sheet shows how to run a server published on PyPI withuvx. - Per-server tool timeout:
"timeout": 600000(milliseconds). - Pin OAuth scopes:
"oauth": { "scopes": "read:issues" }.
Codex: config.toml
[mcp_servers.context7]
command = "npx"
args = ["-y", "@upstash/context7-mcp"]
env = { MY_FLAG = "1" }
startup_timeout_sec = 20
tool_timeout_sec = 60
[mcp_servers.sentry]
url = "https://mcp.sentry.dev/mcp"
[mcp_servers.internal-api]
url = "https://api.example.com/mcp"
bearer_token_env_var = "INTERNAL_API_TOKEN"
enabled_tools = ["search", "get_record"]
| Key | Meaning |
|---|---|
command, args, env, cwd |
Start a stdio server |
env_vars |
Names of variables to forward from your environment |
url |
Streamable HTTP endpoint |
bearer_token_env_var |
Variable holding a bearer token |
http_headers, env_http_headers |
Static headers, or headers read from variables |
startup_timeout_sec |
Default 10 |
tool_timeout_sec |
Default 60 |
enabled_tools, disabled_tools |
Allow and deny lists of tool names |
enabled |
false to switch a server off without deleting it |
required |
true to fail start-up if the server is not ready |
Cursor: .cursor/mcp.json
{
"mcpServers": {
"context7": {
"command": "npx",
"args": ["-y", "@upstash/context7-mcp"],
"envFile": "${workspaceFolder}/.env"
},
"sentry": {
"url": "https://mcp.sentry.dev/mcp"
},
"internal-api": {
"url": "https://api.example.com/mcp",
"headers": { "Authorization": "Bearer ${env:INTERNAL_API_TOKEN}" }
}
}
}
- Variables use
${env:NAME}; also available:${userHome},${workspaceFolder},${workspaceFolderBasename}. envFileworks for stdio servers only.- For OAuth with a pre-registered client, add
"auth": { "CLIENT_ID": "${env:MCP_CLIENT_ID}" }to aurlentry.
Manage and authenticate
| Task | Claude Code | Codex | Cursor |
|---|---|---|---|
| List servers | claude mcp list |
codex mcp list |
Settings, MCP section |
| In-session status | /mcp |
/mcp |
Settings, MCP section |
| OAuth sign-in | /mcp, or claude mcp login <name> |
codex mcp login <name> |
Sign-in button on the server |
| Sign out | claude mcp logout <name> |
Settings | |
| Remove | claude mcp remove <name> |
Delete the table from config.toml |
Delete the entry |
| Reset project approvals | claude mcp reset-project-choices |
Test a server without an agent
# stdio server
npx @modelcontextprotocol/inspector npx -y @upstash/context7-mcp
# remote server: start Inspector, then choose Streamable HTTP and enter the URL
npx @modelcontextprotocol/inspector
Transports in one line each
- stdio: the client starts the server as a subprocess. For local servers. Never print to stdout from the server except protocol messages.
- Streamable HTTP: one HTTP endpoint, each message a POST. For remote servers. Use OAuth.
- HTTP+SSE: deprecated since 2025. Migrate; see Migrate an MCP server from HTTP+SSE to Streamable HTTP.
Safety reminders
- Pin versions in
args(@1.2.3, not@latest) for anything you rely on. - Keep secrets in environment variables, not in committed files.
- Enable only the servers a project needs.
- Read MCP security before connecting servers that read untrusted content.
Next steps
- Get the concepts behind the config in what is MCP? The Model Context Protocol explained.
- Protect your own remote server with secure a remote MCP server with OAuth.
- Find each agent’s other settings in the coding agent cheat sheet.
Covers
Related
- Connect MCP servers to Claude Code, Codex and Cursor
Add local and remote MCP servers to Claude Code, Codex and Cursor, choose the right scope, sign in with OAuth and check which tools actually loaded.
- MCP explained: hosts, clients, servers and transports
What MCP is and how the Model Context Protocol connects AI apps to tools and data: hosts, clients, servers, transports and what the 2026-07-28 spec changed.
- Coding agents side by side: Claude Code, Codex and Cursor
The same task in Claude Code, Codex CLI and Cursor, in one table per topic: start, commands, instruction files, skill folders, MCP setup and permissions.
- MCP security: tool poisoning, token scope and the lethal trifecta
The real attacks on MCP setups, from tool poisoning and rug pulls to token passthrough and the lethal trifecta, what hosts do about them, and a checklist.
- MCP Inspector
Browser-based tester that connects to an MCP server and calls its tools by hand.