AI Usage logo

AI Usage

Analyze local Claude Code, Codex CLI, and OpenCode token usage, costs, cache breaks, limits, and project trends.

Install AI Usage

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

STDIONode.js
~/Library/Application Support/Claude/claude_desktop_config.json
claude_desktop_config.json
{
  "mcpServers": {
    "ai-usage": {
      "command": "npx",
      "args": [
        "-y",
        "ai-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 ai-usage -- npx -y ai-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

We hit an unexpected error while testing this listing automatically.

npx -y ai-usage-mcp

Rate limit exceeded, please try again later - you have reached the maximum number of concurrent E2B sandboxes (20). If you need more, please visit 'https://e2b.dev/docs/billing'

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

AI Usage connects Claude Code, Codex CLI, and OpenCode histories to local MCP tools for token and cost analysis. It imports observed usage into a local SQLite database, keeps history beyond Claude Code’s transcript cleanup period, and separates client-reported costs from estimates. Use it to investigate expensive sessions, compare models, analyze cache losses, review project or daily spending, and track Claude Pro or Max limits. The package runs through npx and requires Node.js 22.13 or newer.

Use cases

  • Find which projects, models, or sessions consume the most tokens
  • Investigate prompt-cache losses and their estimated cost
  • Compare actual spending with another model’s list rates
  • Track Claude Pro or Max limits and reset forecasts

Key features

  • Local SQLite history for Claude Code, Codex CLI, and OpenCode usage
  • Token and cost reports by session, model, client, project, and day
  • Prompt-cache break detection with cost analysis
  • Counterfactual pricing at alternate model rates
  • Claude Pro and Max five-hour and weekly limit tracking
  • CSV, JSON, status-line, verification, and MCP prompt support

Tools12

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

Self-reported~216 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.

16/16 checks healthy over the last 89d

Supply-chain signal

No high-severity advisories surfaced by our automated scan.

Critical 0High 0Medium 0Low 0

Scanned 7d ago via OSV.dev · ai-usage-mcp (npm)

Adoption & maintenance

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

GitHub stars1Stargazers on the source repository.
npm downloads1.3kPackage downloads in the last 30 days.
Last commit4d agoMost recent push to the default branch.
Install checkInconclusiveWe hit an unexpected error running the automated check.
Tools exposed12Callable tools this server registers over MCP.

How AI Usage works

What AI Usage MCP server does

AI Usage turns local activity from Claude Code, Codex CLI, and OpenCode into queryable usage data. It reports token counts, costs, sessions, projects, models, clients, and dates, giving an MCP-compatible agent enough context to answer questions about where usage went and what to change.

The server also examines prompt-cache behavior for individual sessions. Its cache analysis identifies turns where a cached prefix was lost, shows the likely reason, and calculates the associated cost. For Claude Pro and Max users, plan tracking records five-hour and weekly limit readings, reset times, current pace, and projected usage.

How it works

On its first run, the package imports available history into a local SQLite database. As new source data is seen, turns are copied into that database, allowing longer retention than Claude Code’s configurable transcript cleanup. The data remains on the local machine; the server does not require an account or API key and does not upload usage records.

Cost reporting keeps values supplied by a client separate from package estimates. When a source lacks a value, the result remains unavailable rather than being treated as zero. A verification command independently rereads source files and compares its findings with the database, helping detect inflated counts caused by repeated usage objects in JSONL records.

Setup and configuration

Run the package directly with:

Terminal
npx ai-usage-mcp

The required runtime is Node.js 22.13 or newer. Storage uses Node’s built-in node:sqlite; an optional better-sqlite3 fallback can be used on older Node versions, but it is not required for the normal supported runtime.

Claude Code can add the server with claude mcp add ai-usage -s user -- npx -y ai-usage-mcp, or install the supplied Claude Code plugin. Codex CLI uses codex mcp add ai-usage -- npx -y ai-usage-mcp. OpenCode, Cursor, VS Code, Windsurf, Claude Desktop, and JetBrains are also listed as installation targets. Native Windows clients should invoke npx through cmd /c.

Tools and capabilities

The MCP tools include:

  • usage_report for an overall verdict, major usage areas, heavy sessions, and suggested changes.
  • usage_summary, daily_usage, project_usage, model_usage, and client_usage for grouped totals.
  • session_usage and recent_sessions for detailed or recent session views.
  • usage_breakdown for combined dimensions such as project by day or model by day.
  • counterfactual_cost for pricing the same tokens at another model’s listed rates.
  • cache_health for locating and pricing lost prompt-cache prefixes.
  • plan_usage for five-hour and weekly Pro or Max limit status, reset times, and pace.

The package also provides a command-line interface, resources, prompts, CSV and JSON export, and a status-line command for retaining plan-limit readings.

Limitations and notes

The analysis depends on history written by the supported clients, so it is intended for local usage records rather than remote provider billing data. Plan-limit tracking relies on readings passed through Claude Code’s status-line mechanism. Historical retention depends on the server seeing source data before it is removed; imported records remain in the local database afterward.

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 AI Usage

AI Usage is an MCP server that connects to local Claude Code, Codex CLI, and OpenCode usage histories. Its main tools report tokens and costs by session, model, client, project, and day, while also analyzing prompt-cache breaks, alternate-model pricing, and Claude Pro or Max plan limits.

Install it by running `npx ai-usage-mcp`, then add it to your MCP client with that command. Claude Code and Codex CLI provide dedicated `mcp add` commands; Claude Code also has a plugin installation path, and configuration examples are listed for other supported clients.

Yes, Cursor is listed as a supported installation target. Configure it as a local MCP server using the command that runs `npx -y ai-usage-mcp`.

AI Usage stores imported history in a local SQLite database and does not upload it. The database preserves records after Claude Code removes older source transcripts according to its cleanup period.

Yes, the `plan_usage` tool reports five-hour and weekly limit usage, reset times, and usage pace. A status-line command can retain readings passed through Claude Code’s status-line mechanism.

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 PreviewAI Usage AllMCPs Directory Badge
Markdown (GitHub README)
[![AllMCPs](https://allmcps.com/api/badge/ai-usage?style=directory)](https://allmcps.com/mcp/ai-usage)
HTML Embed
<a href="https://allmcps.com/mcp/ai-usage"><img src="https://allmcps.com/api/badge/ai-usage?style=directory" alt="AI Usage on AllMCPs" /></a>