TokenZero

sh.tokenzeroPublished by tokenzero.shOfficial publisherv0.3.0Updated Nov 5, 2026

Ledger of record for AI spend: verifiable receipts, waste auditor & model arbitrage MCP.

VerifiedStreamable HTTPWeb executableDeveloper ToolsData & AnalyticsAI & ML

Overview

AI-generated overview

TokenZero audits LLM token waste, prices model alternatives and makes request bodies cache-friendly, plus provisions a BYOK gateway workspace with signed…

What you can do
  • Audit a public GitHub repo or source files for token waste such as uncached static prompts, frontier models on extraction tasks and calls in loops
  • Rewrite an OpenAI or Anthropic request body so its static prefix is provider-cacheable and show the projected saving
  • Price a workload across models at list prices, including cheaper siblings and prompt-caching effects
  • Create a workspace and key, returning gateway base URLs and a dashboard link
  • Read a workspace's savings scorecard, ROI and per-model breakdown
  • Preview the four savings engines on a sample or your own prompt without a key
When to use it
Useful when you want to cut LLM API bills: checking a codebase or pull request for token waste, comparing model costs for a workload, or routing traffic through a caching gateway that issues verifiable savings receipts.
Requirements
Runs as a remote endpoint or as a local npm package via npx, so Node.js is needed for the stdio install. Most tools need no key; workspace_metrics needs a workspace key in TOKENZERO_KEY, and TOKENZERO_URL can override the gateway base URL. Network access is needed for the hosted tools.
Before you install
optimize_prompt_payload sends the request body you provide to the TokenZero service, so it should not contain secrets. Workspace keys are returned once and should be treated as secrets; keys embedded in base URLs are especially sensitive. Provider keys pass through the gateway, and audit figures are static estimates at list prices rather than measured savings.

Installation

In SourceWeft

  1. Open TokenZero in the dashboard and add it to a workspace.
  2. Enable the server for the chats that should use its tools.

Web executable via Streamable HTTP. Remote servers run from the web runtime once configured in a workspace.

Use with an agent

Paste this prompt into Claude Code, Codex, Cursor or another agent — or into SourceWeft chat. The agent reads this server's install guide, shows you its publisher, endpoint and sign-in, and adds it to your client once you agree. Keys never go into a command.

Read https://sourceweft.com/mcp/sh.tokenzero%2Fmcp/install.md and connect the MCP server it describes to my client. Before changing any config, show me its publisher, endpoint and sign-in method and wait for my OK. Never put an API key in a command or in a file I would commit; ask me where it should come from.

Read the install guide the agent follows

Other MCP clients

Add this to your client's mcpServers config.

{
  "mcpServers": {
    "tokenzero": {
      "type": "http",
      "url": "https://api.tokenzero.sh/mcp"
    }
  }
}

README

TokenZero tools

Open-source tools from TokenZero, the independent ledger of record for AI spend (metering, attribution, budget control, audit).

  • The receipt verifier (verifier/tokenzero-verify.mjs) checks a TokenZero receipt without trusting TokenZero: Ed25519 signature over canonical JSON, the savings-bucket math and the hash chain. Zero dependencies; library or CLI. The format is specified in docs/receipt-spec.md.

  • @tokenzero/mcp is a stdio MCP server for Claude Code, Cursor, Windsurf and Cline: audit the open project for token waste (locally), price model alternatives, make request bodies cache-friendly.

  • @tokenzero/cli connects a project to the ledger (through the gateway sensor) with no code changes, audits LLM token waste locally, shows usage and verifies signed savings receipts.

  • The analyzer (src/audit-core.ts) is the static token-waste audit used by the CLI, the hosted repo audit and the PR cost-diff check. It runs entirely on your machine.

  • The pricing table (src/pricing.ts) lists the list prices every estimate is computed from, versioned and dated.

Audit a project

sh
npx -y @tokenzero/cli audit            # local, nothing is uploadednpx -y @tokenzero/cli audit --jsonnpx -y @tokenzero/cli audit --fail-over 30   # CI gate: exit 1 above 30% recoverablegit diff origin/main | npx -y @tokenzero/cli audit --diff - --format markdown

Audits are static heuristics: they read code, not traffic. Numbers are estimates at list prices; verified savings come from the gateway's signed ledger once requests flow through it.

What it looks for:

  • large static prompts sent without caching directives (Anthropic cache_control, OpenAI prefix stability)
  • prompt templates defined away from their call sites with no caching anywhere
  • frontier models on prompts that read like extraction or classification
  • LLM calls inside loops (Batch API or shared-prefix caching candidates)
  • unpriced or retired model ids

Library and SDK repositories are detected and their findings downgraded, since their call sites pass through whatever the caller chooses.

Check every pull request (GitHub Action)

yaml
# .github/workflows/tokenzero.ymlname: TokenZero cost checkon: pull_requestpermissions: { contents: read, pull-requests: write }jobs:  cost-check:    runs-on: ubuntu-latest    steps:      - uses: actions/checkout@v4        with: { fetch-depth: 0 }      - uses: tokenzero-ai/tokenzero/action@v0

