← Back to directory
T

Token Optimizer MCP

Community
Compression that optimises your bill, not your byte count — and ships the benchmark so you can check it.
Category
Dev Tools #60 of 438
Stars
★ 564 Very popular
Transport
stdio (local process)
Runtime
Node.js 22+
Credentials
No credential needed
License
MIT
Last commit
Tools
11
64FMRS · C

Token Optimizer MCP is an unusually large scope project and a rare self-verifying one: it does not merely claim token savings, it ships the benchmark scripts, the losses, the excluded data and the unfinished studies alongside the wins. Its core value is twofold — compressing tool results and smart-reading files before they reach the model, and a local knowledge graph that fills itself in from real agent traffic. Against typical alternatives it is explicit about separating direct, materialized savings from causal graph evidence, and it renders an unmeasurable saving as unknown rather than zero.

What deserves caution: the many comparisons against the competitor HeadRoom are offline estimates using this repository's own reimplementation of their published design, not their shipped binary, and the author repeatedly states that superiority was not established and that several studies are incomplete. The graph's causal benefit remains Collecting. It also actively refuses tool calls and writes elided payloads to local spill files, both of which have real workflow and security implications. Best suited to developers willing to accept a more invasive integration and able to run the benchmarks themselves.

Strongest · Documentation 16/20 Weakest · Security and permissions 9/20

Reliability
12/20
Security and permissions
9/20
Maintenance
14/20
Documentation
16/20
Setup experience
13/20
Why each score
Reliability 12/20
Static review sees only the README and server.json; no CI workflow files, committed test sources, or reproducible execution evidence for key paths are present in the supplied material. The README self-claims 2,437 tests, 253 client-config checks, a verify:all suite and benchmark scripts (bench/compression/proof.mjs, session-replay.mjs) plus very specific figures (119/120 passes, 0.926x median cost), but all of this is untrusted evidence from the artifact itself with no third-party verification, so per the calibration note reliability cannot exceed 12. The README is also internally contradictory: one section states TOKEN_OPTIMIZER_PROXY defaults off (switch table) while another says the proxy is enabled by default; harvest is described both as 'not opt-in'/default-on and as credential-gated. Such contradictions directly weaken confidence that declared tools match real behavior. Deducted for: no verifiable CI/test evidence, contradictory default-value statements, and error/edge-case handling presented only as prose.
Security and permissions 9/20
Notable but sub-red-line risk. Positives: the manifest exposes only one optional non-secret env var with no embedded credentials; the README states no telemetry, no hosted service, MIT license, forwards rather than stores the provider key, and mentions npm provenance, CHECKSUMS.sha256, and exact uninstall of only self-written files. Risks: installation writes persistent host changes (shell activation, User PATH, owned .cmd launchers, merging into settings.json), a broad privilege footprint; the local proxy writes elided tool-result content in plaintext to OS temp spill files (0600, HMAC salted names, removed on shutdown) and the README itself concedes this may include sensitive conversation content it does not scan for secrets; optional TOKEN_OPTIMIZER_PROXY_CAPTURE writes plaintext request bodies to a named directory; the knowledge graph and harvest may send content to local/remote model endpoints. These are documented, switchable and scoped, and no credential theft, covert exfiltration, or unconfirmed destructive default is evident, so no red line applies, but the enabled-by-default proxy, plaintext spill/capture, and host mutation cap the score. Deducted for: default local proxy with possible plaintext spill files, install-time PATH/shell/settings persistence, and opt-in plaintext request capture.
Maintenance 14/20
Repository metadata supports active maintenance: version 7.0.1, an npm package @ooples/token-optimizer-mcp published in sync, a clear MIT license, 531 stars, only 5 open issues, and not archived. The README references a CI workflow badge, commit hashes (e.g. f712b4ec) and dated evidence directories, indicating sustained iteration, versioned evidence and a defined release path. However the repo description appears inflated/inconsistent with actual function (claiming 'live local knowledge graph across 16 CLI clients' while the core is compression/optimization), the manifest description (60-90% reduction) is in tension with the README's repeated admissions that superiority is not established, the credential-gated harvest and causal evidence remain 'Collecting' (unfinished capability), and unverifiable model names like 'gpt-6-astra' appear. No explicit security-response channel is described. Deducted for: capability/description inconsistencies, partly in-progress features, and no independent governance info, while the release and license path is clear, giving a solid mid-high score.
Documentation 16/20
Documentation is unusually thorough and well above average: install steps (Claude Code plugin, Codex plugin/mcp add, one-line npx), verification commands (npx token-optimizer-doctor feeds a synthetic payload and asserts a large read is refused), diagnostics commands, troubleshooting, links to TOKEN_ACCOUNTING and EVIDENCE_PROTOCOL, a client capability tiering (lifecycle/native/rules), cost and cache-multiplier explanations, and extensive self-declared limitations ('superiority not established', 'not claimed that embedding beats BM25', 'replay does not establish reasoning survives compression'). That proactive disclosure is a plus. Deductions: internal contradictions (proxy default on/off, inconsistent harvest gating), some numbers are enormous and unverifiable statically, a few implausible model names, and marketing-style comparison tables mixed through long prose. Scored in the 'layered docs with examples and disclosed limitations but hidden assumptions/contradictions' band.
Setup experience 13/20
The install path is generally clear: a one-line npx stdio launch for mainstream clients, a plugin-marketplace install for Claude Code, two Codex routes (plugin and mcp add), and 16 generated client configs under integrations/. However complexity is high: the README states that installing only the MCP server just gives ignorable tools, and real effect requires additional native plugins/hook bundles per client, possibly /reload-plugins and a terminal reopen to load PATH, with npm 11 blocking lifecycle scripts unless allow-scripts is enabled. Several CLI-subcommand installs (codex plugin add, /plugin install) cannot be verified in static source, and Windows adds .cmd shims and PowerShell execution-policy considerations. Per the static calibration cap of 15, and given multi-step native integration and lifecycle dependency, it is scored 13. Deducted for: MCP-only install being insufficient, extra plugin/hook and terminal reload steps, and platform/lifecycle-script friction.

