MCP Configuration
MCP Configuration
The mcpServers configuration block holds references to the MCP servers.
Environment variable expansion in config values:
${VAR}— expands to the value of environment variable VAR.${VAR:-default}— expands to VAR if set, otherwise uses default.
HTTP server fields: type: "http", url, headers (e.g. Authorization: "Bearer ${API_KEY}").
Local (stdio) server fields: command (the server executable path), args (command-line arguments), env (environment variables passed to the server).
Example:
{
"mcpServers": {
"api-server": {
"type": "http",
"url": "${API_BASE_URL:-https://api.example.com}/mcp",
"headers": { "Authorization": "Bearer ${API_KEY}" }
}
}
}
Where config lives:
~/.claude.json— user-scoped servers.mcp.json(in project dir) — project-scoped servers
Example stdio server config:
{
"mcpServers": {
"weather": {
"type": "stdio",
"command": "npx",
"args": ["-y", "my-mcp-server"]
}
}
}
Adding servers in Claude Code:
# Add a server (available in all projects)
claude mcp add my-mcp-server --scope user -- npx -y my-mcp-server
# List configured servers
claude mcp list
Managing servers in Claude Code:
/mcp # see connected servers and their tools
claude mcp remove my-mcp-server # remove a server
Related: MCP, Claude Code API Key via Third Party