TokenZero

io.github.tokenzero-aiPublished by GitHub account tokenzero-aiv0.2.2Updated Oct 26, 2026

LLM cost optimization gateway, repo token-waste auditor & model arbitrage MCP server.

The publisher's own server: TokenZero

VerifiedStreamable HTTPWeb executableDeveloper ToolsData & AnalyticsAI & ML

Overview

AI-generated overview

TokenZero audits code for LLM token waste, rewrites request bodies for prompt caching, prices model alternatives and reports workspace savings.

What you can do
  • Audit a public GitHub repo or a set of source files for token waste, with findings, fixes and an estimated recoverable percentage
  • Rewrite an OpenAI or Anthropic request body so its static prefix becomes provider-cacheable, returning the new body, the changes and projected savings
  • Price a workload across models at list prices, including a cheaper sibling and the effect of prompt caching
  • Create a TokenZero workspace and key, and read a live savings and ROI scorecard for a workspace
When to use it
Useful when you are paying LLM API bills and want an assistant to spot wasteful prompt patterns, make requests cache-friendly, compare model costs, or check a workspace's measured savings.
Requirements
Remote MCP endpoint at tokenzero.sh, or the npm package @tokenzero/mcp run locally with npx. No account is needed for the audit, arbitrage and prompt-optimization tools; workspace_metrics needs a workspace key (tz_live_…) and accepts demo: true for sample data. The gateway itself is bring-your-own-key.
Before you install
optimize_prompt_payload sends the request body you provide to the TokenZero service, so secrets must not be included. Workspace keys are credentials; the README warns that keys embedded in base URLs should be treated as secrets and rotated if leaked. Audit figures are static estimates at list prices, not measured traffic savings. Creating a workspace is free up to the monthly free tier.

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/io.github.tokenzero-ai%2Ftokenzero/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://tokenzero.sh/mcp"
    }
  }
}

README

TokenZero tools

Open-source tools from TokenZero, the bring-your-own-key gateway that cuts OpenAI, Anthropic and Gemini bills.

  • @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 gateway 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 52982eb

Tools

5

audit_repo_token_waste

Static-analyze a public GitHub 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. Returns findings with fixes and an estimated recoverable percentage.

Parametersrepofiles

optimize_prompt_payload

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 at list prices across models: cost per request and per month for the requested model, its cheaper sibling, and the effect of prompt caching. Pricing table version 2026-10-26.

Parametersmodelrequiredcompare_toinput_tokensrequiredoutput_tokensrequiredstatic_tokensrequests_per_month

provision_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

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

1
  1. v0.2.2LatestOct 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