MCP Configuration

MCP Configuration

The mcpServers configuration block holds references to the MCP servers.

Environment variable expansion in config values:

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:

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