# ReToken > ReToken is an MIT-licensed Rust proxy and local Model Context Protocol (MCP) server for coding agents. It can compress tool output and align Anthropic prompt-cache breakpoints in Claude Code. Its stdio tool, `retoken_retrieve`, reads omitted lines from the local machine. Codex CLI can use the retrieval tool and proxy. ReToken currently passes Codex Responses traffic through unchanged. Website: https://ashleyimmanuel.github.io/ReToken/ Repository: https://github.com/AshleyImmanuel/ReToken License: MIT Language: Rust Maintainer: Immanuel Ashley (https://github.com/AshleyImmanuel) ## What problem does ReToken solve? Coding agents can send old tool results back to a provider across many turns. ReToken targets that repeated input. Savings depend on the workload and the provider’s cache. ## Measured results - Headless Claude Code benchmark (Claude Sonnet, November 2026, 3 tasks x 3 repeats per setup, all 36 runs correct): direct API $0.0425 per task, caveman proxy $0.0330, ReToken $0.0329, ReToken + terse mode $0.0302 (29% below direct, 3.78 turns against 4.78). ## How it works 1. Exact duplicate tool output is replaced by a reference to the earlier copy (lossless, always on). 2. Large build, test and log output is shortened; errors, assertion details and test summaries are always kept. 3. A file read reaches the model in full on the turn it is read; once stale, large files become an outline with exact line numbers. 4. Pretty-printed JSON from commands is minified without changing its value. 5. Anthropic prompt-cache breakpoints are placed to match the client's TTL, so repeated history is billed at the cached rate. 6. Optional terse mode asks the model for short prose replies; code and tool inputs stay normal. ## Common questions - How do I use ReToken in Codex? Register the installed binary with `codex mcp add retoken -- retoken mcp` and start a new session. Use `retoken exec -- cargo test` to shorten long test output, or `retoken wrap codex` to route Codex CLI requests through the proxy. - What does the MCP tool return? Copy a `ccr:` handle from a marker to retrieve the original, search for a case-insensitive substring, or read an inclusive 1-based line range. A nonempty search spans the whole original. Oversized results carry a truncation notice. A missing or expired handle returns a tool error. - How do I reduce Claude Code token usage? Run Claude Code through ReToken: `cargo install --path cli`, `claude mcp add retoken -- retoken mcp`, then `retoken wrap claude`. - Does ReToken work with a Claude Pro or Max subscription? Yes. It forwards the client's own authorization headers, including Claude Code OAuth. - Does ReToken send my code to a third party? No. It listens on loopback only and forwards requests only to the provider the agent already uses. - Is it safe for agent quality? Lossy changes happen only when the agent has the retrieval tool, and fresh file reads are never shortened. - How is it different from prompt plugins that make the model terse? Those shorten replies only. ReToken also cuts input (tool output, duplicates, cache placement) and includes a terse mode. ## Docs - [README](https://github.com/AshleyImmanuel/ReToken/blob/main/README.md): overview, quick start, results, FAQ, CLI commands - [AI_INSTALL.md](https://github.com/AshleyImmanuel/ReToken/blob/main/AI_INSTALL.md): step-by-step setup an AI agent can follow, every setting, undo steps - [ARCHITECTURE.md](https://github.com/AshleyImmanuel/ReToken/blob/main/ARCHITECTURE.md): crate layout and request flow - [CONTRIBUTING.md](https://github.com/AshleyImmanuel/ReToken/blob/main/CONTRIBUTING.md): how to build, test and open a pull request - [Releases](https://github.com/AshleyImmanuel/ReToken/releases/latest): binaries and checksums - [Benchmarks](https://github.com/AshleyImmanuel/ReToken/tree/main/benchmarks): reproducible short-task harness - [Glama](https://glama.ai/mcp/servers/AshleyImmanuel/ReToken): published MCP tool schema and evaluation - [Official MCP Registry](https://registry.modelcontextprotocol.io/v0.1/servers/io.github.AshleyImmanuel%2FReToken/versions/latest): verified package identifier, download URL and checksum