An MCP (Model Context Protocol) server is a small program that connects Claude Code to an outside tool like issue tracking or a database (in the glossary). Putting the servers your team uses into the .mcp.json file in the repo takes one command. The hard part starts the moment the file reaches a teammate's machine, because there the server waits for approval the first time it opens, and the repo can't give that approval itself. A token you write into the file is also open to everyone who reads the repo. Which of that server's tools the agent uses without asking is a separate setting. The command and setting names come from Claude Code's MCP docs.

Which file a server sits in

The scope is which file a server definition is written to and who it affects.

ScopeFileWho it affects
local, the default~/.claude.jsonOnly you, only in this project
project.mcp.json in the project rootEveryone who clones the repo, once committed
user~/.claude.jsonYou, in all your projects

If you don't give claude mcp add a scope, the server stays on your machine as local and nobody on the team sees it.

If the same name is defined in more than one place, Claude Code looks at the local definition first, then project, then user, and after those at the servers plugins bring and the connectors in claude.ai. The winning definition is used on its own, and its fields aren't merged with the others. If a teammate has an old local server with the same name on their own machine, the definition in the repo never runs for them.

Put the team server in .mcp.json

For a server that connects to a remote address, use the http transport and give it the project scope.

claude mcp add --transport http shared-server --scope project https://example.com/mcp

The command writes this file in the project root. Commit it.

{
  "mcpServers": {
    "shared-server": {
      "type": "http",
      "url": "https://example.com/mcp"
    }
  }
}

A server that starts as a program on your machine is added with the stdio transport. The -- here separates Claude Code's own options from the command that starts the server, so --transport, --env and --scope have to come before it.

claude mcp add --env KEY=value --transport stdio myserver -- python server.py --port 8080

Pass secrets without putting them in the repo

Don't write the token into .mcp.json, or into the claude mcp add command with --header. A value in the command also ends up in the terminal's command history. Write the name of an environment variable in the file instead, one of the name and value pairs the terminal hands to the programs it starts. Claude Code expands ${VAR}, and ${VAR:-default} with a default, in the command, args, env, url and headers fields.

{
  "mcpServers": {
    "api-server": {
      "type": "http",
      "url": "${API_BASE_URL:-https://api.example.com}/mcp",
      "headers": {
        "Authorization": "Bearer ${API_KEY}"
      }
    }
  }
}

Only the variable's name sits in the file, and every teammate sets the value on their own machine. For someone who hasn't defined the variable and gave no default, the server still loads, but the header goes out with the literal text ${API_KEY}. claude mcp list shows this as a warning. An empty value counts as set.

Pick a variable name specific to the server. In the url or headers field of a remote server, well-known credential names like ANTHROPIC_API_KEY, AWS_BEARER_TOKEN_BEDROCK, HTTPS_PROXY or NPM_TOKEN are read as empty even when they're set. A name like API_KEY expands as it is.

This approach assumes everyone carries their own key. If the team shares the key of a single service account, the repo fix isn't enough. The path the docs recommend then is per-user OAuth, the authorization flow where each person signs in with their own account, or settings an admin distributes (managed MCP). For keeping the key short-lived, see the company data guide, and for what an API key is, see the glossary.

The approval on first open

When a teammate opens the repo, Claude Code asks them before using each project server in .mcp.json. To reset the answers they gave, there's claude mcp reset-project-choices. Before you approve, make sure you trust the server itself. The docs' warning is about servers that pull in outside content, "Servers that fetch external content can expose you to prompt injection risk." Prompt injection is an instruction hidden in content the agent reads that tries to give it work.

Three keys answer this question in advance through settings. enableAllProjectMcpServers approves all of them without asking, enabledMcpjsonServers approves the ones named, and disabledMcpjsonServers rejects the ones named.

If the first two are written into the repo's .claude/settings.json and committed, they're ignored in an untrusted folder and the server waits as Pending approval. The docs give the reason in one sentence, "a cloned repository can't approve its own servers". Approval counts only when it comes from the teammate's own ~/.claude/settings.json, from the managed settings, or from a file passed with --settings. A rejection works from any file, so disabledMcpjsonServers can turn a server off from the repo too.

For a small team, my suggestion is to keep .mcp.json in the repo, turn off any unwanted server with disabledMcpjsonServers, and leave the approval to each person's own settings. The docs don't describe a separate path for small teams.

Permission rules decide which tools the agent touches

Which of a server's tools the agent uses without asking, and which it can never touch, is decided by the permissions key in settings.json (permission rules, in the glossary).

