✻Founding-member pricing: every lesson for $19/mo. The first 3 lessons are free. Start lesson 1 →
Unit 6 · Model Context Protocol (MCP) · Lesson 27 of 40

Connecting MCP Servers to Claude Code

Add MCP servers to Claude Code with claude mcp add: HTTP and stdio transports, local/project/user scopes, .mcp.json, authentication and /mcp.

ACADEMY11 min+72 XP4-question quiz

🎯 By the end of this lesson you'll be able to

  • Add remote and local MCP servers
  • Choose the right scope and share via .mcp.json
  • Authenticate with OAuth and headers
  • Manage servers with claude mcp and /mcp

Adding servers

bash
# Remote server over HTTP (most hosted services)
claude mcp add --transport http notion https://mcp.notion.com/mcp

# Remote server with an auth header
claude mcp add --transport http secure-api https://api.example.com/mcp \
  --header "Authorization: Bearer $API_TOKEN"

# Local stdio server: everything after -- is the command that launches it
claude mcp add --transport stdio --env AIRTABLE_API_KEY=$KEY airtable -- npx -y airtable-mcp-server

The pattern is claude mcp add [options] <name> <url> for remote servers, and claude mcp add [options] <name> -- <command> [args] for local ones.

Scopes: who gets the server?

ScopeFlagStored inShared?
local (default)--scope local~/.claude.json, this project onlyNo
project--scope project.mcp.json in the repo rootYes, via git
user--scope user~/.claude.json, all your projectsNo

Use project scope for servers the whole team needs. It writes .mcp.json:

.mcp.json
{
  "mcpServers": {
    "sentry": { "type": "http", "url": "https://mcp.sentry.dev/mcp" },
    "db": {
      "command": "npx",
      "args": ["-y", "@example/postgres-mcp"],
      "env": { "DATABASE_URL": "${DATABASE_URL}" }
    }
  }
}

${VAR} expands from each developer's environment, so secrets stay out of git. ${VAR:-default} supplies a fallback. For safety, Claude Code asks each person to approve project-scoped servers before they're used.

!
Never commit secrets in .mcp.json

Use ${ENV_VAR} references for tokens and keys. The file is shared, but the values come from each developer's own environment.

Authentication

Many hosted servers use OAuth. After adding one, run /mcp in a session, select the server and sign in through your browser. From the shell, claude mcp login <name> does the same, and claude mcp logout <name> revokes it.

Managing servers

bash
claude mcp list          # all servers with status: ✔ Connected, ! Needs authentication…
claude mcp get sentry    # details for one server
claude mcp remove sentry

Inside a session, /mcp shows status, tool counts and authentication, and lets you reconnect, enable or disable servers. /context all shows how much context each server's tools use.

▶Watch it runUsing a connected server
Using a connected server
⌨Type the command+15 XP

Add a remote HTTP server named "notion" at https://mcp.notion.com/mcp

❯

Check your understanding

?Lesson quiz10 XP per correct answer · +25 for a perfect score
QUESTION 1 OF 4

Which scope shares a server with your team through git?

Why: Project scope writes .mcp.json in the repo root.
QUESTION 2 OF 4

How should tokens appear in a committed .mcp.json?

Why: Environment variable expansion keeps secrets out of version control.
QUESTION 3 OF 4

In claude mcp add ... airtable -- npx -y airtable-mcp-server, what does -- separate?

Why: Everything after -- is passed unchanged as the server's command.
QUESTION 4 OF 4

Which in-session command shows MCP server status and handles OAuth sign-in?

Why: /mcp manages servers, including authentication.
0 / 4 correct
Academy lesson

Unlock lesson 27 and the next 13

You've finished the free lessons. Join the Academy for $19/month to unlock every lesson, quiz, terminal simulation and puzzle, plus the final exam and your certificate of completion.

  • All 40 lessons across 9 units
  • 165+ quiz questions
  • Final exam + certificate
  • New lessons as Claude Code evolves
  • XP, streaks and badges
  • Cancel anytime

Already a member? Log in to continue.

Key takeaways

  • Remote: claude mcp add --transport http <name> <url>. Local: claude mcp add <name> -- <cmd>.
  • Scopes: local (default), project (.mcp.json, shared) and user.
  • Use ${ENV_VAR} for secrets in shared config.
  • Manage with claude mcp list/get/remove and /mcp in a session.

Nice work. Lesson 27 done?

Mark it complete to earn +72 XP, keep your streak alive and unlock badges.

Written by Curtis Cornell from Anthropic's public Claude Code documentation. Last reviewed November 14, 2026. Claude Code changes fast; if something here differs from your version, the official docs win.

Start lesson 1 free →