token-optimization-mcp
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@token-optimization-mcpEstimate tokens for 'Explain quantum computing in simple terms.'"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
token-optimization-mcp v0.2.0
Production-ready Model Context Protocol server for token counting, prompt compression, model routing and semantic caching. Zero external API calls — works fully offline.
Tools
Tool | Description |
| Count tokens for any text+model (calibrated chars/token ratios) |
| Shrink prompts with |
| Pick cheapest model meeting quality + context requirements |
| Semantic cache hit/miss by prompt or pre-computed key |
| Store prompt+result with token-savings metadata |
| Remove one or all cache entries |
| Conversation health: role breakdown, issues, recommendations |
| Session-level token/USD savings dashboard |
| Remove duplicate turns, count saved tokens |
Related MCP server: claw-tsaver
Quick Start
cd mcps/token-optimization-mcp
uv sync
# stdio – Claude Code / Copilot
uv run main.py
# SSE – LangGraph / CrewAI / browser
uv run main.py --sse --port 8001Environment Variables
Variable | Default | Description |
|
| Enable Redis backend |
|
| Redis connection URL |
|
| Default cache TTL (1 day) |
|
| Requests/min per client |
|
| Print audit log to stdout |
Registration
Claude Code (~/.claude/settings.json)
{
"mcpServers": {
"token-optimization": {
"command": "uv",
"args": ["run", "/path/to/token-optimization-mcp/main.py"]
}
}
}VS Code Copilot (.vscode/mcp.json)
{
"servers": {
"token-optimization": {
"type": "stdio",
"command": "uv",
"args": ["run", "${workspaceFolder}/mcps/token-optimization-mcp/main.py"]
}
}
}SSE (LangGraph / CrewAI / Cursor)
http://127.0.0.1:8001/sseSupported Models (routing catalogue)
Model | Context | Quality | Cost/1k |
| 128k | 8 | free |
| 128k | 7 | $0.00015 |
| 200k | 7 | $0.00025 |
| 1M | 6 | $0.000075 |
| 128k | 9 | $0.005 |
| 200k | 9 | $0.003 |
| 200k | 10 | $0.015 |
Testing
uv run --group test pytest
# 118 tests, 100% coverageArchitecture
token-optimization-mcp/
├── main.py ← FastMCP server (9 tools)
├── pyproject.toml
├── README.md
├── tests/
│ ├── conftest.py ← state-reset fixtures
│ ├── test_helpers.py ← unit tests + Hypothesis
│ └── test_tools.py ← integration tests per tool
└── mcp-servers/
└── context-cache-server/ ← standalone Redis-backed sub-server
├── server.py
├── config.py
└── security.pyMaintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/DCx7C5/token-optimization-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server