One comment per PR, updated on every push; nothing leaves the runner. See action/README.md for inputs and outputs.

Use it from a coding agent (MCP)

sh
claude mcp add tokenzero -- npx -y @tokenzero/mcp          # Claude Code
json
{ "mcpServers": { "tokenzero": { "command": "npx", "args": ["-y", "@tokenzero/mcp"] } } }

audit_repo_token_waste and calculate_model_arbitrage run entirely on your machine. optimize_prompt_payload sends the request body you give it to the TokenZero service (https://tokenzero.sh unless TOKENZERO_URL is set), so do not put secrets in it.

Connect a project to the gateway

sh
npx -y @tokenzero/cli init

init audits locally, creates a workspace, and (with your consent) adds OPENAI_BASE_URL / ANTHROPIC_BASE_URL to .env. Your provider keys pass through untouched and are never stored.

Authentication: send the workspace key as the X-TokenZero-Key header (recommended). For zero-code setups the CLI can also embed it in the base URL (/w/<key>/v1); treat such URLs as secrets and use tokenzero rotate-key if one leaks.

Develop

sh
npm installnpm run build      # bundles cli/bin/tokenzero.mjs (single file, no runtime deps)npm test

License: Apache-2.0 · [email protected]

Source: README.md at commit d0afe66

Tools

6

try_tokenzero

Try TokenZero (no key needed)

Call this first: no API key, no signup, no setup. Shows what TokenZero would do to one of your LLM calls: it runs the four savings engines (prompt-cache formatting, edge cache, cascade advice, signed receipt) on a sample or your own prompt and model, and returns the list-price saving, the signed receipt and a copy-paste keyless curl that makes a real call on a free model. Pass {} for the default, or {"model": "gpt-6.1-sol", "system": "...", "prompt": "..."}.

Parametersmodelpromptsystem

audit_repo_token_waste

Audit a repo for LLM token waste

No API key needed. Static-analyze a public GitHub repo (e.g. {"repo": "owner/name"}) or a set of source files for LLM token waste: uncached static prompts, frontier models on extraction tasks, hot loops, non-deterministic repeat calls, and prompt-caching mis-integration (caching gated on model names, volatile values in the system prompt, random ids in history, wrong-provider cache markers, misplaced breakpoints, cost math that ignores cached tokens). Returns findings with fixes and an estimated recoverable percentage.

Parametersrepofiles

optimize_prompt_payload

Make a request body cache-friendly

No API key needed. Rewrite an OpenAI Chat/Responses or Anthropic Messages request body so its static prefix is provider-cacheable (Anthropic cache_control breakpoints, OpenAI prompt_cache_key). Returns the optimized body, what changed, the token profile and the projected per-request saving. Never changes the tokens the model sees.

Parametersbodyrequiredendpointstrategy

calculate_model_arbitrage

Price a workload across models

No API key needed; only `model` is required (e.g. {"model": "gpt-6.1-sol"}, defaults 2,000 tokens in and 400 out). Price a workload at list prices across models: cost per request and per month for the requested model, its cheaper sibling, and the effect of prompt caching. The result names the pricing table version it used.

Parametersmodelrequiredcompare_toinput_tokensoutput_tokensstatic_tokensrequests_per_month

provision_workspace

Create a free TokenZero workspace

Create a TokenZero workspace and key with no form. Returns the key once, the base URLs that route through it (OPENAI_BASE_URL / ANTHROPIC_BASE_URL), the one-click dashboard link and the badge URL. Free up to the monthly free tier; nothing is billed.

Parametersname

workspace_metrics

Read a workspace savings scorecard

Live value scorecard for a TokenZero workspace: hard savings and net ROI per window, the four engines' contribution, speed, parity, availability and privacy posture, per-model breakdown and one-click recommendations. Needs the workspace key (tz_live_…); pass demo: true for a labelled sample.

Parameterskeydemowindow

Version history

8
  1. v0.3.0LatestNov 5, 2026
  2. v0.2.16Nov 4, 2026
  3. v0.2.15Nov 3, 2026
  4. v0.2.12Nov 1, 2026
  5. v0.2.11Nov 1, 2026
  6. v0.2.9Oct 30, 2026
  7. v0.2.5Oct 26, 2026
  8. v0.2.2Oct 26, 2026

Score

100% of the applicable checks met

How complete this listing is, computed from the registry entry, the endpoint and public sources. Not a rating of the server and not a statement that it is safe or working today: reachability is a dated check, and no installs or reviews go into the score.

  • Reached in the last 30 daysRequired25 pts
  • Auth declaredRequired10 pts
  • Tools listedRequired15 pts
  • DescriptionRequired15 pts
  • Logo10 pts
  • Documentation15 pts
  • License10 pts

Other Tokenzero integrations