Static review · not runListed 2026-09-18

Read the FMRS scoring method →

Fit and risk

What it can accessReads local filesWrites / deletes local filesUses the network

Best for

  • Long, multi-turn coding agent sessions
  • Developers using several CLI clients at once
  • Teams that need local-only operation, no telemetry, and a commercially usable license
  • Teams that want to verify compression claims with a reproducible benchmark rather than vendor assertions

Not for

  • Anyone who wants a bare MCP server without installing client hooks or plugins (the README states adding the server alone does not enforce anything)
  • Scenarios where no request content may ever be written to local disk (the proxy writes elided payloads to spill files in the OS temp directory)
  • Users who need a hosted service or cloud account
  • Environments that cannot run Node.js 22+

Required permissions

  • Read and write project files for smart reads, diffs and edits
  • Install and run client lifecycle hooks that intercept or re-route tool calls before execution
  • Write cache, knowledge graph, logs and elided-content spill files to local disk
  • Optionally start a compression proxy process bound to the local loopback address
  • Read native CLI usage receipts for token accounting and pricing

Risks and side effects

  • The server refuses or rewrites built-in tool calls (Read, Grep, Glob, Edit, Write, and shell cat/head/grep -r), which in enforce mode can interrupt existing workflows
  • Recoverable elided content is written with 0600 permissions under token-optimizer-spill/ in the OS temp directory and is not deleted while the proxy runs; a kill signal or power loss leaves the directory behind to be cleaned up by hand
  • The proxy does not inspect written content for secrets, so a secret in your conversation can reach a spill file like any other text
  • The local knowledge graph and cache hold project structure, content hashes and derived findings
  • Several comparisons in the README are development-stage or incomplete studies; the project itself states that superiority was not established and that aggregate intervals still span 1.0

Setup

Before you start

Runtime:Node.js 22+

