token-optimization-mcp
Server Configuration
Describes the environment variables required to run the server.
| Name | Required | Description | Default |
|---|---|---|---|
| REDIS_URL | No | Redis connection URL | redis://localhost:6379/1 |
| USE_REDIS | No | Enable Redis backend | false |
| AUDIT_LOG_ENABLED | No | Print audit log to stdout | true |
| CACHE_TTL_SECONDS | No | Default cache TTL (1 day) | 86400 |
| RATE_LIMIT_PER_MIN | No | Requests/min per client | 120 |
Instructions
Guidance the server publishes about itself, which clients place ahead of the tool catalog so the model reads it before choosing anything.
This server publishes no instructions, or was last inspected before Glama recorded them.
Capabilities
Features and capabilities supported by this server
Protocol revision2025-11-25
| Capability | Details |
|---|---|
| tools | {
"listChanged": true
} |
| logging | {} |
| prompts | {
"listChanged": false
} |
| resources | {
"subscribe": false,
"listChanged": false
} |
| extensions | {
"io.modelcontextprotocol/ui": {}
} |
| experimental | {} |
Tools
Functions exposed to the LLM to take actions
| Name | Description |
|---|---|
| estimate_tokensA | Estimate token count for a text string. Uses calibrated chars/token ratios per model. Example: estimate_tokens(text='Hello world', model='gpt-4o') → {tokens: 2, ...} |
| compress_promptB | Compress a prompt to reduce token usage. strategy: 'trim' (whitespace/blanks), 'summarize_hint' (mark long sections), 'aggressive' (strip comments, examples, filler). Returns compressed text + savings stats. |
| route_modelA | Recommend the cheapest capable model for a task. Filter by min_quality (1-10, default 7) and max_cost_per_1k USD. Returns ranked candidates with per-call cost estimate. |
| cache_lookupA | Look up a cached result by prompt text or pre-computed cache key. Returns {hit: true, result, tokens_saved} or {hit: false}. |
| cache_storeA | Store a prompt+result in the cache. Provide prompt (auto-hashed), result text, tokens_saved estimate, optional TTL override and metadata dict. |
| cache_invalidateA | Invalidate one or all cache entries. Pass cache_key to remove one entry, or flush_all=true to wipe everything. |
| analyze_contextA | Analyze a list of chat messages ({role, content}) for token usage and issues. Detects bloated system prompts, near-full context windows, and repeated content. Returns per-role breakdown, issues list, and recommendations. |
| savings_reportB | Token savings dashboard for the current session. Shows cache hits, tokens saved, and estimated USD savings per client. |
| deduplicate_messagesB | Remove duplicate messages from a conversation (keeps last occurrence). Returns deduplicated list + tokens saved. |
Prompts
Interactive templates invoked by user choice
| Name | Description |
|---|---|
No prompts | |
Resources
Contextual data attached and managed by the client
| Name | Description |
|---|---|
No resources | |
TDQS
Scored across 9 tools
Each tool targets a distinct operation: caching (store/lookup/invalidate), compression, deduplication, analysis, estimation, model routing, and reporting. No two tools overlap in purpose.
All tool names follow a consistent verb_noun pattern in snake_case (e.g., cache_store, compress_prompt, route_model), making them predictable and easy to differentiate.
With 9 tools, the server covers the core aspects of token optimization without being excessive. Each tool serves a clear need within the domain.
The tool set covers analysis, caching, compression, deduplication, estimation, routing, and reporting. The only minor gap is the lack of a cache listing tool, but the core workflow is complete.