Skip to main content
Glama
README.md
<div align="center">

<img src="logo.svg" alt="Tokmeter" width="128" height="128">

# Tokmeter

**Every AI coding agent you run, on one ledger.**

Tokmeter reads the session files your agents already write to disk and turns them into token and cost totals by project, model, provider, and day — across 24 agents and editors, including Claude Code, Codex, Gemini CLI, Cursor, Muse, Cline, Augment, Copilot CLI, Kimi Code and DeepSeek Harness. An agent it has no built-in parser for can register a path and emit a simple usage line to show up too. No API keys, no telemetry, no account. Your data never leaves the machine.

[![release](https://img.shields.io/badge/release-v1.28.0-8b5cf6)](https://github.com/sriinnu/tokmeter/releases)
[![npm](https://img.shields.io/npm/v/%40sriinnu%2Ftokmeter?color=cb3837&label=npm)](https://www.npmjs.com/package/@sriinnu/tokmeter)
[![license](https://img.shields.io/badge/license-AGPL--3.0-blue)](LICENSE)
[![platforms](https://img.shields.io/badge/CLI%20%26%20MCP-macOS%20%C2%B7%20Linux%20%C2%B7%20Windows-22c55e)](#-multi-os-surfaces)
[![macOS Bar](https://img.shields.io/badge/macOS%20Bar-14%2B-000000?logo=apple)](packages/macos-bar/README.md)
[![sriinnu/tokmeter MCP server](https://glama.ai/mcp/servers/sriinnu/tokmeter/badges/score.svg)](https://glama.ai/mcp/servers/sriinnu/tokmeter)

</div>

---

## Why

Every agent bills you separately and shows you its own slice. Claude Code knows what Claude Code cost. Codex knows what Codex cost. Nothing knows what *today* cost, or which project is quietly burning the most, or whether the model you switched to is actually cheaper for the work you do.

Tokmeter answers that from data already on your disk. It parses each agent's local session logs, prices them against a live model catalog, and keeps an append-only daily ledger so history survives even after the agents rotate their own logs away.

```sh
npx @sriinnu/tokmeter --today
```

Docs and the theme gallery: **[tokmeter.srinivas.dev](https://tokmeter.srinivas.dev)**.

## What it looks like

| | |
|---|---|
| <img src="docs/assets/screenshots/cli-overview.png" alt="CLI overview"> | <img src="docs/assets/screenshots/cli-digest.png" alt="CLI digest"> |
| **CLI** — usage by project, model and provider | **Digest** — a weekly report card |

<div align="center">
<img src="docs/assets/screenshots/bar-popover.png" alt="macOS menubar popover" width="420">

**macOS menubar** — today's tokens and cost, always visible
</div>

There is also a terminal UI (`tokmeter-tui`), a local web dashboard, a statusline for Claude Code, and an MCP server so an agent can query its own spending.

## Multi-OS Surfaces

The CLI, TUI, local web dashboard, ambient status feed, and MCP server all run identically across **macOS, Linux, and Windows** — while `TokmeterBar` provides a native SwiftUI menubar companion on macOS:

```sh
# 1. Shareable privacy-scrubbed receipt (Thermal / Broadsheet, terminal or SVG)
tokmeter receipt --today --style thermal
tokmeter receipt --week --style broadsheet --svg receipt.svg

# 2. Per-branch / per-PR AI cost attribution (paste right into GitHub PRs)
tokmeter git --markdown

# 3. Ambient statusline on Linux, Windows & macOS terminals (<25ms via daemon)
tokmeter bar --format tmux        # or: waybar | polybar | starship | powershell | json
tokmeter bar --snippet waybar     # ready-to-paste config snippet
```

## Install

Requires Node.js 22+. Tools that keep history in SQLite need 22.13+, and DeepSeek Harness logs need 22.15+. Reading session files needs no provider credentials. Pricing fetches public catalogs, and `--light` skips that for one command.

```sh
# Try it without installing
npx @sriinnu/tokmeter --today

# Install the CLI, and the daemon/MCP server
npm install -g @sriinnu/tokmeter @sriinnu/tokmeter-mcp
```

| Package | Contents |
| --- | --- |
| [`@sriinnu/tokmeter`](packages/tokmeter/README.md) | Core API, CLI, and terminal UI |
| [`@sriinnu/tokmeter-mcp`](packages/mcp/README.md) | MCP server, daemon, statusline, and live terminal UI |

`packages/core`, `packages/cli`, and `packages/tui` are private workspace packages bundled into `@sriinnu/tokmeter`. `packages/web` is a separate private workspace app run from source.

To keep the daemon always-on (so the menubar and statusline survive reboots), install the launchd agent once: `tokmeter-mcp daemon install-agent` (macOS). It auto-starts at login and respawns on crash.

Claude Code and Codex are the primary validation targets. See [provider compatibility](docs/compatibility.md) for the other parsers and their known limits.

## CLI

```sh
tokmeter --today
tokmeter models --project my-app --json
tokmeter daily --week
tokmeter projects
tokmeter stats --month
tokmeter digest --period week
tokmeter pricing sonnet
```

Filters include `--project`, `--claude`, `--codex`, `--week`, `--month`, and `--since YYYY-MM-DD --until YYYY-MM-DD`. Use `--json` for machine-readable output and `--light` for token-only reports.

- [Aliases](docs/aliases.md): merge display names, tag projects, or hide them from lists.
- [Backup and restore](docs/backup-restore.md): portable snapshots, cleanup preview, restore. Cleanup deletes source files; keep the confirmation and backup steps.
- [CLI reference](packages/cli/README.md): every command with examples.
- [How the numbers work](docs/how-the-numbers-work.md): what each bucket means and where estimates enter.

## TypeScript API

The root export provides the core API. Convenience query helpers use the `/cli` subpath.

```ts
import { TokmeterCore } from "@sriinnu/tokmeter";
import { loadTokmeterSummary } from "@sriinnu/tokmeter/cli";

const core = new TokmeterCore();
await core.scan({ providers: ["codex", "claude-code"], today: true });
const models = core.getModelCosts();
const daily = core.getDailyBreakdown();

const summary = await loadTokmeterSummary({ week: true, light: true });
```

Reuse one core scan when querying several breakdowns. See [integration guidance](docs/consuming-tokmeter.md), [core API usage](packages/core/README.md), and the [tokmeter agent skill](https://github.com/sriinnu/tokmeter-skill) (`npx skills add sriinnu/tokmeter-skill --skill tokmeter -g`) for agent-facing integration instructions.

## Daemon, MCP, and statusline

```sh
tokmeter-mcp daemon start
tokmeter-mcp daemon status
tokmeter-mcp serve             # MCP server over stdio
tokmeter-mcp statusline        # one statusline tick
tokmeter-mcp live              # live terminal UI
```

The daemon uses local HTTP port `9877` for queries and WebSocket port `9876` for live registration. Private reads and WebSocket connections require the per-user token in `~/.tokmeter/daemon/daemon.token`; `/api/ready` is the public health check. The macOS app, statusline, and MCP server read that credential at use time. Daemon commands belong to `@sriinnu/tokmeter-mcp`; install it for these surfaces.

MCP tools use the `tokmeter_` prefix and cover usage queries, comparisons, receipts, git-branch cost attribution, forecasts, export, and cleanup previews. All 24 are read-only: deleting and restoring sessions stays in the CLI and TUI, where you confirm it. See the [MCP tool reference](docs/mcp-tools.md) for every tool grouped by purpose, and the [package MCP README](packages/mcp/README.md) for configuration and programmatic exports.

`tokmeter-mcp editors` lists installer targets. `tokmeter-mcp install-mcp` and `tokmeter-mcp install-statusline` write editor configuration; inspect the generated settings for your editor. For Claude Code, register the MCP server with `claude mcp add tokmeter --scope user -- npx -y @sriinnu/tokmeter-mcp serve` (from 1.15.0, `install-mcp` runs `claude mcp add` itself; 1.14.1 and earlier wrote the entry to `~/.claude/settings.json`, which Claude Code doesn't read). See [architecture](docs/architecture.md) for registration, authentication, refresh, storage, and daemon lifecycle details.

## Terminal and web interfaces

```sh
# After installing @sriinnu/tokmeter
tokmeter-tui

# Without a global install
npx -p @sriinnu/tokmeter tokmeter-tui
```

The terminal UI supports overview, model, daily, statistics, and cleanup views. See its [keys and commands](packages/tui/README.md).

Run the web workspace from a source checkout:

```sh
bun install
bun run dev:web
```

Vite opens the dashboard in your browser on `127.0.0.1:3000` with a per-launch session link; a plain request to that port can't read your usage. See [web setup and data sources](packages/web/README.md).

## macOS app

Release builds target Apple silicon and macOS 14+. Node.js 22+ with npx is also required for the local daemon.

Install it with `brew install --cask sriinnu/homebrew-tap/tokmeterbar`, or download `TokmeterBar-<version>.zip` from [GitHub Releases](https://github.com/sriinnu/tokmeter/releases) and move it to `/Applications`. The app starts the version-matched `@sriinnu/tokmeter-mcp` daemon itself when none is running, and updates through Sparkle.

The popup gives today's tokens and estimated API cost equal prominence, with models and projects below. Chart hover cards show exact daily tokens and cost. **Usage details** expands lifetime totals, trends, and signals. Themes: Terminal, Paper, Prism, Lagoon, Carbon, Glass, and (since 1.15.0) the instrument themes Meter, Pump, Rams, Deck, and Passbook. A **$/M** button in the models header shows each model's list price per million tokens (input, output, cache read, cache write) and where that price came from, and the dashboard port is configurable. The Hub provides larger breakdowns and settings. Settings → **Open web dashboard** starts its local server on demand; **Stop web dashboard** or quitting the app stops it.

See [macOS build and runtime details](packages/macos-bar/README.md), [first-use checks](docs/macos/first-use.md), and [popover validation](docs/macos/popover-usability.md). The [completion tracker](docs/macos-completion.md) records remaining fresh-machine, reliability, update, accounting, accessibility, and trial gates.

The [synthetic walkthrough](docs/assets/demo/README.md) documents how the example images were generated; it is not a capture of a current local candidate.

## Documentation

- [MCP tool reference](docs/mcp-tools.md) — all 24 `tokmeter_` tools, grouped
- [Consuming tokmeter](docs/consuming-tokmeter.md) — MCP, daemon HTTP, CLI, and in-process integration
- [How the numbers work](docs/how-the-numbers-work.md) — bucket semantics and where estimates enter
- [Backup, snapshot & restore](docs/backup-restore.md) — the confirmation/backup model and cross-machine restore
- [Troubleshooting](docs/troubleshooting.md) — daemon, bar updates, "shrinking" history, performance
- [Architecture](docs/architecture.md) — daemon lifecycle, storage, refresh
- [Security and privacy](docs/security.md) — what is read, what leaves the machine, and how releases are signed

## Privacy

Tokmeter reads session files your agents already wrote, sends **no credentials**
and **no telemetry**, and requires **no account**. Your usage data doesn't leave
the machine.

It does download public price catalogs: the daemon refreshes them about daily on
its own, and `--light` skips that only for the command it's on. The macOS app also
checks GitHub for updates. [Security and privacy](docs/security.md) lists every
host and how to check.

## Support

Tokmeter is free and open source. If it saves you money, consider chipping in to keep it maintained:

- [GitHub Sponsors](https://github.com/sponsors/sriinnu)
- [Buy Me a Coffee](https://buymeacoffee.com/sriinnu)

## License

[AGPL-3.0-only](LICENSE). See [licensing notes](docs/licensing.md) for what that means if you embed Tokmeter in another product.

TDQS

A3.7/5.0

Scored across 24 tools

Disambiguation4/5

Most tools target distinct facets (pulse, models, providers, timeline, projects, search, export, heatmap, anomaly, git_cost) and descriptions explicitly cross-reference each other with 'use X for Y instead' guidance, which strongly aids selection. The remaining ambiguity is mild: pulse vs digest, models vs model_advisor vs leaderboard, and budget vs budget_alert overlap conceptually even though descriptions separate them.

Naming Consistency4/5

All tools share the tokmeter_ prefix and snake_case, giving a highly predictable surface, with multi-word names like cache_efficiency, budget_alert, and cost_optimization_tips staying readable. Minor deviation: most names are bare nouns (models, providers, heatmap) while others are verbs (search, compare, export, forecast), so there is no strict single verb_noun convention.

Tool Count3/5

At 24 tools this sits at the heavy end of the scale for what is fundamentally a read-only spend-analytics domain. While each tool maps to a real analytical question, several feel like variants of the same view (pulse/digest, models/model_advisor/leaderboard, budget/budget_alert), pushing the surface past comfortable scope.

Completeness4/5

Coverage is broad across the analytics lifecycle: overview, per-model/provider/project breakdowns, time trends, forecasting, budgets, anomalies, efficiency/caching, export, receipts, and git attribution. The main gap is that destructive cleanup is only previewable (deletion is deliberately terminal-only), and there is no scheduling/alert persistence, but both appear intentional and are documented.

Maintenance

ActivityActive
ResponsivenessNo recent community issues