Mibayy/token-savior

MCP server that gets Claude to 97.9% (188/192) on a real coding benchmark at -80% active tokens and -83% wall time, vs 78.3% plain. Structural code navigation + persistent memory engine. Works with every MCP client.

What it solves

Token Savior is designed to reduce the massive token consumption and context window bloat common in AI coding agents (like Claude Code). It addresses three main problems: the tendency of agents to read entire files for small pieces of information, the loss of session memory across restarts, and the noise of verbose Bash output that consumes turn budgets.

How it works

The project operates as a Model Context Protocol (MCP) server that provides several layers of optimization:

  • Structural Navigation: Instead of reading whole files, it indexes the codebase by symbols (functions, classes, imports, and call graphs), allowing the agent to navigate via pointers.
  • Persistent Memory: It uses a combination of SQLite (WAL + FTS5) and vector embeddings to store decisions, bugfixes, and conventions, re-injecting them as compact deltas in new sessions.
  • Bash Optimization:
    • PreToolUse Rewriter: Edits Bash commands before they run to produce smaller, more efficient output that reaches the model.
    • PostToolUse Compactors: Applies 34 different pure-function compactors (for git, docker, kubectl, etc.) to render tool output in a token-efficient way. While these don't shrink the current turn, they preserve full output in a "capture sandbox" so it survives context compaction.
  • Profiles: It offers different tool manifests (e.g., optimized, tiny, full) to control how many tools are exposed to the model, further reducing manifest tokens.

Who it’s for

It is primarily for developers using AI coding agents (such as Claude Code, Cursor, Gemini, or Codex) who want to lower their token costs, speed up agent response times, and maintain persistent memory across coding sessions.

Highlights

  • Significant Token Reduction: Reported 80% reduction in active tokens per task on the tsbench benchmark.
  • Symbol-based Indexing: Replaces cat and grep chains with direct symbol lookups.
  • PreToolUse Rewriting: Actively modifies commands to prevent token bloat before it occurs.
  • Persistent Memory Engine: Uses Bayesian validity and ROI ranking to manage long-term project knowledge.
  • Broad Tool Support: Includes 34 specialized compactors for common CLI tools like git, gh, pytest, and aws-cli.

Related

  • Project
  • Project
  • Project
  • Dispatch
  • Project