
Product
Microsoft Teams Notifications Are Now Available in Socket
Socket can now send alerts and supply chain attack notifications to Microsoft Teams, with filters that route the right updates to each channel.
token-optimizer-mcp
Advanced tools
Intelligent context window optimization for Claude Code - store content externally via caching and compression, freeing up your context window for what matters
Intelligent token optimization through caching and compression for Claude Code and Claude Desktop
Token Optimizer MCP is a Model Context Protocol (MCP) server that reduces context window usage through intelligent caching and compression. By storing compressed content externally in SQLite, the server removes tokens from your context window while keeping them accessible. The server provides tools to compress text, cache results, and analyze token usage - helping you maximize your available context window.
The automated installer detects and configures token-optimizer-mcp for:
No manual configuration needed - the installer automatically detects which tools you have installed and configures them all!
Install the MCP server and global hooks in one command:
# Download and run the automated installer
irm https://raw.githubusercontent.com/ooples/token-optimizer-mcp/main/install-hooks.ps1 | iex
# Download and run the automated installer
curl -fsSL https://raw.githubusercontent.com/ooples/token-optimizer-mcp/main/install-hooks.sh | bash
This will:
Token Reduction: 60-90% average across all operations on all supported AI tools!
For detailed platform-specific installation instructions, see HOOKS-INSTALLATION.md.
All Platforms:
# 1. Install the MCP server
npm install -g @ooples/token-optimizer-mcp
# 2. Run the installer script for your platform
Windows:
cd "$env:APPDATA\npm\node_modules\@ooples\token-optimizer-mcp"
.\install-hooks.ps1
macOS / Linux:
NPM_PREFIX=$(npm config get prefix)
cd "$NPM_PREFIX/lib/node_modules/@ooples/token-optimizer-mcp"
bash install-hooks.sh
See HOOKS-INSTALLATION.md for complete instructions including:
When global hooks are installed, token-optimizer-mcp runs automatically on every tool call:
┌─────────────────────────────────────────────────────────────┐
│ Phase 1: PreToolUse - Tool Replacement │
│ ├─ Read → smart_read (60-90% token reduction) │
│ ├─ Grep → smart_grep (60-90% token reduction) │
│ └─ Glob → smart_glob (60-90% token reduction) │
└─────────────────────────────────────────────────────────────┘
↓
┌─────────────────────────────────────────────────────────────┐
│ Phase 2: Input Validation - Cache Lookups │
│ └─ get_cached checks if operation was already done │
└─────────────────────────────────────────────────────────────┘
↓
┌─────────────────────────────────────────────────────────────┐
│ Phase 3: PostToolUse - Output Optimization │
│ ├─ optimize_text for large outputs │
│ └─ compress_text for repeated content │
└─────────────────────────────────────────────────────────────┘
↓
┌─────────────────────────────────────────────────────────────┐
│ Phase 4: Session Tracking │
│ └─ Log all operations to operations-{sessionId}.csv │
└─────────────────────────────────────────────────────────────┘
↓
┌─────────────────────────────────────────────────────────────┐
│ Phase 5: UserPromptSubmit - Prompt Optimization │
│ └─ Optimize user prompts before sending to API │
└─────────────────────────────────────────────────────────────┘
↓
┌─────────────────────────────────────────────────────────────┐
│ Phase 6: PreCompact - Pre-Compaction Optimization │
│ └─ Optimize before Claude Code compacts the conversation │
└─────────────────────────────────────────────────────────────┘
↓
┌─────────────────────────────────────────────────────────────┐
│ Phase 7: Metrics & Reporting │
│ └─ Track token reduction metrics and generate reports │
└─────────────────────────────────────────────────────────────┘
Result: Every Read, Grep, Glob, Edit, Bash operation is automatically optimized for token efficiency!
Based on 38,000+ operations:
| Tool | Avg Before | Avg After | Reduction |
|---|---|---|---|
| Read | 5,000 tokens | 1,850 tokens | 63% |
| Grep | 2,000 tokens | 740 tokens | 63% |
| Glob | 1,500 tokens | 555 tokens | 63% |
| Edit | 3,500 tokens | 1,295 tokens | 63% |
Per-Session Savings: 300K-700K tokens (worth $0.90-$2.10 at $3/M tokens)
// Use the optimize_text tool to cache content externally
optimize_text({
text: "Your large text content here...",
key: "my-cache-key",
quality: 11 // 0-11, higher = better compression
})
// Result - compressed data is stored in SQLite, NOT returned in context
{
"success": true,
"key": "my-cache-key",
"originalTokens": 1500,
"compressedTokens": 450, // Tokens IF it were in context (not relevant)
"tokensSaved": 1050, // Context window savings (what matters)
"percentSaved": 70.5, // Based on compression + external storage
"originalSize": 6000,
"compressedSize": 1800, // Stored in SQLite
"cached": true
}
// Your context window now contains only the cache key (~50 tokens)
// instead of the original 1500 tokens - 96.7% reduction in context usage!
// Use the get_cached tool
get_cached({ key: "my-cache-key" })
// Result:
{
"success": true,
"key": "my-cache-key",
"text": "Your original text content...",
"fromCache": true
}
// Use the count_tokens tool
count_tokens({ text: "Your text here" })
// Result:
{
"tokens": 150,
"characters": 500
}
// Use the analyze_optimization tool
analyze_optimization({ text: "Your text here" })
// Result:
{
"tokens": {
"current": 1500,
"afterCompression": 450,
"saved": 1050,
"percentSaved": 70
},
"size": {
"current": 6000,
"compressed": 1800,
"ratio": 3.33,
"percentSaved": 70
},
"recommendations": {
"shouldCompress": true,
"reason": "Compression will provide significant token savings"
}
}
// Use the get_cache_stats tool
get_cache_stats({})
// Result:
{
"totalEntries": 15,
"totalSize": 45000,
"hits": 42,
"misses": 8,
"hitRate": 84.0,
"avgCompressionRatio": 3.2,
"totalTokensSaved": 12500
}
It's important to understand the difference between compression ratio and context window savings:
When you cache content using this MCP server:
Example: A 10,000 token API response is cached:
When you compress text without caching (using compress_text), the compressed data must be encoded as Base64 to be transmitted as text:
optimize_text which caches the compressed data externallyHigh Value Use Cases:
Lower Value Use Cases:
Original Text (10,000 tokens)
↓
Brotli Compress (82x ratio)
↓
Store in SQLite (~122 bytes)
↓
Return Cache Key (~50 tokens)
↓
RESULT: 9,950 tokens removed from context window
The key insight: The value is in external storage, not compression alone. Even with modest compression ratios, moving data out of your context window provides massive savings.
# Build the project
npm run build
# Run in development mode (watch)
npm run dev
# Run tests (when implemented)
npm test
# Run benchmarks (when implemented)
npm run benchmark
ISC
Built for optimal Claude Code token efficiency.
FAQs
Intelligent context window optimization for Claude Code - store content externally via caching and compression, freeing up your context window for what matters
The npm package token-optimizer-mcp receives a total of 192 weekly downloads. As such, token-optimizer-mcp popularity was classified as not popular.
We found that token-optimizer-mcp demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.

Product
Socket can now send alerts and supply chain attack notifications to Microsoft Teams, with filters that route the right updates to each channel.

Security News
pnpm 12 rewrites the package manager in Rust, cutting install times by up to 90% while preserving pnpm 11 workflows and lockfiles.

Security News
Socket CTO Ahmad Nassri joins AppSec leaders at Black Hat to discuss active malware, package manager risks, and software supply chain defense.