How to Connect an MCP Server to Claude Code
Add a Model Context Protocol server so Claude Code can use external tools like a database, browser, or docs source.
The Model Context Protocol (MCP) lets Claude Code talk to external tools through a small server: a database connector, a browser, a docs index, and more. Once a server is connected, its tools appear to the agent automatically. This guide adds one with the CLI and confirms it works.
What you need
- Claude Code installed
- The command or URL for an MCP server you want to add
- Any credentials that server needs (as environment variables)
- About 10 minutes
Step 1: Add the server
Use claude mcp add to register a server. Below adds a filesystem server that runs over stdio. The double dash separates Claude's flags from the server's own command.
Step 2: Pass any required secrets
Servers that need a token take it via an environment variable. Use the --env flag so the value is stored in config, not pasted into chat.
claude mcp add github \
--env GITHUB_TOKEN=ghp_yourtokenhere \
-- npx -y @modelcontextprotocol/server-githubStep 3: Verify the connection
List your servers to confirm the status is connected. If it shows failed, the server command or a credential is wrong.
Step 4: Use the new tools
Start a session and run /mcp to see the tools the server exposes, then ask for something that needs them. The agent will call the server when relevant.
Result: Claude Code now has new capabilities beyond editing files, and you can add more servers the same way to wire it into the tools you already use.
Watch related tutorials
12:05
23:41
18:30
1:42:18
28:14
41:09