Skip to content
86% off$349 $48.86code BF2026

Guides

How to Add MCP Servers to Claude Code (Commands and Scopes)

Exact claude mcp add commands for stdio and HTTP servers, how scopes work, where tokens are stored, and how to share one server list across several agents.

GuideUpdated 9 min read

On this page

To add a local MCP server to Claude Code, run claude mcp add <name> -- <command> [args...]. For a remote server, run claude mcp add --transport http <name> <url>. Then run claude mcp list to check that it connects.

By default, a server is saved for you in the current project only. Add --scope project to share it with your team through a .mcp.json file in the repo. Add --scope user to use it in every project.

The commands below follow Claude Code's CLI as of November 2026. If a flag is rejected, claude mcp add --help shows the current syntax.

What MCP gives Claude Code

MCP (Model Context Protocol) lets Claude Code call tools that aren't part of its built-in set. An MCP server provides those tools. A server might drive a browser, query a database, read issues from your tracker or check errors in your monitoring service. Claude Code starts the server or connects to it, sees its tools, and calls them when a task needs them. It asks your permission before using an MCP tool, the same way it does for its built-in tools.

You will use one of two transports:

  • stdio: a local program that Claude Code starts on your Mac, usually through npx, uvx or a binary path. It talks over standard input and output.
  • HTTP: a server that runs somewhere else and that you reach by URL. Hosted services often offer one, with OAuth sign-in or a bearer token.

An older SSE transport also exists (--transport sse). When a service offers both, use HTTP.

Add a local stdio server

The general form is:

bash
claude mcp add [options] <name> -- <command> [args...]

Put all options (--transport, --scope, --env, --header) before the name. The -- marks where the server's own command starts. Without it, flags such as -y would be read as Claude Code options.

Example: add the Playwright browser server to the current project.

bash
claude mcp add playwright -- npx -y @playwright/mcp@latest

This saves a server named playwright. Claude Code starts it with npx whenever you open a session in this folder.

If the server needs a key, pass it as an environment variable with --env (short form -e):

bash
claude mcp add --env API_KEY=your-key-here myserver -- npx -y some-mcp-server

This saves API_KEY with the server, and Claude Code sets it each time it starts the process. The value is stored as plain text in Claude Code's config. The token section below shows how to avoid that.

To remove a server:

bash
claude mcp remove playwright

This deletes the entry. If the server is saved in a scope other than the default, add --scope.

Add a remote HTTP server

bash
claude mcp add --transport http <name> <url>

Example: GitHub's hosted MCP server, signed in with a token header.

bash
claude mcp add --transport http --header "Authorization: Bearer $GITHUB_TOKEN" github https://api.githubcopilot.com/mcp/

This adds a remote server named github and sends the header with every request. Because of the double quotes, your shell replaces $GITHUB_TOKEN with its value before Claude Code runs. The real token is what gets saved in the config.

Some remote servers use OAuth instead of a pasted token. Add the server without a header, start Claude Code, and run /mcp inside the session. Pick the server and complete the sign-in in your browser. The token is not added to the server entry.

Claude Code MCP scopes: local, project and user

Every server belongs to one scope. The scope decides where the entry is saved and who gets the server.

ScopeFlagSaved inWho gets it
Local (default)--scope local or no flag~/.claude.json, under this project's pathYou, in this project only
Project--scope project.mcp.json at the project rootEveryone who uses the repo, after they approve it
User--scope user~/.claude.jsonYou, in every project

Three things to know:

  • Local scope belongs to the folder where you ran the command. If you add a server in one repo and then open Claude Code in another, the server won't be there.
  • Project scope is meant to be committed. Claude Code asks each person to approve a project's servers before it uses them. If someone declined by mistake, claude mcp reset-project-choices clears those answers.
  • The same name in two scopes: local beats project, and project beats user.

Use user for personal tools you want everywhere, such as a docs lookup or a browser. Use project for servers the whole team needs for this codebase, such as its database or its issue tracker. Use local for experiments and for anything that carries your personal credentials.

