Back to all articles
TutorialDecember 1, 2026·10 min read

How to Set Up MCP Servers in Claude Code and Pick the Right Scope (2026)

You added an MCP server to Claude Code last week, and it worked. Today you open a different project and it's gone. A teammate says the server is in .mcp.json and you should have it already, but /mcp shows nothing. Another teammate has the same server name pointing somewhere else. You'd like to know where Claude Code keeps MCP config, what goes in .mcp.json, and which definition wins when there's more than one.

The short answer: Claude Code stores MCP servers at three scopes across two files. Anthropic's quickstart lays it out: local scope lives in ~/.claude.json under the entry for the current project, user scope lives in ~/.claude.json under the top-level mcpServers key, and project scope lives in .mcp.json at your project root. Local is the default. When the same server is defined in more than one place, Anthropic says: "The entire server entry from that source is used; fields are not merged across scopes." Local beats project, and project beats user.

This guide covers the three scopes, what goes in .mcp.json, how to add and move servers between scopes, how project servers get approved, how to keep secrets out of the file, which definition wins, and how to fix the common reasons a server doesn't show up.

The three MCP scopes in Claude Code

Anthropic's MCP page explains why scope matters: "The scope you choose controls which projects the server loads in and whether the configuration is shared with your team."

Local scope. The default. Anthropic's page says: "A local-scoped server loads only in the project where you added it and stays private to you." It's stored in ~/.claude.json under that project's path.

Project scope. Stored in .mcp.json at the project root and meant to be committed. Anthropic's page says to check it into version control "so everyone on your team gets the same MCP tools and services."

User scope. Stored in ~/.claude.json and available in all your projects, while staying private to you.

There's a naming trap here. Anthropic's page warns that local scope for MCP servers isn't the same as local settings: MCP local-scoped servers are stored in ~/.claude.json in your home directory, while general local settings use .claude/settings.local.json in the project.

What goes in .mcp.json

Every scope uses the same JSON shape for server entries. The quickstart says: "Every file in the scope table uses the same JSON format for server entries."

The file has one top-level key, mcpServers. Inside it, each server is an entry named after the server. The fields depend on the type:

  • For a remote HTTP server, set type to http and url to the endpoint.
  • For a local server, set type to stdio, command to the program to run, and args to its arguments.
  • For either, you can add env for environment variables, and HTTP servers can add headers.

Anthropic's quickstart explains the two field sets plainly: "For HTTP servers, url is the endpoint Claude Code connects to." and "For stdio servers, command and args are the program it runs."

Claude Code reads .mcp.json when a session starts, so after editing it, start a new session in the project.

Example entries to adapt

These are our examples, described as the entries you'd write. Replace names and addresses with your own.

A shared docs server for the team. In .mcp.json, add an entry named docs with type set to http and url set to your docs server's address. Commit the file.

A shared server that needs an API key. Add an entry named tickets with type set to http, url set to the server address, and a headers entry whose Authorization value uses a variable reference such as ${TICKETS_KEY}. Each teammate sets the variable on their own machine.

A local tool only you use. Don't put it in .mcp.json. Add it with the CLI at local scope, so it stays in ~/.claude.json for this project only.

A personal server for every project. Add it at user scope, so it's available wherever you open Claude Code.

Add and move servers with the CLI

You don't have to edit any file by hand. Anthropic's quickstart says claude mcp add writes the server to a configuration file and, by default, registers it at local scope. Pass --scope user or --scope project to choose otherwise.

The management commands:

  • claude mcp list lists configured servers.
  • claude mcp get <name> shows details for one server, including which scope holds it.
  • claude mcp remove <name> removes a server.
  • /mcp, inside a session, checks server status and lets you reconnect or authenticate.

Scope can't be edited in place. The quickstart says: "A server's scope is fixed when you add it, so changing scope means removing the entry and re-adding it at the new one." To share a local server with your team, remove it at local scope and add it again at project scope.

