How to install
How to add and use MCP servers in Claude Code
The one command that adds a local or hosted MCP server to Claude Code, which scope to pick, and what to try when a server will not connect.
3 min read · Updated
Claude Code adds MCP servers from your terminal with claude mcp add. You run it once, and the server is there every time you start Claude Code after that.
Add a server that runs on your machine
Most open source servers run as a small program on your computer. Give the server a name, then put the command that starts it after --:
claude mcp add playwright -- npx @playwright/mcp@latest
Everything after -- is the command Claude Code runs to start the server. Everything before it is for Claude Code itself, like the name and options.
If the server needs an API key, pass it with -e:
claude mcp add firecrawl -e FIRECRAWL_API_KEY=your-key -- npx -y firecrawl-mcp
Add a hosted server
Some companies run the server for you, and you connect with a URL. Add --transport http and the URL:
claude mcp add --transport http sentry https://mcp.sentry.dev/mcp
Most hosted servers ask you to sign in. Start Claude Code, type /mcp, pick the server and finish the login in your browser. From your terminal, claude mcp login sentry does the same.
If a server wants a token instead of a sign-in, send it as a header:
claude mcp add --transport http my-server https://example.com/mcp --header "Authorization: Bearer your-token"
Pick a scope
The --scope option decides where the server is saved and who gets it.
| Scope | Works in | Saved in | Shared with your team |
|---|---|---|---|
local (the default) |
This project | ~/.claude.json |
No |
project |
This project | .mcp.json in the project folder |
Yes, through Git |
user |
All your projects | ~/.claude.json |
No |
Use user for servers you want everywhere, like a docs server:
claude mcp add --scope user --transport http context7 https://mcp.context7.com/mcp
Use project when everyone on the project should get the same servers. Commit .mcp.json and your teammates get the servers when they pull. Claude Code asks each person to approve a project's servers before it starts them, so nobody runs a server they did not agree to.
Keep real API keys out of .mcp.json, because it goes into Git with the rest of your code. Write ${API_KEY} instead, and Claude Code fills it in from your environment when it starts the server. It works in the command, args, env, url and headers fields.
Check that it works
claude mcp list
This shows every server and whether it connected:
✔ Connectedmeans it is ready.! Needs authenticationmeans you still need to sign in with/mcp.✘ Failed to connectmeans the start command failed.
Inside Claude Code, /mcp shows the same list.
When a server will not connect
- Run the start command on its own, for example
npx @playwright/mcp@latest. If it fails there, it fails in Claude Code too. A missing runtime is the usual cause: servers started withnpxneed Node.js, and servers started withuvxneed uv. - Check the API key. A server with a wrong key often starts fine and then fails on the first call.
- Run
claude mcp get playwrightto see how the server is saved and in which scope. - Remove it with
claude mcp remove playwrightand add it again.
Servers to start with
These are popular servers, and each page has the Claude Code command ready to copy: