ooples/token-optimizer-mcp
Intelligent token optimization for Claude Code - achieving 95%+ token reduction through caching, compression, and smart tool intelligence
What it solves
Large language model (LLM) context windows are limited and expensive. When agents read large files, long API responses, or repetitive data, they consume massive amounts of tokens, which can lead to high costs and reduced reasoning capacity. This project provides a way to manage that data more efficiently.
How it works
This is a local Model Context Protocol (MCP) server that acts as an intermediary between an AI client (like Claude Code, Cursor, or Codex) and your local data. It uses several techniques to minimize token usage:
- Caching: Stores large payloads locally (using SQLite) and returns compact references instead of full text.
- Diffing: Instead of re-reading an entire file after an edit, it returns only the changes (diffs).
- Compression: Uses Brotli compression for storage and provides token-aware decisions on whether to compress or skip.
- Filtering: Strips noisy command output to keep only relevant information.
Who it’s for
It is designed for developers using MCP-compatible AI agents and CLI tools (such as Claude Code, GitHub Copilot CLI, Gemini CLI, Codex, and OpenCode) who want to optimize their context window usage and reduce token costs.
Highlights
- Provides 74 specialized tools for optimizing text, files, Git operations, and APIs
- Features built-in token-savings reports to track optimization performance
- Operates entirely locally with no hosted service required for core functions
- Supports smart file operations like
smart_readandsmart_editto minimize context bloat