TokenZero

Official registry Security

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

What can you do with TokenZero?

  • @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.

Install

Add this to your client's MCP configuration (Claude Desktop: claude_desktop_config.json; Cursor: .cursor/mcp.json; VS Code and others use the same "mcpServers" shape).

Remote (streamable-http)
Claude Code
claude mcp add --transport http tokenzero 'https://api.tokenzero.sh/mcp'
JSON configuration (Claude Desktop, Cursor, VS Code)
{
    "mcpServers": {
        "tokenzero": {
            "type": "http",
            "url": "https://api.tokenzero.sh/mcp"
        }
    }
}
NPM package @tokenzero/mcp
Claude Code
claude mcp add tokenzero -e 'TOKENZERO_URL=<TOKENZERO_URL>' -e 'TOKENZERO_KEY=<your tokenzero_key>' -- npx -y @tokenzero/mcp@0.2.7
JSON configuration (Claude Desktop, Cursor, VS Code)
{
    "mcpServers": {
        "tokenzero": {
            "command": "npx",
            "args": [
                "-y",
                "@tokenzero/mcp@0.2.7"
            ],
            "env": {
                "TOKENZERO_URL": "<TOKENZERO_URL>",
                "TOKENZERO_KEY": "<your tokenzero_key>"
            }
        }
    }
}

Environment variables

  • TOKENZERO_URL Gateway base URL (default https://tokenzero.sh)
  • TOKENZERO_KEY secret Workspace key (tz_live_…) for workspace_metrics; optional

Documentation

From the project's README on GitHub, refreshed weekly. Links open on GitHub.

Contents
  1. TokenZero tools
  2. Audit a project
  3. Check every pull request (GitHub Action)
  4. Use it from a coding agent (MCP)
  5. Connect a project to the gateway
  6. Develop

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

npx -y @tokenzero/cli audit            # local, nothing is uploaded
npx -y @tokenzero/cli audit --json
npx -y @tokenzero/cli audit --fail-over 30   # CI gate: exit 1 above 30% recoverable
git 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)

# .github/workflows/tokenzero.yml
name: TokenZero cost check
on: pull_request
permissions: { 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)

claude mcp add tokenzero -- npx -y @tokenzero/mcp          # Claude Code
{ "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

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

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

License: Apache-2.0 · support@tokenzero.sh

Frequently asked questions

What is TokenZero?

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

How do I install TokenZero?

It runs as a remote server. In Claude Code: claude mcp add --transport http tokenzero 'https://api.tokenzero.sh/mcp'. For other clients, paste the JSON configuration from this page into their MCP settings.

Does TokenZero need an API key?

Yes. It expects TOKENZERO_KEY, which you set in its configuration.

Is TokenZero open source?

Yes. Its code is on GitHub under the Apache-2.0 license.

Who maintains TokenZero?

It is published by tokenzero-ai. AI.tn lists it but does not maintain or endorse it.

From the official MCP Registry. Listing is not an endorsement: review a server's code and permissions before giving it access to your data.