# MCP in Claude Code: add servers, pick a scope and stay safe

> How to add MCP servers to Claude Code with claude mcp add, choose a scope, check them with /mcp, and keep your tokens and projects safe.

Updated: 2026-11-01

MCP, the Model Context Protocol, is an open standard that connects Claude Code to outside tools such as GitHub, a database or Notion. Add a server in your terminal with `claude mcp add`, choose who shares it with `--scope`, and check it with `/mcp` in a session. Servers work the same with an API key.

## What is MCP in Claude Code?

An MCP server is a program or web service that gives Claude new abilities. It can offer three things:

- **Tools:** actions Claude can take, such as opening a pull request or running a database query.
- **Resources:** data you can mention with `@`, such as an issue or a table schema.
- **Prompts:** ready-made instructions that appear as slash commands.

Claude Code is the MCP client. Once a server is connected, you ask in plain language and Claude picks the right tool. Claude Code can connect to hundreds of tools this way, and you can write your own server too.

## Which kind of server do you have?

A server reaches Claude Code in one of four ways, called transports. The server's own docs tell you which one it uses.

| Transport | Use it for | How to add it |
| --- | --- | --- |
| HTTP | Remote servers, the recommended choice | `claude mcp add --transport http` |
| stdio | A program that runs on your machine | `claude mcp add --transport stdio` |
| SSE | Older remote servers, now deprecated | `claude mcp add --transport sse` |
| WebSocket | Remote servers over WebSocket, without OAuth | A `"type": "ws"` entry in JSON |

When a server offers both HTTP and SSE, use HTTP.

## How do you add an MCP server?

### A remote HTTP server

Give the server a name and its URL. If it uses a token, pass it as a header:

```bash
claude mcp add --transport http notion https://mcp.notion.com/mcp
claude mcp add --transport http secure-api https://api.example.com/mcp \
  --header "Authorization: Bearer your-token"
```

Servers that sign you in with OAuth need no header. Run `/mcp` in Claude Code, pick the server and finish the sign-in in your browser. From the terminal, `claude mcp login <name>` does the same.

### A local stdio server

A stdio server is a program Claude Code starts on your machine. Put its command after `--`:

```bash
claude mcp add --env AIRTABLE_API_KEY=YOUR_KEY --transport stdio airtable \
  -- npx -y airtable-mcp-server
```

Everything before `--` is for Claude Code, such as `--transport`, `--env` and `--scope`. Everything after it runs the server, untouched. `--env` takes several `KEY=value` pairs, so keep another option such as `--transport stdio` between it and the server name.

### From JSON or Claude Desktop

If a server's docs give you a JSON block, add it as it is:

```bash
claude mcp add-json weather-api '{"type":"http","url":"https://api.weather.com/mcp","headers":{"Authorization":"Bearer token"}}'
```

On macOS and WSL, `claude mcp add-from-claude-desktop` imports the servers you already set up in Claude Desktop.

Then run `/mcp`. `claude mcp add` saves the settings without testing them, so a wrong token only shows up here: a connected server has a check mark, and a failed one shows ✘ with the HTTP status, such as 401.

## Which scope should you choose?

The scope decides where a server is saved and who gets it. Set it with `--scope` when you add the server.

| Scope | Who gets it | Where it is saved |
| --- | --- | --- |
| `local` (default) | You, in the current project | `~/.claude.json` |
| `project` | Everyone on the project, through Git | `.mcp.json` in the project root |
| `user` | You, in all your projects | `~/.claude.json` |

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

If the same server name appears in more than one scope, local wins over project, and project wins over user. Claude Code uses the whole entry from the winner and doesn't merge fields.

### Keep secrets out of .mcp.json

A project's `.mcp.json` goes into Git, so don't write tokens in it. Use `${VAR}` to read an environment variable, or `${VAR:-default}` to fall back to a default value:

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

Expansion works in `command`, `args`, `env`, `url` and `headers`. Each person sets the variable on their own machine.

## How do you manage your servers?

| Command | What it does |
| --- | --- |
| `claude mcp list` | Lists every server you've added |
| `claude mcp get <name>` | Shows one server's details |
| `claude mcp remove <name>` | Removes a server |
| `claude mcp login <name>` | Signs in to an OAuth server from the terminal |
| `claude mcp reset-project-choices` | Clears your approvals for `.mcp.json` servers |
| `/mcp` | Shows each server's status inside a session and signs you in |

Claude Code waits 30 seconds for a server to start. If yours needs longer, raise the timeout in milliseconds, such as `MCP_TIMEOUT=60000 claude` for 60 seconds.

## What can you do once a server is connected?

### Ask in plain language

Take GitHub. Create a fine-grained personal access token for the repositories Claude should work with, then add the server:

```bash
claude mcp add --transport http github https://api.githubcopilot.com/mcp/ \
  --header "Authorization: Bearer YOUR_GITHUB_PAT"
```

Now ask for what you need, for example:

```text
Review PR #456 and suggest improvements
Show me all open PRs assigned to me
```

### Mention resources with @

Type `@` to see resources from your servers next to your files. Use the form `@server:protocol://path`, such as `@github:issue://123`. Claude Code fetches the resource and attaches it to your message.

### Run server prompts as commands

A server's prompts appear in the `/` menu as `/server:prompt (MCP)`. Typing `/mcp__github__pr_review 456` also runs one, with its arguments separated by spaces.

## Is MCP safe to use?

A server can read your data and act for you, so treat it like any software you install:

