Claude CodeIntermediate

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.

10 minIntermediate

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.

zsh - mcp add
$claude mcp add filesystem -- npx -y @modelcontextprotocol/server-filesystem ~/projects
Added MCP server 'filesystem' (stdio).
$

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.

terminal
claude mcp add github \
  --env GITHUB_TOKEN=ghp_yourtokenhere \
  -- npx -y @modelcontextprotocol/server-github

Step 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.

Terminal - mcp list
$ claude mcp list
filesystem stdio connected
github stdio connected
Use /mcp inside a session to see available tools.
A healthy server reports a connected status.

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.

Claude Code - using MCP
You
List the open issues on this repo and summarize the top three.
Agent
Calling the github MCP server... found 12 open issues. The top three by reactions are: ...
The agent calls an MCP tool to complete the request.
Trust the source
An MCP server can run code and read data on your behalf. Only add servers you trust, and prefer official packages. Treat a third-party server like installing any other dependency.

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

Tags
#mcp#tools#integration#config#servers