RuleWhat it covers
mcp__issues__*All tools of the issues server
mcp__issuesThe same thing, the whole server
mcp__issues__create_issueOnly one tool
mcp__plugin_acme_issues__*The issues server that the acme plugin brings

In the example below, the read tool runs without asking and the delete tool never runs. Tool names come from the server itself, and the ones here are placeholders.

{
  "permissions": {
    "allow": [
      "mcp__issues__search_issues"
    ],
    "deny": [
      "mcp__issues__delete_issue"
    ]
  }
}

In an allow rule, the star works only after the full server name. An allow rule like mcp__* is skipped and approves nothing, while on the deny side "mcp__*" turns off every MCP tool. If the server name has a dot or a space, it becomes an underscore in the rule, so for my.server you write mcp__my_server__*. An mcp__ rule with parentheses is skipped in the settings file. If you need a rule based on a tool's parameter, use --disallowedTools.

These rules are the MCP counterpart of the Bash(...) and Read(...) rules in the permission list guide, and the limits of the deny list are covered there too.

Managed settings once the team grows

The managed settings are a file an admin distributes to computers, sitting above user settings. To distribute MCP servers all at once there's managed-mcp.json, a standalone file in the same format as .mcp.json. It sits at /Library/Application Support/ClaudeCode/managed-mcp.json on macOS, /etc/claude-code/managed-mcp.json on Linux and WSL, and C:\Program Files\ClaudeCode\managed-mcp.json on Windows. While this file exists, it has full control of MCP servers, and claude mcp add gives this error.

Cannot add MCP server: enterprise MCP configuration is active and has exclusive control over MCP servers

Everyone on the machine can read the file, so don't put secrets in it. Use ${VAR}, OAuth or per-user headers.

In v2.1.259 and later, servers can also be provided with the managedMcpServers setting. This path accepts only http or sse servers with an https:// address, and it doesn't expand ${VAR}.

Which servers can be used is decided by the allow and deny lists. Each entry carries one key, serverUrl (accepts a star), serverCommand (the full command) or serverName.

{
  "allowManagedMcpServersOnly": true,
  "allowedMcpServers": [
    { "serverUrl": "https://mcp.example.com/*" },
    { "serverUrl": "https://*.internal.example.com/*" },
    { "serverCommand": ["python", "/usr/local/bin/approved-server.py"] }
  ],
  "deniedMcpServers": [
    { "serverUrl": "https://*.untrusted.example.com/*" }
  ]
}

If allowedMcpServers isn't written at all, every server is allowed, while an empty list allows none. The allow list is locked only with allowManagedMcpServersOnly. Without that setting, a user can extend the list with their own settings, and the deny list is merged from every scope. allowManagedPermissionRulesOnly is a separate setting and doesn't lock the MCP allow list.

Don't build the list with serverName. The docs say it plainly, "A serverName entry, in either list, is not a security control." The name is a label the user gives the server, and what limits the actual server is serverUrl or serverCommand.

Claude Code has no built-in registry of approved servers. The docs suggest sharing the approved list on a wiki or distributing it through a managed plugin marketplace, and setting up a marketplace is in the skill sharing guide. If you want to see which server and tool were used, OpenTelemetry, the open standard applications use to send metrics and logs, also writes the server and tool names with OTEL_LOG_TOOL_DETAILS=1.

MCP in claude -p and CI

claude -p runs Claude Code non-interactively. It writes the answer and exits, and that's how it's used in a script or in CI. The same goes for the Agent SDK, the developer library for running Claude Code from inside your own program. Because the approval prompt can't be shown in these runs, Claude Code loads project servers without asking ("loads project-scoped servers without asking"), so in a CI job every server in .mcp.json is open to the agent.

One way to prevent this is disabledMcpjsonServers. --setting-sources user opens the run with user settings only, and --strict-mcp-config uses only the servers you pass with --mcp-config and ignores every other MCP definition. If an admin set up a managed-mcp.json on the machine, Claude Code doesn't open at all with this flag, and the allow and block lists still apply to the --mcp-config servers (CLI reference, managed MCP).

From here

To write down role by role what the agent can touch, there's the permission list guide. For the rules that govern the data going to an MCP server, there's the company data guide.

In TeamHandbook Orchestrator, when you start a new task, you can leave an MCP server that fetches outside content out of that task. A policy that turns off a server or one of its tools for the whole team is merged into the team repo's .teamhandbook.json, the way skills are. The TeamHandbook plugin then applies it in every teammate's session. The orchestrator's details are on the TeamHandbook Orchestrator page, the policies' in TeamHandbook's security document.