Add your first MCP server
One command connects Claude Code to GitHub, databases, and more
⏱ Est. ~6 min
01 · Read
Adding an MCP server to Claude Code is a single command. You use claude mcp add followed by a name and either a URL (HTTP) or a command (stdio).
Once added, Claude can use every tool that server exposes — automatically. No code changes, no config files, no restart. Add it and start asking Claude to use it.
Key points
- claude mcp add is the main command for adding servers
- HTTP servers need a name and a URL
- Stdio servers need a name and a command to run
- Options like --transport, --env, --scope go before the server name
02 · Code example
Here's how to add a remote HTTP server — the most common type. This example connects Claude to GitHub.
Add the GitHub MCP server
claude mcp add --transport http github https://api.githubcopilot.com/mcp/
Add the Notion MCP server
claude mcp add --transport http notion https://mcp.notion.com/mcp
Add with an auth header
claude mcp add --transport http secure-api https://api.example.com/mcp \
--header "Authorization: Bearer your-token"
The pattern is always the same: claude mcp add --transport http <name> <url>. The name is how you refer to this server later. The URL is where the MCP server lives. If the server needs a token, use --header to add an auth header.
03 · Code example
Stdio servers run local processes. This example uses the dbhub package to connect Claude to a PostgreSQL database.
Add a PostgreSQL server
claude mcp add --transport stdio db \
-- npx -y @bytebase/dbhub \
--dsn "postgresql://readonly:pass@localhost:5432/mydb"
Add with environment variables
claude mcp add --transport stdio airtable \
--env AIRTABLE_API_KEY=YOUR_KEY \
-- npx -y airtable-mcp-server
The -- (double dash) separates Claude's options from the server's command and arguments. Everything after -- is the command to run the MCP server. Use --env to pass API keys as environment variables safely — don't hardcode them.
04 · Step-through
1. Pick a server
Decide which MCP server you want to add. For HTTP servers, you need the server's URL. For stdio servers, you need the npm package name or command. Check the official MCP servers list or your service's docs.
2. Run claude mcp add
For remote servers use claude mcp add --transport http <name> <url>, and for local ones use claude mcp add --transport stdio <name> -- <command>. Remember: all options go before the name, and -- separates the server command.
3. Confirm it's connected
Run claude mcp list to see all configured servers, or use /mcp inside Claude Code to check status and authenticate. A green status means the server is connected and ready.
4. Ask Claude to use it
Start a Claude Code conversation and ask a question that needs that server. GitHub: "Show me my open PRs." Database: "What tables exist?" Claude discovers the server's tools automatically.
05 · Quiz
You're adding a local database server that needs a DATABASE_URL environment variable. Flag order matters. Which command is correct?
- claude mcp add --transport stdio --env DATABASE_URL=... db -- npx dbhub
- claude mcp add db --transport stdio --env DATABASE_URL=... -- npx dbhub
- claude mcp add --transport stdio db -- npx dbhub --env DATABASE_URL=...
- claude mcp add -- npx dbhub --transport stdio db
06 · Fill in the blank
To list every MCP server you've configured, run claude mcp _____
Other lessons in this chapter
⚠ The full interactive experience needs JavaScript. Please enable it and reload.
※ This is an independent Traditional Chinese teaching project — not an official Anthropic product. Claude™ is a trademark of Anthropic, PBC.