Token Diet
Runs Gradle build, test, and lint commands for projects with build.gradle, compacts the log using Gradle error markers, and supports dry-run command previews.
Runs MSBuild or dotnet build for .NET projects, selects the toolchain from the project style, keeps the full build log, and returns errors plus warnings grouped by code.
Runs npm build, test, and lint commands for projects with package.json, compacts the output using npm error markers, and can show the command without executing it.
Runs pnpm build, test, and lint commands for projects with package.json, compacts the output using npm-style error markers, and supports dry-run command previews.
Runs pytest test commands for projects with pyproject.toml or pytest.ini, compacts the log using pytest error markers, and supports dry-run command previews.
Runs Yarn build, test, and lint commands for projects with package.json, compacts the output using npm-style error markers, and supports dry-run command previews.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Token Dietoutline OrderService.cs so I can find the method I need"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Zero Token
Universal token firewall & compact-context optimizer for AI coding agents (Google Antigravity 2.0 & ZCode).
Stops an AI coding session from flooding its own context window with whole-file reads, unbounded grep/rg, and raw multi-megabyte build logs — without lossy history truncation or rewriting tool outputs.
Tiếng Việt · MIT · Node 18+
before Read / read_file OrderService.cs (136 KB) ~38,700 tokens
after outline OrderService.cs ~1,470 tokens
read_file StartLine=412 EndLine=452 (or Read offset=412 limit=40)Why
An AI coding session pays for every single character a tool returns, and pays repeatedly on every subsequent turn because the transcript retains it. The most expensive calls are predictable:
Opening a 3,000-line file just to inspect one method;
Running an unconstrained recursive search that returns 9,000 matches;
Dumping a build log with 1,800 warning lines, where only 3 error codes matter.
None of these need model judgement to fix — they need a strict, automated cap at the gateway. That is what Zero Token enforces.
Related MCP server: ctxkit
Measured Results
Token estimates use 3.6 chars/token for code and 4 chars/token for logs. Rows marked real were measured on actual enterprise solutions; the rest use synthetic fixtures sized like standard enterprise files.
Scenario | Before | After | Saved |
Read one large C# file (whole file) | 38,749 | 1,761 | 95.5% |
Find one symbol across the repo ( | 9,218 | 1,698 | 81.6% |
Read a warning-heavy build log | 55,783 | 461 | 99.2% |
real 59-project .NET Framework solution via MSBuild | 27,258 | 2,104 | 92.3% |
real SDK-style solution via | 1,624 | 1,493 | 8.1% |
The last row is the honest floor: when the build already runs with -v:q and fails early, there is little to compress. The plugin earns its keep on large files, repo-wide searches, and warning-heavy builds.
Its own permanent overhead is only about 780 tokens per session (5 MCP tool schemas ≈ 626, skill and agent descriptions ≈ 154). One blocked 38k-token read pays for months of usage.
See bench/RESULTS.md for the generated benchmark report.
Platform Support
Zero Token natively supports both Google Antigravity 2.0 and ZCode through a unified adapter layer:
Platform | Hook Integration | Tools Covered | Interface & Surfaces |
Google Antigravity 2.0 |
|
| Skills, MCP Server, always-on |
ZCode |
|
| Skills, Commands, Agents, MCP Apps Webview Panel |
Components
Component | Behaviour |
Universal Guard ( | Intercepts oversized reads ( |
Loop Breaker ( | Warns once when the agent repeats the exact same tool call with identical arguments 3 times. |
MCP Tool | Extracts type and method signatures with line numbers across 16+ programming languages. Replaces blind whole-file reads. |
MCP Tool | Literal or |
MCP Tool | Runs MSBuild or |
MCP Tool | Build/test/lint for npm/pnpm/yarn, cargo, go, maven, gradle, make, and pytest with per-ecosystem error extraction. |
MCP Tool | Analyzes token cost of all installed skills and MCP schemas in the environment. |
Savings Ledger ( | Logs every blocked call and saved byte into a local rotating JSONL ledger ( |
MCP App Panel ( | Real-time webview dashboard visualizing tokens kept out of context, blocked calls, and recent interventions. |
Installation
Option 1: Fast Universal Install (PowerShell)
Clone the repository and run the installer script:
git clone https://github.com/kzxl/zero-token.git
cd zero-token
./install.ps1The script automatically sets up NTFS Junctions pointing to plugins/zero-token for both environments:
Antigravity 2.0:
~/.gemini/config/plugins/zero-tokenZCode:
~/.zcode/plugins/zero-token
Option 2: ZCode Plugin Marketplace
In ZCode:
/plugin marketplace add kzxl/zero-token
/plugin install zero-token@zero-tokenOr navigate to Plugin Marketplace → + → Add Plugin Marketplace, paste kzxl/zero-token, then install Zero Token.
Option 3: Antigravity 2.0 Manual MCP Registration
If you prefer registering Zero Token strictly as an MCP server in Antigravity:
Add to ~/.gemini/config/mcp_config.json:
{
"mcpServers": {
"zero-token": {
"command": "node",
"args": [
"C:/Users/<Username>/source/repos/zero-token/plugins/zero-token/scripts/mcp-server.mjs"
],
"env": {
"ZERO_TOKEN_WORKSPACE": "C:/path/to/your/workspace"
}
}
}
}Language Support
Layer | Coverage |
Guard | Any language. Evaluates file sizes, byte offsets, line ranges, and shell commands. |
| Any text file. Skips binaries/NUL bytes, handles UTF-16LE/BE (with/without BOM), respects |
| Heuristic symbol extraction for C, C++, C#, Java, Kotlin, JS, TS, Python, Ruby, PHP, Go, Rust, Swift, Scala, Dart, Shell, Lua, Perl, and SQL. |
| .NET solutions (legacy MSBuild or modern SDK |
| npm, pnpm, yarn, cargo, go, maven, gradle, make, and pytest. |
Configuration
Zero Token supports a 3-tier configuration hierarchy:
Repository Overrides:
<repo>/.zero-token.json(highest priority)User Global Overrides:
~/.zero-token/config.json(or path inZERO_TOKEN_CONFIG)Plugin Defaults:
plugins/zero-token/scripts/config.json
Key | Default | Meaning |
|
| Master switch for the PreToolUse guard. |
|
| Files above this (128 KB) are blocked without line/byte constraints. |
|
| Suggested line count in deny messages. |
|
| Reads requesting >400 lines on large files are treated as full reads and blocked. |
|
| Size cap for files viewed via |
|
| Block |
|
| Block |
|
| Block |
|
| Detect repetitive identical tool calls. |
|
| Number of identical calls before triggering a warning. |
|
| Honour |
|
| In-memory file cache TTL (ms). |
|
| LRU cache budget for decoded files (32 MB). |
|
| Command execution timeout for |
Savings Ledger & Real-Time Dashboard
Every blocked call, preserved token count, and MCP execution is recorded in:
~/.zero-token/ledger.jsonl(customizable viaZERO_TOKEN_DATA).
To inspect savings:
In chat: Run
/zero-token statusor/saved [days]for a concise summary.In ZCode / MCP App hosts: Open
ui://zero-token/panel.htmlin the sidebar for live metrics, visual gauges, and zero-token consumption.
Benchmarks & Verification
Run the test suite locally:
npm test # Full test suite: guard, languages, build parser, gitignore, runner, panel
npm run smoke # MCP protocol handshake and tool verification
npm run bench # Synthetic scenario benchmark (writes bench/RESULTS.md)
node bench/repo-bench.mjs # Benchmark against real multi-language repositories
node bench/hook-bench.mjs # Measure hook spawn overhead and ledger append latencyHook latency on Windows is ~70 ms per guarded call (Node process spawn overhead); ledger appends take only 0.35 ms. A typical session with 50 tool calls incurs ~3.5 seconds of total hook latency while saving tens of thousands of tokens.
Safety & Security
Zero Token runs entirely locally. Nothing leaves your machine.
The guard denies dangerous calls; it never auto-approves permissions. Your host environment's permission boundaries remain in full control.
MCP tools are read-only inspection tools, except
buildandrunwhich execute existing local build scripts with bounded timeouts.
License
MIT © kzxl
This server cannot be deployed
Maintenance
Related MCP Connectors
Find, vet, and run MCP tools through a secure audited gateway with prompt-injection risk scoring
Your org's AI agents, tasks, runs, search, and brain files as MCP tools and resources.
LLM cost optimization gateway, repo token-waste auditor & model arbitrage MCP server.
LLM cost optimization gateway, repo token-waste auditor & model arbitrage MCP server.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceProvides MCP tools for common developer operations like file outlining, git commit context, test summary, process management, and waiting for conditions, returning structured JSON to reduce token usage.MIT
- AlicenseNot gradedqualityAmaintenanceEnables AI coding agents to retrieve repository context through stdio-based MCP tools, including ranked repo maps, context packs, and live symbol search.3 npmMIT
- AlicenseNot gradedqualityAmaintenanceEnables MCP-compatible developer environments to shrink verbose tool outputs—test logs, git diffs, directory listings, and file dumps—before they reach the context window, preserving compiler errors, failure signatures, and decisive anchors. It runs either as direct callable tools or as a transparent proxy wrapping other MCP servers such as filesystem, git, or terminal providers.1MIT
- AlicenseBqualityAmaintenanceEnables AI coding agents and local LLMs to store and recall project memory, compact verbose logs, look up code symbols, create and rewind workspace snapshots, detect risky commands and loops, pack context optimally, and draft tokens through MCP tools.102Apache 2.0