In this categoryClaude Code · 45
Claude CodeIntermediate

How to Add Any MCP Server to Claude Code

Learn the claude mcp add command, the difference between stdio and remote servers, where the config lives, and how to verify a server with /mcp.

10 minIntermediate

The Model Context Protocol (MCP) is an open standard that lets Claude Code talk to external tools through a small server, so the agent can read a database, drive a browser, or pull live docs. Once a server is added, its tools show up automatically. This guide covers the one command you need, the two kinds of server, where the config is stored, and how to confirm everything connected.

What you need

  • Claude Code installed and signed in
  • The command or URL for the MCP server you want to add
  • Any token that server needs, ready to pass as an environment variable or header
  • About 10 minutes

Step 1: Know the two kinds of server

Every MCP server connects over a transport. A stdio server is a local process Claude Code launches itself, usually through npx or uvx. A remote server already runs somewhere and you connect to it over HTTP (the current standard) or SSE (older, now deprecated). The transport decides the shape of the command.

TransportWhat it isHow you add it
stdioA local process Claude Code spawnsclaude mcp add <name> -- <command>
httpA remote server over streamable HTTPclaude mcp add --transport http <name> <url>
sseA remote server over SSE (deprecated)claude mcp add --transport sse <name> <url>

Step 2: Add a stdio server

Use claude mcp add with a name, then a double dash, then the command that starts the server. The double dash is required: it separates Claude's own flags from the server's command so the rest passes through untouched. Pass any secret with --env so it is stored in config rather than typed into chat.

zsh - mcp add (stdio)
$claude mcp add filesystem -- npx -y @modelcontextprotocol/server-filesystem ~/projects
Added stdio MCP server filesystem to local config.
$claude mcp add postgres --env DATABASE_URI=postgresql://user:pass@localhost:5432/app -- uvx postgres-mcp --access-mode=restricted
Added stdio MCP server postgres to local config.
$

Step 3: Add a remote HTTP or SSE server

For a hosted server you give a URL instead of a command. Set the transport to http and pass any auth as a header. Many hosted servers use OAuth instead, in which case you run /mcp inside a session to sign in.

terminal
# token in a header
claude mcp add --transport http context7 https://mcp.context7.com/mcp \
  --header "CONTEXT7_API_KEY: your-key-here"

# OAuth server: add it, then run /mcp in a session to authenticate
claude mcp add --transport http github https://api.githubcopilot.com/mcp/

Step 4: Choose a scope

Where a server is saved decides who sees it. The default is local (just you, just this project). Use project to share a server with your team through a committed .mcp.json file, or user to make it available across all of your own projects.

ScopeFlagStored inShared with team?
Local (default)--scope local~/.claude.json (per project)No
Project--scope project.mcp.json in the repo rootYes, commit it
User--scope user~/.claude.json (global)No, but all your projects

Step 5: Or edit .mcp.json by hand

Project-scoped servers live in a .mcp.json file at the repo root. You can write it directly instead of using the CLI. Use ${VAR} so secrets come from the environment rather than sitting in the file.

.mcp.json
{
  "mcpServers": {
    "filesystem": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-filesystem", "."]
    },
    "context7": {
      "type": "http",
      "url": "https://mcp.context7.com/mcp",
      "headers": { "CONTEXT7_API_KEY": "${CONTEXT7_API_KEY}" }
    }
  }
}
Trust the source
An MCP server runs code and reads data on your behalf. Only add servers you trust, prefer official packages, and treat a third-party server like any other dependency you install. For databases, start in a read-only or restricted access mode.

Step 6: Verify the connection

List your servers to confirm each one is connected, then start a session and run /mcp to see the tools it exposes. A failed status almost always means a wrong command, a missing binary, or a bad credential.

zsh - verify
$claude mcp list
filesystem stdio connected
context7 http connected
$claude mcp get context7
context7 https://mcp.context7.com/mcp (http, local scope)
Run /mcp inside a session to list each server's tools
$
Want MCP outside Claude Code?
mcphost (mark3labs/mcphost) is a separate command line host that runs the same MCP servers against other models, including local ones through Ollama. The server packages are identical, so a server you add here works there too.

Result: you can wire any MCP server into Claude Code with one command, pick the right scope, and confirm it connected before you rely on it. Adding the next server is the same three steps.

Related guides

Watch related tutorials

Free weekly email

New guides in your inbox

Fresh step-by-step how-to guides as we publish them. One email a week, no more.

Tags
#mcp server#add mcp server to claude code#mcphost#stdio#claude-code