TokenZero — Claude Code MCP server: what it does, install
TokenZero scans code for wasted LLM tokens, compares model pricing, and reshapes request payloads for caching. Use it from a coding agent or CI.
Apache-2.0 updated 2026-10-28
claude mcp add --transport http mcp https://api.tokenzero.sh/mcpWhat TokenZero does
TokenZero gives a coding agent tools for inspecting LLM spend patterns. audit_repo_token_waste reads the local project and flags large uncached prompts, detached templates, model choices that do not fit simple extraction or classification work, looped LLM calls, and model IDs without current pricing. calculate_model_arbitrage compares model options, while optimize_prompt_payload sends a supplied request body to the service for adjustment.
The audit is static: it examines source code rather than request traffic, so its cost figures are estimates based on listed prices. The analyzer stays on the machine and can process a diff or fail CI after a chosen recoverable-cost threshold. The MCP package runs through npx; the CLI can also initialize a project and add provider base URLs to .env after consent.
optimize_prompt_payload sends its input to https://tokenzero.sh unless TOKENZERO_URL changes the destination. Keep secrets out of that payload. Provider keys pass through the gateway without being stored.
What it helps with
- spot prompts that lack caching directives
- compare alternative model prices
- check the cost impact of a pull request
- find LLM calls placed inside loops
- prepare a request body for caching
Example prompts for the agent
- Run
audit_repo_token_wasteon this repository and list the token-waste findings. - Use
calculate_model_arbitrageto compare models for this request. - Send this non-secret body to
optimize_prompt_payloadand make it more cache-friendly.
How to install TokenZero
1Platform CLI: remote server
claude mcp add --transport http mcp https://api.tokenzero.sh/mcp2Platform CLI
claude mcp add --env TOKENZERO_URL=<TOKENZERO_URL> --env TOKENZERO_KEY=<TOKENZERO_KEY> --transport stdio tokenzero -- npx -y @tokenzero/mcpReplace <…> with your own values
1Platform CLI: remote server
codex mcp add tokenzero --url https://api.tokenzero.sh/mcp2Platform CLI
codex mcp add tokenzero --env TOKENZERO_URL=<TOKENZERO_URL> --env TOKENZERO_KEY=<TOKENZERO_KEY> -- npx -y @tokenzero/mcpReplace <…> with your own values
Config file
{
"mcpServers": {
"tokenzero": {
"url": "https://api.tokenzero.sh/mcp"
}
}
}{
"mcpServers": {
"tokenzero": {
"command": "npx",
"args": [
"-y",
"@tokenzero/mcp"
],
"env": {
"TOKENZERO_URL": "<TOKENZERO_URL>",
"TOKENZERO_KEY": "<TOKENZERO_KEY>"
}
}
}
}Replace <…> with your own values
Config file
{
"servers": {
"tokenzero": {
"type": "http",
"url": "https://api.tokenzero.sh/mcp"
}
}
}{
"servers": {
"tokenzero": {
"type": "stdio",
"command": "npx",
"args": [
"-y",
"@tokenzero/mcp"
],
"env": {
"TOKENZERO_URL": "<TOKENZERO_URL>",
"TOKENZERO_KEY": "<TOKENZERO_KEY>"
}
}
}
}Replace <…> with your own values
1Platform CLI: remote server
gemini mcp add -t http tokenzero https://api.tokenzero.sh/mcp2Platform CLI
gemini mcp add -e TOKENZERO_URL=<TOKENZERO_URL> -e TOKENZERO_KEY=<TOKENZERO_KEY> tokenzero npx -y @tokenzero/mcpReplace <…> with your own values
Step by step, with commands for each platform: How to add an MCP server to Claude Code, Codex, Cursor, VS Code, Gemini CLI and more
Questions about TokenZero
How do I install TokenZero in Claude Code?
Run claude mcp add --transport http tokenzero https://api.tokenzero.sh/mcp.
What does TokenZero do?
It gives coding agents a local project audit, model price comparisons, and request-payload preparation for caching. Its CLI also supports project setup, usage checks, and signed savings receipt verification.
Does TokenZero send the repository or secrets to its service?
The repository audit and model comparison run locally. The body supplied to optimize_prompt_payload goes to https://tokenzero.sh, so secrets should stay out of that input.