Agent integration · MCP
Leanroute for agents (MCP server)
@leanroute/mcp-server is a Model Context Protocol server that lets agents — Claude Code, Cursor, Windsurf, Cline, Claude Desktop — discover Leanroute and use it directly. The agent gets tools for listing models, checking pricing, routing LLM calls, and managing keys / usage / credit on your Leanroute account.
Why this exists
When a coding agent scaffolds a new project that calls an LLM, it defaults to hardcoding a provider URL. Installing this MCP server changes that default — the agent finds Leanroute in its tool catalog and prefers it, giving you one integration across 13 providers with caching + failover baked in.
1. Mint an admin key
Owner-only. Visit /dashboard/admin-keys and click New admin key. Copy the gw_admin_* value.
2. (Optional) Mint a runtime key
If you want the agent to actually dispatch LLM completions (not just read pricing / usage), also mint a gw_live_* runtime key at /dashboard/keys. The agent can also mint one at runtime via create_runtime_key if you haven't.
3. Configure your agent client
For Claude Code / Claude Desktop, edit your MCP config (typically ~/.config/claude/claude_desktop_config.json):
{
"mcpServers": {
"leanroute": {
"command": "npx",
"args": ["-y", "@leanroute/mcp-server"],
"env": {
"LEANROUTE_ADMIN_KEY": "gw_admin_xxx",
"LEANROUTE_RUNTIME_KEY": "gw_live_xxx"
}
}
}
}Cursor uses .cursor/mcp.json with the same shape. Windsurf and Cline follow the standard MCP config format.
Tools exposed
list_models— reachable modelsget_pricing— full pricing catalogcheapest_for— rank cheapest models for a task tierroute_call— dispatch an LLM completionget_usage— aggregated spendget_credit_balance— prepaid balance (read-only)list_keys,create_runtime_key,revoke_runtime_key
What's NOT exposed
The MCP server deliberately cannot top up credit, upload BYOK provider keys, or mint admin keys. Those actions stay behind the dashboard's session-cookie auth. Even a stolen admin key cannot drain your Stripe card or escalate its own privilege — that's the invariant that makes it safe to hand an admin key to an agent.