Keep API tokens out of project files

Anything you pass with --env or --header is saved exactly as written. For local and user scope, that file is ~/.claude.json in your home folder. It isn't part of your repo, but the token is still plain text. For project scope, the file is .mcp.json, which you are about to commit.

Use variable expansion in .mcp.json

When Claude Code loads .mcp.json, it expands ${VAR} and ${VAR:-default}. Commit the variable name, and let each person keep the value in their own environment:

json
{
  "mcpServers": {
    "github": {
      "type": "http",
      "url": "https://api.githubcopilot.com/mcp/",
      "headers": {
        "Authorization": "Bearer ${GITHUB_TOKEN}"
      }
    },
    "playwright": {
      "type": "stdio",
      "command": "npx",
      "args": ["-y", "@playwright/mcp@latest"]
    }
  }
}

You can also write the entry from the command line. Single quotes stop your shell from expanding the variable, so the literal ${GITHUB_TOKEN} is saved:

bash
claude mcp add --scope project --transport http --header 'Authorization: Bearer ${GITHUB_TOKEN}' github https://api.githubcopilot.com/mcp/

This writes the github entry into .mcp.json with the variable name in place of the token.

If a variable has no value and no default, Claude Code can't load that config. Set the variable in the shell you start Claude Code from.

Keep the value in the macOS Keychain

Putting export GITHUB_TOKEN=... in ~/.zshrc just moves the plain-text token into a different file. A better option is to store it in your login Keychain and read it when the shell starts.

bash
security add-generic-password -a "$USER" -s github-mcp -w

This asks you to type the token, then saves it in your login Keychain under the name github-mcp.

Then add this line to ~/.zshrc:

bash
export GITHUB_TOKEN="$(security find-generic-password -s github-mcp -w)"

This reads the token from the Keychain each time a new shell starts.

To undo this, remove that line from ~/.zshrc and delete the Keychain item:

bash
security delete-generic-password -s github-mcp

This removes the saved token from your Keychain.

Check that a server works

From the terminal:

bash
claude mcp list

This lists every server Claude Code can see from the current folder and shows whether each one connects.

bash
claude mcp get github

This shows one server's scope, its command or URL, and its settings.

Inside a Claude Code session, run /mcp. It shows each server's status and the tools each server provides, and it lets you finish an OAuth sign-in. Then ask for something only that server can do, such as "Open example.com in the browser and read the page title." Claude Code should ask permission to use the server's tool.

Changes apply to new sessions. If you add a server while Claude Code is running, quit Claude Code and start it again.

If it doesn't work

  • The server isn't in claude mcp list. You are probably in a different folder from the one where you added a local-scope server. Run the command from that project's root, or add the server again with --scope user.
  • A stdio server fails to connect. Either the command isn't found or it exits right away. Run the exact command yourself in Terminal (for example npx -y @playwright/mcp@latest) and read the error. If npx comes from nvm or asdf and isn't on the PATH Claude Code sees, use the full path. which npx prints it.
  • Your flags were swallowed. If you put options after the name, or left out --, they go to the wrong program. Put every Claude Code option before the name, and the server's command after --.
  • A project server is ignored. It is still waiting for approval, or someone declined it. Start a session to see the prompt, or run claude mcp reset-project-choices.
  • The server starts slowly and times out. Raise the startup timeout for one run with MCP_TIMEOUT=10000 claude. The value is in milliseconds.
  • A remote server returns 401. The token is missing or expired, or ${VAR} wasn't set when Claude Code started. Run echo $GITHUB_TOKEN in the same shell to check, or use /mcp to sign in again.

Share servers across several agents

claude mcp add only sets up Claude Code. Codex, Gemini CLI and OpenCode each keep their own MCP config, in their own format. If you use several of them, you add the same server three or four times and copy the same token into each file.

