How to add an MCP server to Claude Code
In Claude Code you add a server with one terminal command: claude mcp add <name> -- <command> for a local server, or claude mcp add --transport http <name> <url> for a remote one. Check it with claude mcp list, or type /mcp inside a session.
Add a local server
Local servers run on your computer, usually through npx (Node.js) or uvx (Python). Everything after -- is the command that starts the server.
claude mcp add playwright -- npx -y @playwright/mcp@latest
Add a remote server
claude mcp add --transport http my-server https://example.com/mcp
Use the server's real URL from its page here.
If the server uses sign-in, Claude Code opens the login the first time you use it. Type /mcp to sign in or check status.
Pass an API key
Use -e for environment variables (local servers) or --header for remote ones:
claude mcp add my-server -e API_KEY=your-key -- npx -y package-name
claude mcp add --transport http my-api https://example.com/mcp --header "Authorization: Bearer your-key"
Choose the scope
- local (default): only you, only this project.
- project: saved in
.mcp.jsonin the repo, so your team gets it too. Never put real keys in this file. - user: you, in every project.
claude mcp add --scope user playwright -- npx -y @playwright/mcp@latest
Check, update and remove
claude mcp list
claude mcp get playwright
claude mcp remove playwright
Every MCP server page on this site has the exact claude mcp add command, with required settings filled in as placeholders. Browse servers for Claude Code.
Questions
Where does Claude Code store MCP servers?
Servers with local or user scope are stored in your Claude Code settings in your home folder. Project scope servers are stored in a .mcp.json file in the project, which you can commit to share with your team.
Why does my server say failed to connect?
Usually the start command fails: a missing runtime, a wrong package name or a missing API key. Run the command after -- yourself in a terminal to see the real error.