If a server's documentation gives you a JSON block for another client, Anthropic's page describes claude mcp add-json for adding it directly, with the same --scope flag.

How project servers get approved

Because .mcp.json comes from the repository, Claude Code asks before using it. Anthropic's page says: "For security reasons, Claude Code prompts for approval in interactive sessions before using project-scoped servers from .mcp.json files."

Until you approve, claude mcp list shows the server as pending approval. If you dismissed the prompt, the quickstart says to run claude mcp reset-project-choices and restart Claude Code to see it again.

There are cases where Claude Code can't show the prompt. Anthropic's page says that in non-interactive runs, Agent SDK sessions, and some cloud sessions, it loads project-scoped servers without asking. To keep a server out anyway, the page lists options, including the disabledMcpjsonServers setting, which blocks it in every permission mode.

Keep secrets out of .mcp.json

Since .mcp.json is committed, secrets don't belong in it. Claude Code expands environment variables instead. Anthropic's page says you can reference a variable in a server's command, args, env, url, or headers value, in two forms: ${VAR} for the variable's value, and ${VAR:-default} for a fallback when it's unset.

If a variable isn't set and has no default, the config still loads, but Claude Code reports a missing-variable warning in claude mcp list and uses the text as written.

There's a safety rule for remote servers. Anthropic's page says Claude Code reads certain credential variables, such as its own API keys and cloud provider tokens, as empty in a remote server's url and headers. The page explains why: "This keeps a project's .mcp.json or a plugin from sending your Claude Code or cloud provider credentials to a server it names." If a server needs one of those values, the page says to copy it into a variable with your own name and reference that.

Listings help too. Anthropic's page says claude mcp list, claude mcp get, and the /mcp detail view show a ${VAR} reference by name rather than as its resolved value.

Which definition wins

When the same server appears in more than one place, Claude Code connects once. Anthropic's page says it uses the definition from the highest-precedence source, in this order: local scope, project scope, user scope, plugin-provided servers, and claude.ai connectors.

Two details are easy to miss:

  • No merging. The whole entry from the winning scope is used, so you can't put the URL in .mcp.json and headers in your local scope.
  • Matching rules differ. Anthropic's page says Claude Code matches duplicates across the three scopes by name, and matches plugins and connectors by endpoint.

If you define the same name in more than one scope with different endpoints, Claude Code warns about the conflict in claude mcp list and in /mcp. The page suggests keeping the endpoint you want and removing the others with claude mcp remove and the --scope flag.

Organizations can also provide servers through managed settings. Anthropic's page says those rank above all of the others.

For how scopes work in Claude Code's general settings files, see our guide to Claude Code settings.json examples.

Why a server doesn't show up

Anthropic's troubleshooting section names the common causes when /mcp shows no servers:

  • You added it from a different project. Local-scoped servers are tied to the project where you added them.
  • You edited the wrong file. The quickstart says the correct files are ~/.claude.json and .mcp.json in your project, and that Claude Code doesn't read paths such as ~/.claude/.mcp.json or ~/.claude/mcp.json.
  • The entry is malformed. Claude Code skips that entry, still loads the others, and shows a parse warning in claude mcp list.

And if a project server shows as pending, it's waiting for your approval in an interactive session.

What people try first

Adding a server and expecting it in every project. The default is local scope, tied to one project.

Editing ~/.claude/mcp.json. Claude Code doesn't read that path.

Putting API keys in .mcp.json. Use ${VAR} references and set the variables on each machine.

Splitting one server across scopes. Fields aren't merged; the whole winning entry is used.

Changing a server's scope in place. Remove it and add it again at the new scope.

Wondering why a teammate's server isn't connecting. They may need to approve it from .mcp.json first.

The Fix: Organize MCP config in Claude Code

Step 1: Decide each server's scope

Team servers go in .mcp.json, personal ones at user scope, and one-project experiments at local scope.

Step 2: Write .mcp.json with variables

