Tallybook
Tallybook is a local MCP server that prices Claude Code and Codex sessions on your disk and tells you what would have been cheaper.
report — total spend over a window (7d/30d/90d/all or a start date), split by tool, model and day, with cache hit rate, sessions, sub-agent runs, findings, and an optional prior-window comparison; filterable by source and project.
finding — one finding in full by its stable id: what happened, why it costs, what to change, what to expect, the evidence table, and an applyable unified diff patch if applicable.
agents — spend per sub-agent type: runs, dominant model and effort, average cost per run, read-only share, tool errors, and requested-vs-actual model mismatches.
changes — every point where a sub-agent's model changed, comparing measured runs before/after with a keep/watch/revert/too-early verdict (threshold tunable via
min_runs).sessions / session — list sessions ranked by cost or recency, or drill into one session turn by turn: model, effort, tokens, context, text length, tool calls, cost, and the sub-agents it launched (no prompt text or tool output is ever returned).
prices — the USD-per-million-token price table every figure is derived from, including user overrides and the last verification date.
refresh — force an immediate rescan of transcript directories and report files scanned, newly ingested, unchanged, and failed.
All tools accept since, source, project, and currency (usd vs. subscription list-price equivalent) filters where relevant, and every response reports plan detection, scan timestamp/age, and any scan errors.
No proxy, no API key, nothing leaves your machine. Run it as a CLI, open the same report in your
browser with tallybook --serve, or add tallybook-mcp to Claude Code or Codex and ask the agent
itself what it's spending and what would be cheaper.
More in the documentation.
Install
brew install --cask magna-nz/tap/tallybookAlso available via go install github.com/magna-nz/tallybook/cmd/tallybook@latest, or as a
release download. Works on macOS, Linux
and Windows.
Add the MCP server so your agent can check its own spend mid-session — tallybook-mcp ships
alongside tallybook, so no separate install:
claude mcp add tallybook -- tallybook-mcp # Claude CodeFor Codex, add it to ~/.codex/config.toml:
[mcp_servers.tallybook]
command = "tallybook-mcp"Related MCP server: nikhilnt
Use
tallybook # this period's report: the five biggest findings
tallybook --serve # the same report, findings and sessions in your browser, on localhost
tallybook findings # every finding, grouped by what kind of change it asks for
tallybook --since 7d --compare # this week against last week: spend, sessions, cache hit rate
tallybook finding 1 # finding #1 in full: what happened, why, what to change
tallybook finding 1 --evidence # the same, with the sessions behind it
tallybook finding 1 --patch # finding #1's fix, as an applyable diff
tallybook agents # spend by sub-agent type, with the model and effort each ran at
tallybook sessions --sort cost # sessions ranked by what they cost
tallybook changes # did a past model swap actually save money?
tallybook setup hook # record sessions automatically as they endDocs
The command reference, the MCP server's tools, configuration, and the privacy model live on the documentation site.
License
MIT
Available Tools
8 toolsagentsBRead-onlyIdempotent
Spend per sub-agent type: runs, the model it mostly used, average cost per run, the share of runs whose tool calls were all read-only, errored tool results, and runs where the requested model differed from the one actually used.
Inputs: since, source, project, currency. Returns: plan, agents, currency, scan_error, +3 more
changesBRead-onlyIdempotent
Every point where a sub-agent's model changed, with the real runs before and after compared and a verdict: keep, watch, revert, or too early. These are measured figures, not estimates.
Inputs: since, source, project, currency, +2 more. Returns: plan, changes, currency, min_runs, +5 more
findingARead-onlyIdempotent
One finding in full, addressed by its stable id from report: what happened, why it costs, what to change, what to expect, plus the evidence table and the patch if there is a file to change.
Inputs: id (required), since, source, project, +1 more. Returns: id, plan, patch, share, +14 more
pricesBRead-onlyIdempotent
The price table every figure is computed from, in US dollars per million tokens, with the date it was last verified. Includes any overrides from the user's config.
Returns: unit, models, verified, scan_error, +2 more
refreshAIdempotent
Rescan the transcript directories now instead of waiting for the automatic rescan, and report how many files were scanned, newly recorded, unchanged, or skipped. Only tallybook's own database is written.
Returns: errors, failed, scanned, ingested, +5 more
reportARead-onlyIdempotent
What the coding agents on this machine cost over a window: the total, the split by tool and by model, and the list of findings about what would have been cheaper. Call finding with an id from the list for the full advice.
Inputs: since, source, compare, project, +1 more. Returns: usd, plan, prior, turns, +17 more
sessionARead-onlyIdempotent
One session turn by turn: model, effort, token counts and cost per model response. Accepts a full session id or a unique prefix. Never returns prompt text, tool output, or command lines; the database does not hold them.
Inputs: id (required), currency. Returns: id, usd, plan, turns, +15 more
sessionsARead-onlyIdempotent
Sessions in the window with what each cost, sorted by cost or by time, most expensive or most recent first. Includes sub-agent runs as their own rows.
Inputs: sort, limit, since, source, +2 more. Returns: plan, total, currency, sessions, +4 more
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 8 tools
Each tool targets a distinct granularity: report (window summary), sessions (per-session list), session (single session detail), agents (per-agent-type rollup), changes (model-change points), finding (single finding), prices, and refresh. The analytics tools (report/sessions/agents/changes) overlap in domain and an agent must parse descriptions carefully to pick the right level, but boundaries are stated clearly enough.
Seven tools are single lowercase nouns (finding, prices, agents, changes, session, report, sessions) with only refresh acting as a verb, so the set is mostly predictable despite lacking a verb_noun pattern. The session/sessions singular-plural pair is a minor readability risk but conventional.
Eight tools is well-scoped for a cost-tracking server: one data-refresh action, one price reference, and a small hierarchy of correctly-sized analytics views. No tool feels redundant or bolted on.
The read/analytics surface is thorough (window totals, session and sub-agent breakdowns, change verdicts, drill-down findings, price reference, manual rescan). Minor gaps exist: no tool to set or edit the price/override config that 'prices' reads from, and no keyword search across findings.
Maintenance
Related MCP Connectors
Exact Claude API cost calc with real cache economics, plus a tiktoken-misuse scanner.
Shared memory MCP server for Claude Code, Codex, Gemini CLI and Cursor. Cited, editable.
LLM cost optimization gateway, repo token-waste auditor & model arbitrage MCP server.
A paid remote MCP for OpenAI Codex agent coordination MCP, built to return verdicts, receipts, usage
Related MCP Servers
- AlicenseAqualityBmaintenanceLocal-first dashboard + MCP server that parses Claude Code and Codex JSONL files into a SQLite cost / token tracker. Per-MCP and per-tool breakdown, session drill-down, dedup by request_id; never talks to vendor APIs5104 npm1MIT
- AlicenseBqualityDmaintenanceTrack LLM token costs across Claude, GPT and Gemini. MCP server + CLI with optimization hints and $ savings estimates.813 npm1MIT
- AlicenseNot gradedqualityBmaintenanceEnables local-first tracking of AI token usage and costs from Claude Code and OpenCode, answering queries about tokens, models, sessions, and cost through MCP tools and a CLI, with no network calls.124 npm1MIT
- AlicenseAqualityBmaintenanceEnables analyzing coding-agent session transcripts to measure tool efficiency, detect loops, track test outcomes, and report costs, with MCP tools for listing sessions, analyzing sessions, finding loops, and generating cost reports.4MIT