LLM Usage MCP logo

LLM Usage MCP

by zhaoyue722

Tracks local LLM usage and costs across four providers, with spend queries, pricing comparisons, and budget-based recommendations.

Install LLM Usage MCP

Pick your client, then add it in one click or paste the config.

STDIOPython
~/Library/Application Support/Claude/claude_desktop_config.json
claude_desktop_config.json
{
  "mcpServers": {
    "zhaoyue722-llm-usage-mcp": {
      "command": "uvx",
      "args": [
        "llm-usage-mcp"
      ]
    }
  }
}

Settings → Developer → Edit Config, merge this into mcpServers, then fully quit and reopen Claude Desktop.

Claude Code command
claude mcp add --transport stdio zhaoyue722-llm-usage-mcp -- uvx llm-usage-mcp

Run in your terminal. Add --scope project to share it with your team through .mcp.json.

We couldn’t confirm it starts correctly

The install command started, but didn't respond the way we expected when we tried to talk to it.

uvx llm-usage-mcp

initialize succeeded but no response to tools/list.

This is an experimental automated check and can have false negatives — missing environment variables, a slow cold install, etc. It doesn’t necessarily mean something’s wrong. Last checked .

Overview

The zhaoyue722/llm-usage-mcp MCP server records LLM API usage in a local SQLite ledger and exposes cost analysis through MCP tools. It supports Anthropic, OpenAI, Qwen, and DeepSeek, calculating costs from a provider pricing table and handling Chinese-provider pricing with CNY-to-USD conversion. Use it when an agent or local workflow needs spend totals, provider comparisons, pricing lookup, or cheapest-model recommendations without sending usage data to a hosted service. A separate local capture proxy can record calls automatically, while `record_usage` supports manual ingestion.

Use cases

  • Track API spend across Anthropic, OpenAI, Qwen, and DeepSeek
  • Compare projected costs for a token-based workload
  • Recommend a priced model within a specified budget
  • Inspect weekly or monthly usage summaries
  • Record usage manually when a capture proxy is unavailable

Key features

  • Local SQLite usage ledger
  • Provider and model spend breakdowns
  • CNY-to-USD support for Chinese providers
  • Idempotent recording with request IDs
  • Cross-provider cost comparison
  • Budget-based model recommendations

Tools7

What LLM Usage MCP lets your agent do. Expand a tool for its parameters.

Verified live~2.2k tokens of context

Security & health

What it can reach and how reliably it runs — from our own checks, not the maintainer’s claims.

ActiveLast checked

Recent health check succeeded.

30/30 checks healthy over the last 117d

Supply-chain signal

No high-severity advisories surfaced by our automated scan.

Critical 0High 0Medium 0Low 0

Scanned 13d ago via OSV.dev · llm-usage-mcp (PyPI)

Adoption & maintenance

Factual signals from GitHub, npm, and our automated checks — not a rating.

GitHub stars6Stargazers on the source repository.
Last commit12d agoMost recent push to the default branch.
Install checkInconclusiveStarted but did not complete the MCP handshake in our test.
Tools exposed7Callable tools this server registers over MCP.
Directory activity10 viewsConfig copies, upvotes, and views on AllMCPs.

How LLM Usage MCP works

What zhaoyue722/llm-usage-mcp MCP server does

The zhaoyue722/llm-usage-mcp MCP server provides a local ledger for LLM API usage and cost analysis. It supports Anthropic, OpenAI, Qwen, and DeepSeek, including Chinese-provider pricing represented with CNY-to-USD conversion. Data is stored in SQLite at ~/.llm-usage/usage.db.

The server is a cost meter rather than a request router. It does not select models for live API calls or alter client traffic. Its recommendation tools evaluate recorded or hypothetical workloads using the available pricing catalog.

How it works

Usage can enter the ledger through the local capture proxy or through the record_usage MCP tool. The proxy listens only on 127.0.0.1:5525, keeps provider keys on the server side, and provides provider-specific routes for Anthropic, OpenAI, DeepSeek, and Qwen-compatible clients. Each recorded call includes token counts, cost, latency, and a request ID. Reusing a request ID makes repeated ingestion idempotent.

