Short answer
To add an MCP server to Claude Code, run claude mcp add --transport http <name> <url> for a remote server, or claude mcp add <name> -- <command> for a local one. Then run /mcp inside Claude Code to check status and sign in. Add --scope project to share a server through a .mcp.json file.
What MCP is, in short
MCP, the Model Context Protocol, is an open-source standard for connecting AI applications to external systems. The MCP site compares it to a USB-C port for AI: one standard way to plug an assistant into data sources such as files and databases, tools such as search engines, and workflows such as specialised prompts. A server exposes those things, and a client such as Claude Code connects to it. Because the protocol is open, the same server can work with Claude, ChatGPT, Visual Studio Code, Cursor and other clients that support it. For you, that means you add a server once and Claude Code can use what it offers, such as reading a ticket and then writing the fix.
Everything below works the same wherever Claude Code runs, on your laptop, a VPS or a Claude Code computer on Hivra that stays on when your laptop is shut.
The three kinds of server at a glance
Claude Code connects to MCP servers in three ways, which Anthropic's MCP documentation calls transports. Almost everything you add will be one of the first two.
| Transport | Where the server runs | Command shape | Use it when |
|---|---|---|---|
| HTTP | On the vendor's servers, reached by URL | claude mcp add --transport http <name> <url> | The service offers a remote server. Anthropic's docs recommend this one |
| stdio | As a process on the same computer as Claude Code | claude mcp add <name> -- <command> [args...] | The server is an npm package or a program you run locally, such as a database tool |
| SSE | On the vendor's servers, reached by URL | claude mcp add --transport sse <name> <url> | An older remote server only offers SSE. Anthropic marks this transport deprecated |
Add a remote HTTP server
A remote server is the simplest case, because there is nothing to install. Give it a name and its URL:
If the server wants a token in a header, pass it with --header:
The GitHub server is added the same way, with a personal access token in the header:
If a service only offers an SSE endpoint, use the same shape with --transport sse:
Anthropic's docs also say that --transport http now tries HTTP first and falls back to SSE automatically on current versions, so you rarely need to choose by hand. When you write the server into a JSON file instead, "type": "streamable-http" is accepted as another way to say http. One trap: a JSON entry that has a url but no type is treated as a stdio server and skipped, so always set the type.
Add a local stdio server
A stdio server is a program Claude Code starts on the same computer and talks to through its input and output. The syntax is:
The double dash matters. Everything after -- is passed to the server untouched. Without it, Claude Code tries to read the server's own flags as its flags. Here is Anthropic's Airtable example, which also shows how to pass a secret through the server's environment:
--env takes one or more KEY=value pairs. If you put another option after it, such as --transport stdio, put it before the server name so the name is not swallowed as a value. A database example from the same page, using a read-only database user on purpose:
Claude Code also sets CLAUDE_PROJECT_DIR in a stdio server's environment, so a project server can find its own folder. In a project .mcp.json you write it as ${CLAUDE_PROJECT_DIR:-.}.
If you already have the server's configuration as JSON, claude mcp add-json takes it directly:
A note on names: server names added through claude mcp commands can contain only letters, numbers, hyphens and underscores.
Scopes: local, project and user
Every server you add lives in one of three scopes, which decide where the setting is stored and who gets it. Pick one with --scope:
| Scope | Flag | Stored in | Who gets it |
|---|---|---|---|
| Local (the default) | --scope local | ~/.claude.json | You, in the current project only |
| Project | --scope project | .mcp.json at the project root | Everyone who uses the repo, through version control |
| User | --scope user | ~/.claude.json | You, in every project |
A simple rule: use local for something you are trying out, user for tools you want everywhere (a notes app, say), and project for servers the whole team should have. Because a project server is a file in the repository, a teammate gets it by pulling. They are asked to approve it the first time in an interactive session, and claude mcp reset-project-choices resets those choices.
If the same server name appears in more than one place, Claude Code does not merge them. The order of precedence is local, then project, then user, then plugin-provided servers, then claude.ai connectors. A server delivered through managed settings by an administrator outranks all of them.
The .mcp.json file and environment variables
The project scope is just a JSON file named .mcp.json in your repository root. Anthropic's example shows the shape, including variables:
Two variable forms work: ${VAR} and ${VAR:-default}, which uses the default when the variable is unset. Expansion works in command, args, env, url and headers. This is how you commit a server to git without committing the token: the file names the variable and each teammate sets it in their own environment.
Two details from the docs save a debugging session. If a variable is unset and has no default, the server still loads, with the literal ${VAR} text in place and a warning. And certain credential variables read as empty when used in a remote server's url or headers, on purpose, so that they are not sent to a remote server. The docs list ANTHROPIC_API_KEY, ANTHROPIC_AUTH_TOKEN, AWS_BEARER_TOKEN_BEDROCK, HTTPS_PROXY and NPM_TOKEN as examples. If a header comes out empty, run claude --debug-file /tmp/claude-debug.log and search the file for never expanded toward a remote server.
Sign in to a server that uses OAuth
Many remote servers use OAuth rather than a pasted token. You add the server as usual, then sign in from inside Claude Code:
Choose the server and complete the flow in your browser. Anthropic's docs say tokens refresh automatically, and that "Clear authentication" in the same panel revokes access. If you would rather do it from the shell, claude mcp login <name> and claude mcp logout <name> do the same job, and --no-browser prints a URL prompt instead of opening a browser, which helps on a machine with no screen.
Some providers only accept a fixed callback address. For those, set a port when you add the server, and the redirect address becomes http://localhost:PORT/callback:
If a provider gave you a client ID and secret, pass --client-id your-client-id and --client-secret. The secret is prompted for with masked input, and MCP_CLIENT_SECRET in the environment skips the prompt for automated runs.
One limit to know about: some Anthropic-hosted connectors, such as Microsoft 365, Gmail and Google Calendar, do not support OAuth from Claude Code, because the identity provider only accepts the address registered by claude.ai. For those, connect the service at claude.ai/customize/connectors and it appears in Claude Code automatically.
List, check, remove and debug servers
Four commands cover day-to-day management:
remove also deletes any stored OAuth tokens for a remote server. Inside a session, /mcp shows the same list with status, sign-in and the option to enable or disable each server. To switch a server off without deleting it, use that panel, which records the choice in disabledMcpServers in ~/.claude.json.
The status markers tell you what is wrong: Connected, Needs authentication, Failed to connect, Pending approval (run claude to approve a project server) and Disabled for this project. When a server fails, work down this list:
- Run
claude mcp get <name>and read the failure detail it prints. - For a stdio server, run the command yourself in a terminal. If
npxcannot find the package or the program crashes, Claude Code will not do better. - Check the double dash. A missing
--is the most common cause of a stdio server that never starts, because Claude Code reads the server's flags as its own. - Check variables.
claude mcp listandgetshow variable references, not their values, so a${VAR}there is normal. Look instead for the missing-variable warning when Claude Code starts, or an empty header on a remote server, which points to an unset or deliberately blanked variable. - Retry. Remote servers that drop mid-session get five retries with a delay that doubles from one second, and
/mcp reconnect allretries everything that failed or needs sign-in on current versions. - Raise the startup timeout if a slow server never finishes starting:
MCP_TIMEOUT=60000 claudegives it sixty seconds. The value is in milliseconds, and Anthropic's docs give the default as 30 seconds, so only a number above 30000 makes the wait longer.
You can also import servers you already set up in Claude Desktop with claude mcp add-from-claude-desktop. Anthropic says this works only on macOS and Windows Subsystem for Linux, and servers with a name that has spaces or other odd characters are skipped.
Output limits and the token warning
A tool that returns a huge result can fill your context. Claude Code warns you when an MCP tool's output goes above 10,000 tokens, and caps it at 25,000 tokens by default. If you have a good reason to allow more, raise the cap with an environment variable:
Anthropic's docs add that successful text results of more than 50,000 characters are saved to a file instead of being pasted into the conversation, unless the server raises that limit itself. The better fix is usually to ask the server for less: a narrower query, fewer rows, one page at a time.
Servers worth adding first
There is no official ranking, but the servers Anthropic's own documentation uses as examples are a fair guide to what people connect first: GitHub (issues and pull requests), Notion and Asana (tasks and notes), Airtable, Sentry (errors), Stripe, HubSpot, and a PostgreSQL database through DBHub.
Claude Code can also use connectors you set up in claude.ai. If you sign in to Claude Code with a claude.ai account, those connectors appear in /mcp automatically. Anthropic notes they are not loaded if you authenticate with an API key or a third-party provider such as Amazon Bedrock instead.
Security: only add servers you trust
Anthropic's documentation carries a plain warning: verify that you trust each MCP server before you connect it, because servers that fetch external content can expose you to prompt injection. Prompt injection means text inside a web page, ticket or document that is written to look like instructions, and that the model may follow. An MCP server that pulls in issue comments or web pages is a route for that text to reach Claude, and an agent that can also run commands or write files can be tricked into using them.
A few habits keep the risk down:
- Prefer servers from the service's own maintainers. A random package from a forum thread runs as a program on your computer if it is a stdio server.
- Give each server the least access that works. Use a read-only database user, as Anthropic's own example does, and a token with narrow scopes.
- Keep secrets out of the repository. Use
${VAR}in.mcp.jsoninstead of the token itself. - Read the approval prompt for a project server before you accept it. A
.mcp.jsonpulled from someone else's repo can start a program on your machine. - Be careful about combining powers. A server that reads untrusted content plus a session that can run any command is the dangerous pairing. Our guide to the permission-skipping flag covers why, and leaving an agent running unattended covers the wider risks.
Where your MCP servers run: laptop, VPS or a Hivra computer
A stdio MCP server is a process on whatever computer Claude Code runs on, and its sign-in lives there too. That makes the answer to "where should Claude Code run" matter more once you have servers. If it runs on your laptop, a database tool or a browser server stops when the lid closes, and the work Claude was doing with them stops too.
Hivra runs Claude Code on a cloud computer of its own, with the official Anthropic CLI installed, and you open its terminal and files in a browser from any device. There the claude mcp add commands in this guide work as written, in the Terminal tab. The computer stays available when yours doesn't, and a Claude Code run you start inside tmux keeps going after you close your laptop. Work you send through the agent's Telegram tab also runs on the computer. It also keeps coding tools, credentials and experiments separate from your everyday laptop.
On a paid Hivra plan the computer stays on and keeps your files, sessions and login. A Claude Code or Codex run you start inside tmux in the computer's Terminal tab keeps going after you close the laptop. On Claude Code, work you send through Telegram, connected in the agent's Telegram tab, runs on the computer, not in your browser.
Here is the part that is not about Claude Code at all. Hivra is not tied to one agent. The same account launches agents including Hermes, OpenClaw, Claude Code, Codex and Agent Zero, each on a computer of its own, and you reach all of them from a browser on any device. MCP is an open standard, so if you try Codex next month, the servers you have learned to set up carry over, and you do not need a second account or a second server to find out. Hivra is not affiliated with Anthropic.
Plans start at $9.99 a month for 2 vCPU and 4 GB of RAM. You sign in to Claude Code with your own Anthropic account on that computer, as you would on a desktop. Hivra does not say that it installs, manages or vets MCP servers for you: you add them yourself, with the commands above.
Two honest limits. A Hivra computer is managed, so you get less freedom than a VPS you root yourself, and Hivra administrators retain infrastructure access to managed hosts. And if you only use Claude Code at your desk, with servers that need your local files or a desktop session, running it on your own machine is simpler and costs nothing extra. Hivra earns its place when you want Claude Code to keep working while you are away.
Launch Claude Code on Hivra to try it, or read Claude Code on Linux if you would rather set up a server yourself.
A short setup you can copy
Putting it together, here is a reasonable first session. Add a remote server for your tracker, check it, sign in, then add a shared project server for the team:
The point is the order: add, list, sign in, and only then commit the shared file, so you know the server works before your teammates pull it.
Common questions
What is MCP in Claude Code?
MCP, the Model Context Protocol, is an open standard for connecting AI applications to outside tools and data. In Claude Code, an MCP server gives Claude extra tools, such as reading GitHub issues or querying a database. You add servers with claude mcp add and manage them with /mcp.
How do I add an MCP server to Claude Code?
For a remote server, run claude mcp add --transport http <name> <url>. For a local one, run claude mcp add <name> -- <command> [args...], with the double dash before the command. Then run /mcp inside Claude Code to check that it connected and to sign in if it needs OAuth.
Where does Claude Code store MCP server settings?
Local and user scope servers are stored in ~/.claude.json. Project scope servers are stored in a .mcp.json file at the project root, which you can commit to version control. Local is the default scope. If a name appears in several scopes, local beats project, and project beats user.
How do I list or remove MCP servers in Claude Code?
Run claude mcp list to see every server and its status, claude mcp get <name> for details, and claude mcp remove <name> to delete one. Removing a remote server also deletes its stored OAuth tokens. Inside a session, /mcp shows the same information and lets you disable a server without removing it.
Why does my MCP server say it needs authentication?
Remote servers that use OAuth need a sign-in after you add them. Run /mcp, choose the server and finish the browser flow, or run claude mcp login <name> from a shell. Tokens refresh automatically afterwards. Some Anthropic-hosted connectors, such as Gmail and Google Calendar, must be connected at claude.ai instead.
Is it safe to use MCP servers with Claude Code?
Only with servers you trust. Anthropic warns that servers which fetch external content can expose you to prompt injection. Prefer servers from the service's own maintainers, give them read-only or narrowly scoped access, keep tokens out of your repository, and read the approval prompt before accepting a project server.
What does the MCP output token warning mean?
Claude Code warns when one MCP tool returns more than 10,000 tokens, and caps output at 25,000 tokens by default. You can raise the cap by setting MAX_MCP_OUTPUT_TOKENS before starting claude, but asking the server for less data is usually the better fix.
Can I keep MCP servers running when my laptop is closed?
Only if Claude Code runs on a machine that stays on. A stdio server is a process on the same computer as Claude Code, so it stops when that computer sleeps. Run Claude Code on a VPS, or on a Hivra computer inside tmux, if you want the work to continue while you are away.