LLM Usage — Claude Code MCP server for LLM API spend tracking
Tracks what your LLM calls cost and serves those numbers to a coding agent over MCP. Useful when the monthly bill is a surprise.
claude mcp add llm-usage-mcp -- uvx llm-usage-mcpWhat LLM Usage does
The server sits in front of your providers as a local proxy, records each call, prices it per provider and writes the result to a SQLite file at ~/.llm-usage/usage.db. It binds to 127.0.0.1:5525 only, so nothing on the network can reach it, and your API keys stay on the proxy side. Anthropic, OpenAI, DeepSeek and Qwen are covered, streaming and non-streaming alike.
There is a CLI too: llm-usage spend, llm-usage compare, llm-usage recommend. Same data either way — ask the agent or type a command. It is a meter, not a router. Spend gets measured and providers get compared; your calls are left untouched.
You need a key for at least one provider in an environment variable: ANTHROPIC_API_KEY, OPENAI_API_KEY, DEEPSEEK_API_KEY or DASHSCOPE_API_KEY for Qwen. The proxy starts without one, but a request to a provider whose key is missing comes back as 503 configuration_error. Point your client at the proxy with ANTHROPIC_BASE_URL and the matching variables for the other providers.
What it helps with
- see what a week of Anthropic and OpenAI calls cost
- compare the price of one request across providers
- keep spend from several APIs in a single local database
- confirm that an agent call was actually recorded
- price a 10k-in / 2k-out request before picking a model
Example prompts for the agent
- How much did I spend on Claude this week?
- Show my spend broken down by provider.
How to install LLM Usage
Platform CLI
claude mcp add llm-usage-mcp -- uvx llm-usage-mcpuvx runs the command named after the package; if the README names another one, use uvx --from llm-usage-mcp <command>
Platform CLI
codex mcp add llm-usage -- uvx llm-usage-mcpuvx runs the command named after the package; if the README names another one, use uvx --from llm-usage-mcp <command>
Config file
{
"mcpServers": {
"llm-usage": {
"command": "uvx",
"args": [
"llm-usage-mcp"
]
}
}
}uvx runs the command named after the package; if the README names another one, use uvx --from llm-usage-mcp <command>
Config file
{
"servers": {
"llm-usage": {
"type": "stdio",
"command": "uvx",
"args": [
"llm-usage-mcp"
]
}
}
}uvx runs the command named after the package; if the README names another one, use uvx --from llm-usage-mcp <command>
Platform CLI
gemini mcp add llm-usage uvx llm-usage-mcpuvx runs the command named after the package; if the README names another one, use uvx --from llm-usage-mcp <command>
Step by step, with commands for each platform: How to add an MCP server to Claude Code, Codex, Cursor, VS Code, Gemini CLI and more
Questions about LLM Usage
How do I install LLM Usage in Claude Code?
Add the MCP server with claude mcp add llm-usage-mcp -- uvx llm-usage-mcp, or under the name llm-usage: claude mcp add llm-usage -- uvx llm-usage-mcp.
What does LLM Usage do?
It records calls to LLM providers, works out tokens and cost, and returns those numbers through MCP or the CLI.
What do I need before running LLM Usage?
An API key for at least one provider in an environment variable: ANTHROPIC_API_KEY, OPENAI_API_KEY, DEEPSEEK_API_KEY or DASHSCOPE_API_KEY. Without a key the proxy still starts, but requests to that provider return 503 configuration_error.