Costs are calculated against the pricing table when a usage row is inserted. query_spend can group results by provider, model, project, tag, or day, and accepts ISO-8601 time boundaries. Failed rows are excluded by default from spend totals and summaries; callers can include them for capture diagnostics. Calendar summaries cover today, week, month, and year using UTC boundaries.

The comparison and recommendation tools use input and output token counts. compare_providers ranks priced models by projected cost, while recommend_provider applies optional provider, model, and budget filters. Recommendations are cost-only in the current version; a task description is echoed in the explanation but does not influence model selection.

Setup and configuration

Install the package with uv tool install llm-usage-mcp, or run the MCP entry point with uvx llm-usage-mcp. The package requires Python 3.13 or newer according to the project metadata.

For automatic capture, configure the API key for each provider in use: ANTHROPIC_API_KEY, OPENAI_API_KEY, DEEPSEEK_API_KEY, or DASHSCOPE_API_KEY for Qwen. Start the proxy with llm-usage-proxy, then point the client’s matching base URL at the loopback proxy. The proxy can start without every provider key, but requests for an unconfigured provider return a configuration error.

The MCP server communicates over stdio. Claude Code can register it with the llm-usage-mcp executable, and the README also identifies Cursor as an MCP client that can use it. A CLI is included for spend, comparison, recommendation, model, provider, status, and proxy operations.

Tools and capabilities

The MCP surface includes:

  • record_usage for manually logging a call.
  • query_spend for filtered, grouped spend windows.
  • usage_summary for totals, top providers, top models, and the largest call.
  • compare_providers for projected cross-model pricing.
  • recommend_provider for cost-based model selection with optional budgets.
  • get_pricing and list_providers for inspecting the local pricing catalog.

The zhaoyue722/llm-usage-mcp MCP server excludes null or empty tags and projects from their respective grouped results. Multi-tag events appear once per tag, so grouped call counts may exceed the total number of calls. Unknown pricing filters return an empty result from get_pricing, while provider or model allowlists that match nothing cause recommendation errors.

Limitations and notes

Pricing and recommendations depend on the seeded local catalog. Recommendation v1 does not use quality benchmarks, and its notes field is reserved for future caveats. If a budget excludes every filtered model, the tool falls back to the cheapest model within the filter set and explains that fallback.

Written by AllMCPs with AI assistance from the project’s README and listing data. How we build listings

Reviews

No reviews yet — be the first to share how it worked for you.

Frequently Asked Questions about LLM Usage MCP

Install it with `uv tool install llm-usage-mcp`, or run the MCP entry point with `uvx llm-usage-mcp`.

Yes. Usage is stored in a local SQLite database at `~/.llm-usage/usage.db`.

Yes. The README identifies Cursor as an MCP client that can use the stdio server.

Automatic proxy capture uses the key for each provider in use: `ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, `DEEPSEEK_API_KEY`, or `DASHSCOPE_API_KEY`.

Related MCP servers

Add a badge to your READMEShow it’s listed — live SVG, Markdown or HTML.

AllMCPs Directory Badge

Full Badge Customizer

Showcase your server listing on GitHub or your project documentation. Embed this dynamic SVG badge to highlight official listing status and live engagement.

Badge Style:
Live Dynamic SVG PreviewLLM Usage MCP AllMCPs Directory Badge
Markdown (GitHub README)
[![AllMCPs](https://allmcps.com/api/badge/zhaoyue722-llm-usage-mcp?style=directory)](https://allmcps.com/mcp/zhaoyue722-llm-usage-mcp)
HTML Embed
<a href="https://allmcps.com/mcp/zhaoyue722-llm-usage-mcp"><img src="https://allmcps.com/api/badge/zhaoyue722-llm-usage-mcp?style=directory" alt="LLM Usage MCP on AllMCPs" /></a>