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-claudeThe documentation describes both ways.
Related questions
What is MCP (Model Context Protocol)?
MCP (Model Context Protocol) is an open standard for connecting AI applications to external systems. With MCP, an application such as Claude or ChatGPT can connect to data sources, tools and workflows. That is how the protocol's own website describes it.
Read the answerHow do you get multiple Claude Code sessions to work together?
The sessions need to share tasks, messages and knowledge. Claude Code has its own features for this: subagents, which work within one session, and agent teams, where one session leads several others. Sessions that you start yourself in different projects or on different computers can be connected to a shared service over MCP.
Read the answer