Claude Code
Route Claude Code through LeanMCP AI Gateway. Every request gets logged — prompts, responses, token usage — visible in your dashboard in real time. Takes 2 minutes to set up.Before you start
You need two things:A LeanMCP account with credits
Go to app.leanmcp.com/billing to top up credits. Credits are required before the gateway will accept requests.
An API key
Go to app.leanmcp.com/api-keys → Create API Key → select SDK permissions → copy the key immediately (shown once only).Your key format:
leanmcp_859fc75e...Already have a key and credits? Skip straight to Configuration below.
Configuration
Claude Code reads environment variables from~/.claude/settings.json. You’re pointing it at the LeanMCP gateway instead of Anthropic directly.
Find your settings file
| OS | Path |
|---|---|
| macOS / Linux | ~/.claude/settings.json |
| Windows | C:\Users\<username>\.claude\settings.json |
Verify it works
Run any Claude Code command as normal:Then open your dashboard at app.leanmcp.com/observability. You should see the request appear within a few seconds.If you see the log entry: you’re done. ✓
What you’ll see in the dashboard
Once configured, go to app.leanmcp.com/observability. Every Claude Code request is tracked:| Field | What it shows |
|---|---|
| Request Body | Full content sent to the AI |
| Response Body | Complete response received |
| Model | Which model was used |
| Tokens | Input, output, and total token counts |
| Latency | Response time in milliseconds |
| Status | Success or error |
| Timestamp | When the request was made |
Troubleshooting
Requests aren't showing in the dashboard
Requests aren't showing in the dashboard
- Double-check
ANTHROPIC_BASE_URLis exactlyhttps://aigateway.leanmcp.com/v1/anthropicwith no trailing slash - Confirm
ANTHROPIC_API_KEYis set to""— a leftover value will bypass the gateway - Confirm your account has credits at app.leanmcp.com/billing — zero credits means requests are rejected
Authentication error / 401
Authentication error / 401
Your
ANTHROPIC_AUTH_TOKEN is wrong or the key was deleted. Go to app.leanmcp.com/api-keys, create a new key, and update settings.json.How do I switch back to Anthropic direct?
How do I switch back to Anthropic direct?
Remove the
env block from settings.json and restore your ANTHROPIC_API_KEY. The gateway is a proxy — removing it has no side effects.You can also set env vars in your shell profile as an alternative to settings.json:Next steps
View your logs
Open the dashboard to see your Claude Code sessions.
Observability features
What gets logged, sensitive data detection, export options, and alerts.
Use with other tools
Also using Cursor, Windsurf, or Cline? Connect them all to the same gateway.
For teams
Route your whole team through a shared gateway.