Use ${VAR} or ${VAR:-default} for anything secret or machine-specific, and commit the file.

Step 3: Check status and conflicts

Run claude mcp list and /mcp, approve project servers, and remove duplicate names you don't want.

Step 4: Write down why each server exists

Note what each server is for and who maintains it, in your own words, outside the config.

Setting this up in MemoryLake

.mcp.json tells Claude Code how to reach a server. The reasons behind your team's setup, such as why one server is project-wide and another is personal, or which variables each teammate needs, are context worth keeping where other assistants and teammates can find it.

MemoryLake is a memory layer for that kind of context, kept in one place you maintain and available to the assistants you connect, such as ChatGPT, Claude Code, and Codex.

You write the entries yourself, in your own words. Nothing is read out of, written to, or deleted from your .mcp.json, your ~/.claude.json, your MCP servers, your Claude Code sessions, or any vendor's store. Claude Code's MCP scopes work the way Anthropic describes them.

Step 1: Create an API key

Sign in and generate a key from the dashboard. Keep it somewhere private.

The MemoryLake console showing the API keys screen, where a new key is created and copied for use in an agent
The MemoryLake console showing the API keys screen, where a new key is created and copied for use in an agent

Step 2: Upload your first memories

Start with what you wrote in Step 4 of the fix: what each server is for and what it needs. One topic per entry.

The MemoryLake workspace with the first documents uploaded, listing each file as it becomes searchable memory
The MemoryLake workspace with the first documents uploaded, listing each file as it becomes searchable memory

Step 3: Connect your AI & agents

Connect ChatGPT, Claude Code, Codex, and the other assistants you use, so the same context is there in each.

The MemoryLake integrations screen listing the AI clients and agent frameworks that can be connected to the memory layer
The MemoryLake integrations screen listing the AI clients and agent frameworks that can be connected to the memory layer

What this changes in practice

The first difference is faster onboarding. A new teammate knows which variables to set and why.

The second is fewer conflicts. When everyone knows which scope a server belongs in, duplicate names are less likely.

The third is reach. The reasoning is available outside Claude Code too.

Best practices for Claude Code MCP config

Commit .mcp.json for team servers. It's the only scope shared through the repository.

Keep personal servers at user scope. They follow you across projects.

Use variables for secrets. ${VAR} keeps keys out of the file.

Avoid duplicate names across scopes. The whole winning entry is used.

Check with claude mcp get. It shows which scope holds a server.

Approve project servers deliberately. Review .mcp.json before approving.

Conclusion

Claude Code keeps MCP servers at three scopes. Local scope, the default, lives in ~/.claude.json for one project. User scope lives in ~/.claude.json for all your projects. Project scope lives in .mcp.json at the project root, is shared through version control, and needs approval in interactive sessions. All three use the same JSON shape, with mcpServers entries using url for HTTP servers and command and args for local ones.

When the same server appears in more than one place, local wins over project, project over user, and the whole entry from the winning scope is used. Environment variable references keep secrets out of .mcp.json. Writing down why each server is set up the way it is keeps that knowledge available to your team and the other assistants you use.

Frequently asked questions

Where is .mcp.json in Claude Code?

At your project root. It holds project-scoped servers that you commit to version control.

Where are local and user MCP servers stored?

Both are in ~/.claude.json: local servers under the entry for one project, user servers under the top-level mcpServers key.

Which MCP scope does Claude Code use by default?

Local scope. Pass --scope user or --scope project to change it.

Which definition wins if a server is in more than one scope?

Local, then project, then user. The whole entry from the winning scope is used.

How do I put an API key in .mcp.json safely?

Reference an environment variable with ${VAR} and set it on each machine.

Why doesn't my project MCP server connect?

It may be waiting for approval. Start Claude Code interactively and approve it, or run claude mcp reset-project-choices and restart.

Can I change a server's scope?

Not in place. Remove it and add it again at the new scope.