# LLM Usage

Tracks what your LLM calls cost and serves those numbers to a coding agent over MCP. Useful when the monthly bill is a surprise.

- MCP server · `type=mcp` · Claude Code, Codex, Cursor, GitHub Copilot, Windsurf (Devin Desktop), Cline, Zed, Gemini CLI · ★ 6
- Author: zhaoyue722
- License: MIT · policy=link-only · description only; the file stays with the author
- Source: https://github.com/zhaoyue722/llm-usage-mcp
- Updated: 2026-10-21
- HTML: https://affpapa.org/en/nevibecode/mcp/llm-usage

## What it 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.

## Requirements
- Needs: Python and uv (commands run via uvx)

## Install

### Claude Code (native platform)

**Platform CLI**
```bash
claude mcp add llm-usage-mcp -- uvx llm-usage-mcp
```
uvx runs the command named after the package; if the README names another one, use uvx --from llm-usage-mcp <command>

### Codex

**Platform CLI**
```bash
codex mcp add llm-usage -- uvx llm-usage-mcp
```
uvx runs the command named after the package; if the README names another one, use uvx --from llm-usage-mcp <command>

### Cursor

**Config file**
File `.cursor/mcp.json`:
```json
{
    "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>

### GitHub Copilot

**Config file**
File `.vscode/mcp.json`:
```json
{
    "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>

### Gemini CLI

**Platform CLI**
```bash
gemini mcp add llm-usage uvx llm-usage-mcp
```
uvx runs the command named after the package; if the README names another one, use uvx --from llm-usage-mcp <command>

## When to use it
- 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
- How much did I spend on Claude this week?
- Show my spend broken down by provider.

## Similar
- [model-usage](https://affpapa.org/en/nevibecode/skills/model-usage.md) — skill · 5500 installs
- [claude-usage-analyst](https://affpapa.org/en/nevibecode/skills/claude-usage-analyst.md) — skill · 403 installs
- [cost-benchmark](https://affpapa.org/en/nevibecode/skills/cost-benchmark.md) — skill · 679 installs
- [llm-council](https://affpapa.org/en/nevibecode/skills/llm-council.md) — skill · 1400 installs
- [llm-context](https://affpapa.org/en/nevibecode/skills/llm-context.md) — skill · 1300 installs
- [jetson-llm-serve](https://affpapa.org/en/nevibecode/skills/jetson-llm-serve.md) — skill · 1200 installs

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
