Skip to content
AI Skills Central

Type to search Agent Skills, workflows, tutorials, tools and the glossary.

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.

By 4 min read
Bookmark

Bookmarks are kept in your free account, so you can find this page again on any device.

Sign in to bookmark
On 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). A url without type is treated as stdio and skipped.
  • ${VAR} and ${VAR:-default} expand in command, args, env, url and headers.
  • Servers published as Python packages use "command": "uvx" in place of npx; the uv commands cheat sheet shows how to run a server published on PyPI with uvx.
  • 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}.
  • envFile works for stdio servers only.
  • For OAuth with a pre-registered client, add "auth": { "CLIENT_ID": "${env:MCP_CLIENT_ID}" } to a url entry.

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

Covers

Back to top