# Add to your Claude Code skills
git clone https://github.com/ooples/token-optimizer-mcp
README.md
Token Optimizer MCP
Intelligent token optimization through caching, compression, and smart tooling for Claude Code and Claude Desktop
Overview
Token Optimizer MCP is a Model Context Protocol (MCP) server that reduces context window usage by 60-90% through intelligent caching, compression, and smart tool replacements. By storing compressed content externally in SQLite and providing optimized alternatives to standard tools, the server helps you maximize your available context window.
Production Results: 60-90% token reduction across 38,000+ operations in real-world usage.
Key Features
Smart Tool Replacements: Automatic optimization for Read, Grep, Glob, and more
Context Window Optimization: Store content externally to free up context space
High Compression: Brotli compression (2-4x typical, up to 82x for repetitive content)
Persistent Caching: SQLite-based cache that persists across sessions
Accurate Token Counting: Uses tiktoken for precise token measurements
61 Specialized Tools: File operations, API caching, database optimization, monitoring, and more
Zero External Dependencies: Completely offline operation
Production Ready: Built with TypeScript for reliability
optimize_text - Compress and cache text (primary tool for token reduction)
get_cached - Retrieve previously cached text
compress_text - Compress text using Brotli
decompress_text - Decompress Brotli-compressed text
count_tokens - Count tokens using tiktoken (GPT-4 tokenizer)
analyze_optimization - Analyze text and get optimization recommendations
get_cache_stats - View cache hit rates and compression ratios
clear_cache - Clear all cached data
Usage Example:
// Cache large content to remove it from context window
optimize_text({
text: "Large API response or file content...",
key: "api-response-key",
quality: 11
})
// Result: 60-90% token reduction
Smart File Operations (10 tools)
Optimized replacements for standard file tools with intelligent caching and diff-based updates:
smart_read - Read files with 80% token reduction through caching and diffs
smart_write - Write files with verification and change tracking
smart_edit - Line-based file editing with diff-only output (90% reduction)
smart_grep - Search file contents with match-only output (80% reduction)
smart_glob - File pattern matching with path-only results (75% reduction)
smart_diff - Git diffs with diff-only output (85% reduction)
smart_branch - Git branch listing with structured JSON (60% reduction)
smart_log - Git commit history with smart filtering (75% reduction)
smart_merge - Git merge management with conflict analysis (80% reduction)
smart_status - Git status with status-only output (70% reduction)
Usage Example:
// Read a file with automatic caching
smart_read({ path: "/path/to/file.ts" })
// First read: full content
// Subsequent reads: only diff (80% reduction)
API & Database Operations (10 tools)
Intelligent caching and optimization for external data sources:
smart_api_fetch - HTTP requests with caching and retry logic (83% reduction on cache hits)
smart_cache_api - API response caching with TTL/ETag/event-based strategies
smart_database - Database queries with connection pooling and caching (83% reduction)
smart_sql - SQL query analysis with optimization suggestions (83% reduction)
smart_schema - Database schema analysis with intelligent caching
smart_graphql - GraphQL query optimization with complexity analysis (83% reduction)
smart_rest - REST API analysis with endpoint discovery (83% reduction)
smart_orm - ORM query optimization with N+1 detection (83% reduction)
The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.
A Claude Code plugin that automatically captures everything Claude does during your coding sessions, compresses it with AI (using Claude's agent-sdk), and injects relevant context back into future sessions.