Claude Code is Anthropic’s CLI for AI-assisted software development. It runs in your terminal and has first-class MCP support. This chapter covers how to configure MCP servers for Claude Code, both at the project level and globally.
Claude Code reads MCP configuration from two places:
| Scope | File | Description |
|---|---|---|
| Project | .mcp.json (in project root) |
MCP servers for this specific project |
| User | ~/.claude/settings.json |
MCP servers available in all projects |
Project-level configuration takes precedence and is the recommended starting point. It can be committed to version control so all team members share the same server setup.
.mcp.json)Create .mcp.json in the root of your project:
{
"mcpServers": {
"my-server": {
"command": "python",
"args": ["./tools/mcp_server.py"]
}
}
}
Unlike Claude Desktop, Claude Code resolves paths relative to the .mcp.json file’s location. Relative paths work here, which makes project configs portable.
{
"mcpServers": {
"db-tools": {
"command": "python",
"args": ["./mcp/db_server.py"],
"env": {
"DATABASE_URL": "${DATABASE_URL}"
}
}
}
}
Claude Code supports ${VAR_NAME} syntax to forward environment variables from your shell to the server process.
For servers you want available in every project, add them to ~/.claude/settings.json:
{
"mcpServers": {
"personal-notes": {
"command": "python",
"args": ["/home/user/tools/notes_server.py"]
}
}
}
Use absolute paths in user-level config since the working directory varies by project.
For HTTP/SSE servers:
{
"mcpServers": {
"remote-tools": {
"url": "https://my-mcp-server.example.com/sse"
}
}
}
Use the /mcp slash command inside Claude Code to see the status of connected servers:
/mcp
This lists all configured servers, their connection status, and the tools they expose. It is the fastest way to confirm your server is connected and working.
You can also use:
/mcp list-tools
To see all available tools from all connected servers.
Claude Code has a permission system that controls what actions Claude can take, including which MCP tool calls require approval.
By default, Claude Code asks for confirmation before calling MCP tools that could have side effects. You can configure trust levels in your settings:
{
"mcpServers": {
"my-server": {
"command": "python",
"args": ["./server.py"]
}
},
"permissions": {
"allow": [
"mcp__my-server__read_file",
"mcp__my-server__search"
]
}
}
The permission format is mcp__{server-name}__{tool-name}. Tools listed in allow are called without prompting the user.
For local development servers you trust completely, you can allow all tools from a server:
{
"permissions": {
"allow": ["mcp__my-server__*"]
}
}
Once connected, Claude Code can use your server’s tools automatically. You do not need to invoke them explicitly — Claude decides when a tool is relevant.
To explicitly ask Claude to use a tool:
Use the search_knowledge_base tool to find documentation about authentication
Claude Code will call the tool and incorporate the result into its response.
When a server is connected via stdio, its stderr output appears in Claude Code’s internal logs. To view logs:
# On macOS/Linux
tail -f ~/.claude/logs/mcp-*.log
Add structured logging to your server to make debugging easier:
import logging, sys
logging.basicConfig(
stream=sys.stderr,
level=logging.DEBUG,
format="%(asctime)s %(name)s %(levelname)s %(message)s",
)
A typical workflow when developing an MCP server for use with Claude Code:
mcp dev server.py.mcp.json in your project/mcp in Claude Code to verify the connectionFor hot-reload during development, use mcp dev — it watches for file changes and restarts the server automatically.
.mcp.json in your project root for project-specific servers~/.claude/settings.json for user-wide servers.mcp.json; use absolute paths in user settings/mcp in Claude Code to verify connections and list tools| ← Chapter 7: Connecting to Claude Desktop | Table of Contents | Chapter 9: Connecting to Other Clients → |