Other optional settings (13)
TOKEN_OPTIMIZER_CACHE_DIR optional Directory path for cache storage; optional, defaults to ~/.token-optimizer-mcp.
TOKEN_OPTIMIZER_MODE optional Controls behavior: off disables optimization/enforcement, enforce vetoes expensive built-in calls; default is assist.
TOKEN_OPTIMIZER_PROXY optional Set to 0 to disable the compression proxy routing.
TOKEN_OPTIMIZER_COMPRESSION optional Compression preset: balanced, aggressive, conservative, or lossless; default balanced.
TOKEN_OPTIMIZER_PROXY_KNOWLEDGE optional Set to 0 to disable injecting project knowledge into the cached prefix.
TOKEN_OPTIMIZER_HARVEST optional Set to 0 to turn off model-based semantic harvest; with no credential it reports off:no-key.
TOKEN_OPTIMIZER_HARVEST_ENDPOINT optional Point at a local model endpoint so semantic harvest runs free and private on-machine.
TOKEN_OPTIMIZER_MANAGED_CLIENTS optional Set to 0 before installation to skip shell activation and managed client commands.
TOKEN_OPTIMIZER_PROXY_CAPTURE optional Opt-in request-body capture writing plaintext request content to the named directory.
TOKEN_OPTIMIZER_LOG_DIR optional Log directory; defaults to ~/.token-optimizer/logs or .token-optimizer/logs when a state directory is set.
TOKEN_OPTIMIZER_LOG_MAX_BYTES optional Per-file log rotation size cap; default 5 MiB.
TOKEN_OPTIMIZER_LOG_MAX_FILES optional Maximum number of retained log files; default 40.
TOKEN_OPTIMIZER_LOG_RETENTION_DAYS optional Log retention period in days; default 14.

Claude Code: run /plugin marketplace add ooples/token-optimizer-mcp, then /plugin install token-optimizer@token-optimizer, then /reload-plugins.

MCP server only (any client): npx -y @ooples/token-optimizer-mcp@latest. Optionally set TOKEN_OPTIMIZER_CACHE_DIR to choose the cache directory; it defaults to ~/.token-optimizer-mcp.

Codex: codex plugin marketplace add ooples/token-optimizer-mcp, then codex plugin add token-optimizer@token-optimizer; or codex mcp add token-optimizer -- npx -y @ooples/token-optimizer-mcp@latest.

After installing, verify the hooks actually work with npx token-optimizer-doctor — it feeds a synthetic payload to the real hook binary and asserts a large read is refused and a small one is not. Ready-made config for all sixteen clients lives in the repository's integrations/ directory.

.mcp.json
{
  "mcpServers": {
    "token-optimizer": {
      "command": "npx",
      "args": ["-y", "@ooples/token-optimizer-mcp@latest"],
      "env": {
        "TOKEN_OPTIMIZER_CACHE_DIR": "/path/to/cache"
      }
    }
  }
}

Shown for Claude Code. Other clients may use a different file or key (VS Code uses "servers") — the configurator below converts it.

.vscode/mcp.json
{
  "servers": {
    "token-optimizer": {
      "command": "npx",
      "args": [
        "-y",
        "@ooples/token-optimizer-mcp@latest"
      ],
      "env": {
        "TOKEN_OPTIMIZER_CACHE_DIR": "/path/to/cache"
      }
    }
  }
}

Goes in your project's .vscode/mcp.json (VS Code uses a "servers" key).

Terminal
claude mcp add token-optimizer -e TOKEN_OPTIMIZER_CACHE_DIR=/path/to/cache -- npx -y @ooples/token-optimizer-mcp@latest

Run it in a terminal; replace any <…> placeholders with your own values first.

Check that it works

Check that the token-optimizer tools (e.g. smart_read, token_audit) appear in your client's tool list, then run npx token-optimizer-doctor to confirm the hooks actually refuse a large read and the server answers; issuing a token_audit request that returns results also proves the connection works.

