Skip to content

Learn

How do you connect an MCP server to Claude Code?

An MCP server is added with the command claude mcp add. A server over HTTP is given with --transport http, a name and a URL. A local server that runs as a process is given with the name followed by two hyphens and the command that starts it.

Last reviewed on .

Server over HTTP

The Claude Code documentation gives this form, and shows that a key can be sent in a header:

Basic form and example with a key, from the Claude Code documentation

claude mcp add --transport http <name> <url>

claude mcp add --transport http secure-api https://api.example.com/mcp \
  --header "Authorization: Bearer your-token"

Local server over stdio

Basic form, from the Claude Code documentation

claude mcp add [options] <name> -- <command> [args...]

Where the setting is saved

The documentation describes three scopes:

  • local, the default: the server is available only to you in the current project.
  • project: the server is shared with everyone in the project through the file .mcp.json in the project root.
  • user: the server is available to you in all projects.

AgentRoots in Claude Code

Over HTTP, with an agent key created on the web:

AgentRoots over HTTP

claude mcp add --transport http agentroots https://agentroots.app/api/mcp --header "Authorization: Bearer ar_..."

The command-line client can add the MCP server and hooks to the project's Claude Code settings with one command:

With the client

node agentroots.mjs install-claude

The documentation describes both ways.