Sledbot, our agent workspace for the Mac, keeps one list instead. You connect a server once in Settings ▸ Integrations. Each time an agent starts, Sledbot generates an MCP config for that agent in the agent's own format. This works for Claude Code, Codex, Gemini CLI, Qwen Code, OpenCode, Crush and Goose.

  1. Open Settings with ⌘, (Command-Comma) and choose Integrations.
  2. Find a server with Search integrations, or choose Custom server to add any stdio command or HTTP URL.
  3. Click Configure…. For a custom server, set Type to Local command (stdio) or Remote (HTTP). Then fill in Command (for example npx -y @scope/server) or the server's URL.
  4. Add tokens under Secrets.
  5. Turn on Enabled. The server then shows "On for new agents". Its status reads Ready, Needs token, Needs connection or Sign in on first use.
  6. Start a new agent with ⌘T (Command-T). Servers are added when an agent launches, so agents that are already running don't pick up the change.
Sledbot editor for the connected GitHub MCP server: HTTP URL, personal access token field and scope options

The catalogue includes GitHub, GitLab, Linear, Jira & Confluence, Sentry, Datadog, Postgres, Supabase, Playwright, Chrome DevTools, Figma, Context7 and Hugging Face, among others. Every entry starts turned off. If you already signed in to GitHub through Sledbot's GitHub CLI sign-in, Use this login for the GitHub integration copies that login into the GitHub server. It only does this when you click it. See GitHub in Sledbot.

Where the secrets go:

  • Tokens are stored in your Keychain, not in any project file.
  • When an agent launches, tokens are passed only through that terminal's environment.
  • The generated config files have mode 0600, so only your user account can read and write them. They sit in Sledbot's own state folder and are deleted after 7 days.

Sledbot also adds its own sled mcp server to the same agents. It gives them tools to start other agents, send them messages and wait for them, to ask you for approval, and to hand off delegated jobs.

What it doesn't cover:

  • MCP servers are not passed to GitHub Copilot CLI, Cursor CLI, Grok CLI, Amp, Kimi, Kiro, Droid, Pi or Aider. Sledbot's own native agent has no MCP client either.
  • The server editor has Read-only and Allowed tools options. They are saved but not applied at launch, so don't rely on them to limit a server.
  • To start one agent without any servers, launch it with the label sled.mcp=off, for example sled run --label sled.mcp=off -- claude.

If you only use Claude Code, claude mcp add with user or project scope is all you need. Sledbot helps when you run several agents side by side and want one place to manage servers and tokens. All the options are in MCP integrations. Sledbot is part of MacSuite; you can try it free for 7 days.

Ways to add servers compared

MethodAgents coveredWhere tokens end upBest for
claude mcp add (local or user scope)Claude Code~/.claude.json, plain textPersonal servers, quick setup
.mcp.json with ${VAR}Claude CodeYour shell environment (or the Keychain, through your shell profile)Servers the whole team needs in one repo
Sledbot Settings ▸ IntegrationsClaude Code, Codex, Gemini CLI, Qwen Code, OpenCode, Crush, GooseKeychain, passed through the terminal's environmentSeveral agents sharing one server list

FAQ

Do Codex and Gemini CLI read Claude Code's MCP config? No. Each agent has its own config, so a server you add with claude mcp add only reaches Claude Code. Sledbot generates a config for each supported agent from one list when the agent launches.

Can I reuse servers I set up in Claude Desktop? Yes. On a Mac, claude mcp add-from-claude-desktop offers to import them into Claude Code.

Is adding an MCP server safe? A stdio server runs on your Mac with your user account's permissions. A remote server sees whatever Claude Code sends it. Only add servers from sources you trust, and give tokens the narrowest permissions the service allows.

How do I know when Claude Code needs my approval for a server tool? Claude Code asks before it uses a tool you haven't already allowed. If you're working in another window, see how to get notified when Claude Code needs you. To compare other agents, see the best AI coding agents for Mac.

Every app.
One purchase.