Skip to main content

Claude Code Integration

You can configure Claude Code to direct its requests through the LeanMCP AI Gateway by using environment variables.

Configuration

Claude Code reads its settings from a JSON configuration file. You can inject environment variables directly into this configuration to override the default Anthropics API endpoints.
1

Locate Configuration File

Find your .claude/settings.json file. This is typically located in your home directory:
  • Windows: C:\Users\<your-username>\.claude\settings.json
  • macOS/Linux: ~/.claude/settings.json
2

Update Environment Variables

Add the env property to your settings.json to set the base URL and authentication token.
{
  "autoUpdatesChannel": "latest",
  "env": {
    "ANTHROPIC_BASE_URL": "https://aigateway.leanmcp.com/v1/anthropic",
    "ANTHROPIC_AUTH_TOKEN": "leanmcp_your_api_key_here",
    "ANTHROPIC_API_KEY": ""
  }
}
Ensure ANTHROPIC_API_KEY is set to an empty string ("") or removed if ANTHROPIC_AUTH_TOKEN is used, to avoid conflicts. The Gateway uses ANTHROPIC_AUTH_TOKEN (mapped to your LeanMCP key).

usage

Once configured, simply use claude commands as normal. All requests will be routed through the LeanMCP AI Gateway, providing you with unified logging and observability.