Troubleshooting

  1. If nothing seems to be happening, the lifecycle bundle is probably not installed: an MCP server process cannot modify the host, and npm 11 gates lifecycle scripts behind allow-scripts, so install the plugin or hook bundle for your client
  2. Run npx token-optimizer-doctor; it feeds a synthetic payload to the real hook binary and asserts a large read is refused
  3. If the proxy fails to start after enabling it, check the port and loopback binding, and confirm Node.js is version 22 or newer
  4. A harvest state of off:no-key means no model credential is configured; point TOKEN_OPTIMIZER_HARVEST_ENDPOINT at a local model to run it offline — npx token-optimizer-doctor reports which mode is live
  5. To inspect hook health, run npm run diagnostics with optional --hours and --output; raw event rows are opt-in, capped at 1,000
  6. To disable enforcement temporarily set TOKEN_OPTIMIZER_MODE=off; to disable proxy routing set TOKEN_OPTIMIZER_PROXY=0

Things to try

Once connected, you can ask your AI assistant things like:

  • Use smart_read to read just the relevant part of src/auth.ts instead of the whole file
  • Run token_audit and show me which operations cost the most tokens this session and how to fix them
  • Use wiki_read to recall what previous sessions concluded about the auth module before I re-derive it
  • Use smart_grep to find database connection pool handling in the codebase

Tools 11

smart_read read-only
Read a file and return compressed or diffed content, avoiding a repeat read of an unchanged file.
smart_grep read-only
Run a search and return compressed matches, keeping rows that depart from the expected shape.
smart_glob read-only
Find files by pattern and return the result in a reduced form.
smart_edit writes
Edit a file in an optimized way that cuts redundant context.
expand read-only
Expand previously elided content from a content-addressed store; it never re-runs the original command.
wiki_write writes
Let the active model record a durable conclusion (finding, decision or dead end) into the project knowledge graph.
wiki_read read-only
Read what the project or the files about to be touched already know.
wiki_query read-only
Query the graph directly: one finding by key, a ranked BM25 search over claims, a node with its neighbours, or the graph's own audit.
Show 3 more tools
token_audit read-only
Return a ranked queue of what is costing the most per session, with how to fix each line.
waste_audit read-only
Turn a detected waste into a durable, measured, reversible fix such as a skip rule.
fleet_audit read-only
Rank every project on the machine by measured cost and transfer a proven fix across projects by content hash.

Use cases

Cut tokens spent re-reading unchanged files in a coding agent session
Compress tool results, search output, logs and build output before they reach the model
Carry findings, decisions and dead ends across agent sessions
Attribute token spend by client and action to find the most expensive project
Reuse a proven optimization fix across several local projects

Supported clients

Claude Code
Codex
GitHub Copilot CLI
Gemini CLI
Qwen Code
Cursor
Cline
OpenCode
Kilo
Windsurf
Roo CodePartial support
ZedPartial support
AmpPartial support
ContinuePartial support
CrushPartial support
DroidPartial support

Listed from the project's documentation, not tested by this site.

Overview

Token Optimizer MCP is a locally running MCP server that optimizes the context window of AI coding agents. Through caching, compression and smart file tools, it reduces token spend before tool results reach the model; the README claims a 60–90% cut.

It also maintains a cross-session local knowledge graph: nodes for files, symbols, tasks and findings, joined by edges such as derived_from, contains, supersedes, contradicts and related. Findings, decisions and dead ends accumulate as a side effect of working, then feed back the moment the agent touches a relevant file, so conclusions are not re-derived. Data stays local — no account, no telemetry, no hosted service.

The server speaks stdio and ships as the npm package @ooples/token-optimizer-mcp under the MIT license, which permits commercial use. The README documents 16 clients and separates an enforcing tier (10 clients with a pre-execution hook that can refuse a wasteful built-in call) from a rules tier (6 clients where optimized routing is mandatory via rules but cannot be vetoed). Benchmarks ship in the repository and can be regenerated, e.g. with node bench/compression/proof.mjs.

Similar servers

Context7 80 · B

Upstash's official server providing up-to-date third-party library docs for AI coding assistants

★ 64.1k · Tools 2 Compare with this →

Source revision d474b6a060b3 Data synced 2026-11-02 Read the FMRS scoring method