Wire MCP servers into Claude Code
Configure shared MCP servers in a project's .mcp.json with environment-variable credentials, keep personal servers out of it, and pick resources, existing servers and better descriptions for described needs.
Scenario
Your platform team is building Developer Productivity with Claude tooling. Engineers explore legacy services with an agent that uses the built-in tools plus two MCP servers: the team's own build-insights server (flaky tests, slow builds) and an issue tracker.
Last sprint, one engineer added build-insights to the repository with the API token typed into the config. Another added a half-finished experiment to the same file, and now everyone gets an approval prompt for a server that fails to start.
Both problems come from putting the right server in the wrong place.
Explanation
Three scopes, three files. Claude Code stores an MCP server at one of three scopes:
| Scope | Loads in | Shared | Stored in |
|---|---|---|---|
| local (default) | this project only | no | ~/.claude.json, under the project's path |
| project | this project | yes, via git | .mcp.json in the project root |
| user | all your projects | no | ~/.claude.json |
Team tooling goes in project scope: commit .mcp.json and everyone gets the same servers. Claude Code asks each person to approve project servers before first use. Personal and experimental servers stay out of it: the docs suggest local scope for an experiment in one project and user scope for a personal tool you use everywhere. (The exam guide speaks of "user-level ~/.claude.json" for personal servers; local scope lives in the same file.) claude mcp add --scope project|user|local writes to the right place.
Credentials by reference. .mcp.json expands environment variables, so the file is shareable while the secret stays on each machine: ${VAR}, or ${VAR:-default} with a fallback. Expansion works in command, args, env, url and headers. An unset variable without a default produces a warning, not a secret.
All tools at once. Tools from every connected server are discovered when it connects and are available together, named mcp__<server>__<tool>. So descriptions matter here exactly as for your own tools: if build_insights_search is described as "Searches builds", the agent will keep reaching for Grep over log files. Say what the tool knows that Grep doesn't (test history across 6 months of CI runs) and what it returns.
Resources for catalogs. An MCP server can expose resources as well as tools. Claude Code can list and read them, and you can @-mention them. A catalog (the runbook tree, a database schema, open incident summaries) as a resource shows the agent what exists, so it doesn't spend calls guessing search terms.
Don't build what exists. For a standard integration (an issue tracker, an error monitor) use an existing MCP server; Claude Code connects to hundreds. Build a custom server for what only your team has, like build-insights.
Worked example
Before: the committed .mcp.json.
{
"mcpServers": {
"build-insights": {
"type": "http",
"url": "https://insights.internal.example/mcp",
"headers": { "Authorization": "Bearer bi_live_8f3k" }
},
"lena-scratch": {
"command": "node",
"args": ["/Users/lena/scratch/server.js"]
}
}
}
After: the token by reference, the experiment moved out.
{
"mcpServers": {
"build-insights": {
"type": "http",
"url": "https://insights.internal.example/mcp",
"headers": {
"Authorization": "Bearer ${BUILD_INSIGHTS_TOKEN}"
}
}
}
}
Lena re-adds her server with claude mcp add --scope local from her checkout, and the team rotates the leaked token, since it is still in git history.