How to add an MCP server to Claude Code
Last updated
Add an MCP server to Claude Code with claude mcp add. For a remote server, run claude mcp add --transport http <name> <url>. For a local program, run claude mcp add <name> -- <command>. Then start a new session, and use /mcp to sign in if the server asks you to.
Add a remote server (HTTP)
Most hosted MCP servers use HTTP, also called Streamable HTTP:
claude mcp add --transport http notion https://mcp.notion.com/mcp
If the server takes a fixed token instead of a sign-in, pass it as a header:
claude mcp add --transport http example https://example.com/mcp --header "Authorization: Bearer your-token"
SSE servers still work, but Claude Code's documentation calls SSE deprecated. Use HTTP where a server offers it.
Add a local server (stdio)
A local server is a program Claude Code starts on your computer. Put Claude Code's own options first, then --, then the command that starts the server:
claude mcp add --env AIRTABLE_API_KEY=YOUR_KEY --transport stdio airtable -- npx -y airtable-mcp-server
Everything after -- goes to the server unchanged. Because --env accepts several values, don't put the server's name straight after it: Claude Code would read the name as another value.
Choose a scope
The scope decides where the server is available and who else gets it:
- Local (the default): this project only, for you only. Stored in
~/.claude.json. - Project (
--scope project): written to.mcp.jsonin the project, so everyone who uses the repository gets it. Claude Code asks each person to approve these servers before it uses them. - User (
--scope user): every project on your computer, for you only. Also stored in~/.claude.json.
A server you add without --scope user is missing in other folders. Add it again there, or add it with --scope user.
Share a server with your team (.mcp.json)
claude mcp add --scope project writes a file like this to the project. Commit it to share the server:
{
"mcpServers": {
"shared-server": {
"type": "http",
"url": "https://example.com/mcp"
}
}
}
Each person still signs in with their own account. The file can use environment variables such as ${API_KEY}, so no one commits a secret.
Sign in with /mcp
Many remote servers use OAuth sign-in instead of a token. After adding one, start Claude Code, type /mcp, choose the server and choose Authenticate. A browser page opens; sign in there. Claude Code keeps the sign-in and refreshes it on its own.
Claude Code also has a claude mcp login <name> command. For Memlo, use /mcp: in Claude Code 2.1.281, claude mcp login stopped after the sign-in page with "Existing OAuth client information is required when exchanging an authorization code".
Check, list and remove servers
claude mcp listshows every server and its state, such as "✔ Connected" or "! Needs authentication".claude mcp get <name>shows one server.claude mcp remove <name>removes one. Runclaude mcp logout <name>first if you also want its sign-in revoked./mcpinside a session shows the same states and lets you turn a server off without removing it.
Other ways to add servers
claude mcp add-json <name> '<json>'adds a server from a JSON entry, such as one copied from another app's settings.claude mcp add-from-claude-desktopcopies servers from Claude Desktop, on a Mac or in WSL.
When a server doesn't work
- Restart the session. Claude Code loads servers when a session starts. Type
/exitand start Claude Code again. - Check the URL. It must be the server's full MCP address. For Memlo that is
https://memlo.ai/mcp, ending in/mcp. - Check sign-in.
claude mcp get <name>should say Connected. If it says "Needs authentication", sign in with/mcp. - Check the scope. If the server works in one folder and not another, it was added with the local scope.
- Slow to start. For a local server that takes a while, raise the startup timeout, for example
MCP_TIMEOUT=10000 claudefor 10 seconds. - Large results. Claude Code warns when a tool's answer is over 10,000 tokens and caps it at 25,000 by default. Change the cap with
MAX_MCP_OUTPUT_TOKENS.
Example: add a memory server
A memory server gives Claude Code notes that last between sessions. To add Memlo for every project:
claude mcp add --transport http --scope user memlo https://memlo.ai/mcp
Then sign in with /mcp and start a new session. Full steps, including a hook that loads memory when each session starts: How to give Claude Code memory between sessions.
Frequently asked questions
Where does Claude Code store MCP servers?
Servers with the local or user scope are in ~/.claude.json. Servers with the project scope are in .mcp.json at the root of the project.
Do I need to restart Claude Code after adding an MCP server?
Yes. Claude Code loads MCP servers when a session starts. End the session with /exit and start a new one.
What is the difference between http and sse?
Both are ways to reach a remote server. HTTP (Streamable HTTP) is the current one; SSE is the older one and is deprecated in Claude Code. If a server offers both, use HTTP.
How do I add an MCP server for all projects?
Add --scope user, for example claude mcp add --transport http --scope user <name> <url>.
How do I add the same server to Codex?
Use codex mcp add <name> --url <url> for a remote server, or codex mcp add <name> -- <command> for a local one. Codex keeps servers in ~/.codex/config.toml. See how to give Codex memory between sessions.
Sources
Checked on October 30, 2026:
- Connect Claude Code to tools via MCP, Claude Code documentation
- Commands, Claude Code documentation
- Model Context Protocol in Codex, Codex documentation
Try Memlo
Memlo is invitation only for now. Join the waitlist and we'll email you when your invitation is ready.
Join the waitlist