# MCP in Claude Code: how to add and use MCP servers

An MCP server gives Claude Code tools for another system, such as GitHub, a database or your issue tracker. Add one with claude mcp add --transport http name url for a remote server, or claude mcp add name -- command for one that runs on your machine. Then run /mcp in a session to check it is connected and to sign in.

- Page: https://tecyfy.com/coding-agents/claude-code/mcp
- Guide: Claude Code (https://tecyfy.com/coding-agents/claude-code), from Anthropic's documentation (https://code.claude.com/docs/en/overview)

On its own, Claude Code can read and edit files, run commands and fetch web pages. The [Model Context Protocol](https://tecyfy.com/concepts/model-context-protocol) (MCP) is how you give it more: an MCP server is a small program that offers Claude a set of tools for one system, such as your issue tracker, a database, Figma or Sentry. Once it is connected, Claude reads the ticket or runs the query itself instead of working from what you paste in.

A good sign that you need one: you keep copying text from another tool into the chat.

## Add a remote server

Most services run their MCP server on the web. Add it by name and address:

```bash
claude mcp add --transport http notion https://mcp.notion.com/mcp
```

Then start Claude Code, run `/mcp`, choose the server and sign in. Many remote servers use OAuth, so you sign in through your browser once and Claude Code keeps the token. Servers that take a token instead get it as a header:

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

Use a token with access to only the repositories Claude should work in. `claude mcp add` saves the settings without testing them, so check the server shows as connected in `/mcp`.

## Add a server that runs on your machine

Some servers are a program you run locally. Put the command that starts it after `--`:

```bash
claude mcp add --transport stdio db -- npx -y @bytebase/dbhub \
  --dsn "postgresql://readonly:secret@localhost:5432/shop"
```

Everything after `--` is passed to the server untouched; everything before it is for Claude Code. Use `--env KEY=value` to give the server a variable. The example connects with a **read-only** database user, so no query Claude writes can change data.

Then ask in plain words: "show me the schema of the orders table", "how many orders were refunded last week?"

## Where servers are saved: 3 scopes

| Scope | Flag | Available in | Saved in |
| --- | --- | --- | --- |
| Local (the default) | none | This project, only for you | `~/.claude.json` |
| Project | `--scope project` | This project, for everyone | `.mcp.json` at the project root |
| User | `--scope user` | Every project, only for you | `~/.claude.json` |

Use **project** scope for servers the whole team needs, and commit `.mcp.json`. Never put a secret in it: write `${VAR}` and each person's environment fills it in, with `${VAR:-fallback}` for a default:

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

Claude Code asks each person before it uses a server from `.mcp.json`, since anyone with commit access could have added it.

## Managing servers

```bash
claude mcp list             # every server and whether it is connected
claude mcp get github       # one server's settings
claude mcp remove github    # remove it, and its saved sign-in
```

Inside a session, `/mcp` shows each server's status and tools, and lets you sign in again or turn a server off without removing it.

## Using what a server offers

- **Tools.** Ask for what you want and Claude calls the right tool. In Manual mode, each call asks permission like any other action until you allow it; `mcp__github` in your [allow rules](/coding-agents/claude-code/permissions) covers every tool of the `github` server.
- **Resources.** Type `@` to see a server's resources next to your files, and mention one, such as `@github:issue://123`, to put it into your message.
- **Prompts.** A server's prompts appear as commands: type `/` and look for the ones marked `(MCP)`.

## Context and output size

Every connected server adds tools Claude could call. Claude Code uses **tool search** for them: only the tool names load at the start, and a tool's full description loads when Claude needs it. So adding servers costs little context until their tools are used. `/context` shows what they take.

A tool that returns a lot can still fill the conversation. Claude Code warns when one result passes 10,000 tokens. A result over the limit, 25,000 tokens by default, is saved to a file that Claude reads when it needs to. Raise the limit with the `MAX_MCP_OUTPUT_TOKENS` environment variable.

## Check a server before you trust it

An MCP server runs with whatever access you give it. Before you connect one:

- Prefer servers from the service's own maker or a reviewed directory.
- Give it the narrowest token or database user that does the job.
- Be careful with servers that bring in outside text, such as web pages, emails or support tickets. That text can carry instructions written for Claude, which is [Prompt Injection](https://tecyfy.com/concepts/prompt-injection).
- Keep an ask rule on tools that change things. `/mcp` lists each server's tools by name, and a rule such as `mcp__github__<tool>` names one.

## Questions

### How do I add an MCP server to Claude Code?

For a remote server, run claude mcp add --transport http and then a name and the server's address, such as claude mcp add --transport http notion https://mcp.notion.com/mcp. For a local one, put the command that starts it after --, as in claude mcp add db -- npx -y @bytebase/dbhub. Then run /mcp in a session to check it and sign in.

### Where are MCP servers saved in Claude Code?

Servers added with the default local scope or with --scope user are saved in ~/.claude.json. Servers added with --scope project go in .mcp.json at the project's root, which you commit so the team gets them. Claude Code asks before it uses a server from .mcp.json.

### Do many MCP servers fill Claude Code's context window?

Less than they used to. Tool search loads only the names of MCP tools at the start, and the full description of a tool when Claude needs it, so adding servers costs little context. Run /context to see what they use.

### Is it safe to connect MCP servers?

Only connect servers you trust. A server runs with the access you give it, and one that fetches outside content, such as web pages or emails, can bring prompt injection into the conversation. Give database servers a read-only user and tokens the narrowest access they need.

### What is the difference between an MCP server and a skill?

An MCP server gives Claude new tools to reach a system it could not reach otherwise. A skill gives Claude instructions and scripts for a job, loaded when the job comes up. They work well together, such as a skill that explains how your team uses its issue tracker's MCP tools.

## Sources

- [Connect Claude Code to tools via MCP](https://code.claude.com/docs/en/mcp)
- [Configure permissions](https://code.claude.com/docs/en/permissions)
