Audits projects for LLM token waste, calculates model arbitrage opportunities, and optimizes prompt payloads for caching.
Also known as tokenzero-ai/tokenzero, mcp, @tokenzero/mcp
- Stars
- 0
- Tools
- —
- Downloads, 30 days
- —
- Latest version
- 0.3.0
- Last commit
- Nov 5, 2026
- License
- Apache-2.0
What is TokenZero MCP?
TokenZero audits projects for LLM token waste, calculates model arbitrage opportunities, and optimizes prompt payloads for caching.
Summary generated from the project's README
About TokenZero MCP server
Reducing AI expenditure by identifying inefficient prompt patterns is what TokenZero enables for developers using coding agents like Claude Code, Cursor, Windsurf, and Cline. This stdio MCP server runs locally on your machine to perform static audits of your codebase, looking for specific patterns like LLM calls inside loops or large static prompts that lack caching directives.
Users can utilize tools such as audit_repo_token_waste and calculate_model_arbitrage to find savings opportunities without uploading code. While most audits happen locally, the optimize_prompt_payload tool sends request bodies to the TokenZero service to improve cache friendliness, so users should avoid including secrets in those payloads. The system uses versioned pricing tables to estimate costs and can be integrated into CI/CD workflows via GitHub Actions to gate pull requests based on cost-diff checks. It helps teams transition from frontier models to more economical alternatives for simple tasks like extraction or classification.
What you can do with it
- 1Identify inefficient prompt patternsAsk the agent to scan your local repository to find where you are wasting tokens on unoptimized prompts.
- 2Find cheaper model alternativesRequest a comparison of model costs to see if a cheaper model can handle specific tasks like classification.
- 3Improve prompt caching efficiencyProvide a request body to the agent to make it more compatible with provider caching mechanisms.
- 4Prevent cost regressions in pull requestsSet up a workflow to automatically comment on pull requests if they introduce significant token waste.
Written from the project's README. Every use case is checked against a quote from it.
How to install TokenZero MCP
Formats verified 10 Nov 2026Install TokenZero MCP in Claude Code
$ claude mcp add --env TOKENZERO_KEY=<YOUR_TOKENZERO_KEY> mcp -- npx -y @tokenzero/mcpInstall TokenZero MCP in Cursor
~/.cursor/mcp.json
{
"mcpServers": {
"mcp": {
"command": "npx",
"args": [
"-y",
"@tokenzero/mcp"
],
"env": {
"TOKENZERO_KEY": "<YOUR_TOKENZERO_KEY>"
}
}
}
}Install TokenZero MCP in VS Code
.vscode/mcp.json
{
"servers": {
"mcp": {
"type": "stdio",
"command": "npx",
"args": [
"-y",
"@tokenzero/mcp"
],
"env": {
"TOKENZERO_KEY": "<YOUR_TOKENZERO_KEY>"
}
}
}
}Install TokenZero MCP in Claude Desktop
claude_desktop_config.json
{
"mcpServers": {
"mcp": {
"command": "npx",
"args": [
"-y",
"@tokenzero/mcp"
],
"env": {
"TOKENZERO_KEY": "<YOUR_TOKENZERO_KEY>"
}
}
}
}Install TokenZero MCP in Codex
~/.codex/config.toml
[mcp_servers.mcp] command = "npx" args = ["-y", "@tokenzero/mcp"] [mcp_servers.mcp.env] TOKENZERO_KEY = "<YOUR_TOKENZERO_KEY>"
Install TokenZero MCP in Gemini CLI
~/.gemini/settings.json
{
"mcpServers": {
"mcp": {
"command": "npx",
"args": [
"-y",
"@tokenzero/mcp"
],
"env": {
"TOKENZERO_KEY": "<YOUR_TOKENZERO_KEY>"
}
}
}
}Configuration
TOKENZERO_KEYSecretWorkspace key (tz_live_…) for workspace_metrics; optional
TOKENZERO_URLGateway base URL (default https://tokenzero.sh)
| Name | Description | |
|---|---|---|
| TOKENZERO_KEY | Workspace key (tz_live_…) for workspace_metrics; optional | Secret |
| TOKENZERO_URL | Gateway base URL (default https://tokenzero.sh) |
Automated checks
Ran Nov 14, 2026Full report →Passed our automated checks. That is not a security audit: read the code and give the server the narrowest access it needs. How checks work
- Source repository linked and reachabletokenzero-ai/tokenzero is public and reachablegithub.com/tokenzero-ai/tokenzero ↗Pass
- Package names this repository as its sourceNot checked
- Build provenance (Sigstore attestation)No build attestation published for this releaseNot checked
- Open source license (OSI)Apache-2.0spdx.org/licenses/Apache-2.0.html ↗Pass
- Commit or release in the last yearLast commit or release 2026-11-05github.com/tokenzero-ai/tokenzero ↗Pass
- OpenSSF ScorecardNot checked
- Package name not close to a popular packageNo popular package one edit away from @tokenzero/mcpPass
- No critical advisory in the package or its dependencies1 resolved dependencies checked; no critical advisoryosv.dev ↗Pass
- No hidden instructions to the model0 tool descriptions and the README read; no override phrases, credential paths or hidden charactersPass
- Destructive tools are labelledNot checked
- Remote endpoint answers the MCP handshakeinitialize answered with protocol 2025-06-18 in 618 msPass
README
View on GitHubTokenZero 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 indocs/receipt-spec.md. -
@tokenzero/mcpis 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/cliconnects 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
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
TokenZero MCP questions
How do I add TokenZero MCP to Claude Code?
Run claude mcp add --env TOKENZERO_KEY=<YOUR_TOKENZERO_KEY> mcp -- npx -y @tokenzero/mcp in your terminal. Add --scope user to make it available in every project.
How do I add TokenZero MCP to Cursor?
Open ~/.cursor/mcp.json and add the server under mcpServers, using the Cursor config shown in the install section above.
Does the MCP server upload my code?
The audit and arbitrage tools run entirely on your local machine.
Is my data safe when using the optimize tool?
The optimize_prompt_payload tool sends request bodies to the TokenZero service, so you should avoid including secrets in them.