Developer guide 03
MCP Config Locations for Coding Agents: Claude, Codex, Cursor, and GitHub Copilot
Find the right MCP config file for Claude Code, Codex, Cursor, and GitHub Copilot cloud agent, with commit-safe guidance and verification commands.
Developer guide 03
Find the right MCP config file for Claude Code, Codex, Cursor, and GitHub Copilot cloud agent, with commit-safe guidance and verification commands.
Quick answer
Find the right MCP config file for Claude Code, Codex, Cursor, and GitHub Copilot cloud agent, with commit-safe guidance and verification commands.
MCP configuration is not stored in one universal place. Claude Code, Codex, Cursor, and GitHub Copilot each decide where they read server definitions. If a server is not showing up, open the host-specific config first: .mcp.json for Claude project sharing, config.toml for Codex, .cursor/mcp.json for Cursor, and GitHub.com repository settings for Copilot cloud agent.
| Host | Personal or local config | Project or repository config | Commit this? | Verification |
|---|---|---|---|---|
| Claude Code | ~/.claude.json for local and user-scoped MCP servers | .mcp.json in the project root for project scope | Project .mcp.json can be committed if it contains no secrets | claude mcp list, claude mcp get <name>, /mcp |
| Codex | ~/.codex/config.toml | .codex/config.toml in trusted projects | Usually commit only if the team intentionally shares a project config and no secrets are embedded | codex mcp list, codex mcp --help, /mcp in the TUI |
| Cursor | ~/.cursor/mcp.json | .cursor/mcp.json | Project config can be committed if it is safe for every contributor | Cursor Settings, available tools list, restart Cursor |
| GitHub Copilot cloud agent | Not a local file for repository MCP | GitHub.com repository settings under Copilot MCP servers | No. Repository MCP JSON is saved in GitHub settings, not as a repo file | GitHub validates the JSON when saved |
The mental model is simple: MCP is the protocol, but the coding agent is the host. The host owns discovery, file format, approval behavior, and secret handling.
An MCP config tells the host how to reach a server. For a local stdio server, that usually means a command, arguments, working directory, and environment variables. For a remote server, it usually means a URL plus headers, OAuth, or bearer-token configuration.
The config does not guarantee that a tool will appear. A server can be configured correctly and still fail later because the command cannot start, a token is missing, the transport is wrong, or the server exposes resources and prompts but no tools. Treat config as the first layer, not the whole integration.
Claude Code has three everyday MCP scopes:
| Scope | Loads in | Stored in | Meilleure utilisation |
|---|---|---|---|
| Local | Current project only | ~/.claude.json, nested under the project path | Private local servers, credentials, experiments |
| Project | Current project only | .mcp.json in the project root | Shared team servers with no committed secrets |
| User | All projects for your user | ~/.claude.json | Personal tools you want everywhere |
Use the CLI when possible because it writes the correct shape:
claude mcp add --transport stdio filesystem --scope local -- npx -y @modelcontextprotocol/server-filesystem .
claude mcp add --transport http sentry --scope user https://mcp.sentry.dev/mcp
claude mcp add --transport http docs --scope project https://developers.openai.com/mcp
A project-scoped .mcp.json uses an mcpServers object:
{
"mcpServers": {
"shared-docs": {
"type": "http",
"url": "https://developers.openai.com/mcp"
}
}
}
Claude Code prompts before using project-scoped servers from .mcp.json. That approval step matters in real teams: a teammate may pull the file and still see the server as pending until they approve it.
Codex stores MCP configuration in config.toml. The default user-level file is:
~/.codex/config.toml
Codex can also read project-scoped config from:
<project-root>/.codex/config.toml
Project-scoped config only loads in trusted projects. That trust gate is intentional: a repository config can ask Codex to start local processes, forward environment variables, or connect to remote services.
Codex uses TOML, not JSON. Each MCP server gets a [mcp_servers.<server-name>] table:
[mcp_servers.context7]
command = "npx"
args = ["-y", "@upstash/context7-mcp"]
startup_timeout_sec = 20
tool_timeout_sec = 60
[mcp_servers.openaiDeveloperDocs]
url = "https://developers.openai.com/mcp"
Common copy-paste mistake: using Claude or Cursor's mcpServers JSON shape inside Codex. Codex expects the snake-case TOML table name mcp_servers, so [mcp.servers.foo] ou { "mcpServers": ... } will not load as a Codex MCP server.
Cursor uses mcp.json files:
~/.cursor/mcp.json
<project-root>/.cursor/mcp.json
Use the global file for personal tools and the project file for repo-specific tools. A typical Cursor config looks like this:
{
"mcpServers": {
"repo-docs": {
"command": "npx",
"args": ["-y", "@upstash/context7-mcp"],
"env": {
"API_KEY": "value"
}
}
}
}
If this is committed, do not commit actual token values. Prefer environment variable names, documented setup steps, or a checked-in example file when each developer must provide their own credential.
GitHub Copilot cloud agent is different from local desktop agents. Repository administrators configure MCP servers in GitHub.com repository settings, under the Copilot MCP servers page. The JSON is entered into GitHub's UI and validated when saved.
GitHub's config uses an mcpServers object, but each server must specify the tools it exposes to the agent. GitHub recommends allowlisting specific read-only tools because Copilot cloud agent can use MCP tools autonomously and does not ask for approval before each tool call.
Example shape:
{
"mcpServers": {
"internalDocs": {
"type": "http",
"url": "https://docs.example.com/mcp",
"tools": ["search_docs", "read_page"]
}
}
}
Secrets and variables for this path must use GitHub's Copilot agent secret and variable model. Referenced names must use the COPILOT_MCP_ prefix. Do not assume your local shell environment exists inside the cloud agent.
Local stdio servers are started as subprocesses by the host. They are useful when the server needs filesystem access, a local CLI, a local database tunnel, or a development-only service.
Remote HTTP servers are independent services at a URL. They are better for shared services, OAuth-backed tools, and systems that should not run on each developer's laptop.
| Decision | Prefer local stdio | Prefer remote HTTP |
|---|---|---|
| Needs local files or a local repo | Oui | Usually no |
| Needs a shared SaaS integration | Sometimes | Oui |
| Needs team-wide consistency | Only with careful setup docs | Usually yes |
| Contains machine-specific paths | Yes, but keep user-scoped | Non |
| Requires OAuth | Host-dependent | Usually better supported |
The MCP transport spec expects stdio servers to communicate over standard input and standard output, while Streamable HTTP servers expose an HTTP endpoint. That difference affects debugging: a broken local command is not the same class of problem as a bad remote URL.
Commit shared MCP config only when it is safe and useful for the whole team.
Commit:
Do not commit:
/Users/alex/dev/private-server.A good team pattern is to commit the project config only when the same server should load for everyone, then keep credentials in user scope, environment variables, a secrets manager, or host-specific secret storage.
Environment variables behave differently in shells, GUI apps, remote agents, and CI-like cloud environments. If an MCP server works in your terminal but not in the agent, the config may be fine while the host process has a different environment.
Use these checks:
which node
which npx
which uvx
printenv GITHUB_TOKEN
Then compare that with how the host starts the server. For local agents, absolute command paths often remove ambiguity:
{
"mcpServers": {
"local-tool": {
"command": "/opt/homebrew/bin/node",
"args": ["./server.js"],
"env": {
"API_KEY": "${API_KEY}"
}
}
}
}
For Copilot cloud agent, use GitHub's required COPILOT_MCP_ secret and variable prefix instead of assuming local environment variables.
The most common failure is copying a working server example into the wrong host format. Claude and Cursor examples often use JSON with mcpServers; Codex uses TOML with [mcp_servers.<name>]. That one difference is enough to make a server disappear.
The second failure is putting a team config in a personal location. A Claude local-scope server in ~/.claude.json will not help a teammate, even if it works perfectly on your machine.
The third failure is committing too much. A project .mcp.json ou .cursor/mcp.json can be a good team artifact, but only when it avoids secrets, private paths, and broad write tools.
The fourth failure is expecting Copilot cloud agent to behave like a local IDE. Its repository MCP config is controlled through GitHub settings, supports MCP tools, and uses GitHub-managed secrets and variables. A local ~/.cursor/mcp.json ou ~/.codex/config.toml has no effect there.