- **Trust the source.** Connect only servers you trust. Servers that fetch outside content, such as web pages or issues, can carry prompt injection: hidden text that tries to steer Claude.
- **Give tokens the least access.** A read-only database user, or a GitHub token limited to a few repositories, caps the damage of a mistake.
- **Check a cloned project's .mcp.json.** In an interactive session, Claude Code asks before it uses project servers. Print mode (`claude -p`) loads them without asking, so in scripts add `--strict-mcp-config` with `--mcp-config` to pick the servers yourself.
- **Your key stays out of server requests.** In a remote server's `url` and `headers`, Claude Code reads `ANTHROPIC_API_KEY` and `ANTHROPIC_AUTH_TOKEN` as empty, so a project file can't send your key to a remote server that way.

## Does MCP work with an API key?

Yes. MCP servers run on your machine or at their own address, and only the model requests go to the base URL. 5abeer is an independent service compatible with the Anthropic Messages API, so you set the base URL and key in `~/.claude/settings.json`, and every MCP command above works as Anthropic documents it:

`~/.claude/settings.json`

```json
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://api.5abeer.ai",
    "ANTHROPIC_AUTH_TOKEN": "YOUR_5ABEER_API_KEY",
    "ANTHROPIC_MODEL": "claude-sonnet-5.5"
  }
}
```

Create the key in your dashboard first ([how to create a key](https://5abeer.ai/en/docs/start/keys.md#create)). Then run `/status` to see the 5abeer base URL, and `/mcp` to see your servers.

Three things to know with a key:

- **claude.ai connectors don't load.** They appear only when you sign in with a claude.ai subscription, not when an API key or token is active. Add the same services with `claude mcp add` instead.
- **Tool use counts as tokens.** Tool names, the definitions Claude loads and tool results all go into the request, so they use your balance like any other input ([usage and balance](https://5abeer.ai/en/docs/start/pricing.md#usage)). Tool search keeps definitions small by loading them only when needed. Tool output is capped at 25,000 tokens by default (`MAX_MCP_OUTPUT_TOKENS` changes the cap), and a text result over 50,000 characters is saved to a file instead.
- **Tool search stays on behind a base URL.** Recent versions retry without it when a request is rejected with a 400 or 422 error. To load every tool upfront instead, set `ENABLE_TOOL_SEARCH` to `false` in the `env` block of your settings.

You can run Claude Code on 5abeer in two ways:

- **An API key, paid as you go.** Pay per token from your balance, and give every key a spend limit, an expiry date and an IP allow-list ([key controls](https://5abeer.ai/en/docs/start/keys.md#controls)). Claude prices are on the [Claude API page](https://5abeer.ai/en/api/claude).
- **A 5abeer plan.** The 5abeer AI app turns on Claude Code for your plan ([what each plan runs](https://5abeer.ai/en/docs/subscriptions/plan-apps.md#claude-code)). Plans are for the supported apps. To call the models from your own code, create an API key. See the [pricing page](https://5abeer.ai/en/pricing) and the [Claude Code app page](https://5abeer.ai/en/apps/claude-code).

If a request is refused with a code, [`INVALID_API_KEY`](https://5abeer.ai/en/docs/help/errors.md#INVALID_API_KEY) means the key is wrong or deleted, and [`INSUFFICIENT_BALANCE`](https://5abeer.ai/en/docs/help/errors.md#INSUFFICIENT_BALANCE) means your balance doesn't cover the request. Every code is in [Errors and fixes](https://5abeer.ai/en/docs/help/errors.md), and every setting is on the [Claude Code docs page](https://5abeer.ai/en/docs/apps/claude-code.md).

## Questions

### What does MCP stand for?

Model Context Protocol. It's an open standard for connecting AI tools to outside services, so one server works with any app that supports MCP, not only Claude Code.

### Where does Claude Code save MCP servers?

Local and user servers go in `~/.claude.json`, and project servers in `.mcp.json` at the project root. Run `claude mcp get <name>` to see one server's details.

### Why won't my MCP server connect?

Check the token or header first, since `claude mcp add` doesn't test them. For a stdio server, run its command in a terminal to see the error. If the server is only slow to start, raise `MCP_TIMEOUT`.

### Can I use my claude.ai connectors?

Only when you sign in to Claude Code with a claude.ai subscription. With an API key in your settings they don't load, so add the services you need with `claude mcp add`.

### Can Claude Code be an MCP server?

Yes. `claude mcp serve` starts Claude Code as a stdio MCP server, so another app, such as Claude Desktop, can use its tools. It prints nothing while it waits for a client.

### Which model works best with MCP?

Start with the default model, [`claude-sonnet-5.5`](https://5abeer.ai/en/models/claude-sonnet-5.5), which handles most tool work. Move to [`claude-opus-5.5`](https://5abeer.ai/en/models/claude-opus-5.5) or [`claude-fable-5.1`](https://5abeer.ai/en/models/claude-fable-5.1) for long tasks that chain many tools. Switch with `/model`. The full list with prices is on the [models page](https://5abeer.ai/en/models).

## Sources

Checked on 2026-11-01:

- Claude Code docs: [MCP](https://code.claude.com/docs/en/mcp)
- Claude Code docs: [CLI reference](https://code.claude.com/docs/en/cli-reference)

> 5abeer is an independent service, not affiliated with OpenAI, Anthropic or Google.

## Get started

See every command in [Claude Code commands](https://5abeer.ai/en/guides/claude-code-commands), set up the editor in [Claude Code in VS Code](https://5abeer.ai/en/guides/claude-code-vscode), or install it with [Install Claude Code on Windows](https://5abeer.ai/en/guides/claude-code-windows-install).
