Context Optimizer MCP
@degenhero
About Context Optimizer MCP
An MCP server that uses Redis and in-memory caching to optimize and extend context windows for large chat histories
Config
Add this server to your MCP-compatible client using the configuration below.
{
"mcpServers": {
"context-optimizer-mcp": {
"command": "npx",
"args": [
"mcp",
"install",
"degenhero/context-optimizer-mcp"
]
}
}
}Tools
No tools detected
Fetch the live tool list by running this server in a temporary sandbox using the button above.
Overview
What is Context Optimizer MCP?
Context Optimizer MCP is an MCP server that uses Redis and in-memory caching to optimize and extend context windows for large chat histories. It acts as a middleware between your application and LLM providers (currently supporting Anthropic's Claude models), automatically summarizing older messages to stay within token limits while preserving key information.
How to use Context Optimizer MCP?
Install using the MCP client (npx mcp install degenhero/context-optimizer-mcp), manually via npm install, or with Docker (docker-compose up -d). Configure environment variables in .env (Anthropic API key, Redis host/port, caching settings). Start the server, then send HTTP POST requests to http://localhost:3000/v1/messages using the standard Anthropic API format, optionally including conversation_id and context_optimization parameters.
Key features of Context Optimizer MCP
- Dual-layer caching: in-memory LRU and persistent Redis
- Automatic context summarization when nearing token limit
- Rate limiting with burst protection
- Drop-in replacement for Anthropic API
- Built-in performance monitoring and metrics collection
- Conversation continuity via unique
conversation_id
Use cases of Context Optimizer MCP
- Extending context for long-running chatbot sessions
- Managing large conversation histories within token limits
- Reducing API costs by caching summarized contexts
- Maintaining context across multiple API calls for complex interactions
FAQ from Context Optimizer MCP
What are the prerequisites?
Node.js 18+, a Redis server (local or remote), and an Anthropic API key.
How do I configure it?
Copy .env.example to .env and set ANTHROPIC_API_KEY, Redis host/port/password, and caching parameters (e.g., IN_MEMORY_CACHE_MAX_SIZE). The server listens on port 3000 by default.
Does it support other LLM providers?
Currently, only Anthropic's Claude models are supported.
What transport does it use?
The server exposes an HTTP endpoint at /v1/messages that is compatible with the Anthropic API. It also provides /health and /metrics endpoints.
Where are conversation histories stored?
Summarized contexts are cached in both an in-memory LRU cache (for fast access) and Redis (for persistent, distributed storage across server instances).
Frequently asked questions
What are the prerequisites?
Node.js 18+, a Redis server (local or remote), and an Anthropic API key.
How do I configure it?
Copy `.env.example` to `.env` and set `ANTHROPIC_API_KEY`, Redis host/port/password, and caching parameters (e.g., `IN_MEMORY_CACHE_MAX_SIZE`). The server listens on port 3000 by default.
Does it support other LLM providers?
Currently, only Anthropic's Claude models are supported.
What transport does it use?
The server exposes an HTTP endpoint at `/v1/messages` that is compatible with the Anthropic API. It also provides `/health` and `/metrics` endpoints.
Where are conversation histories stored?
Summarized contexts are cached in both an in-memory LRU cache (for fast access) and Redis (for persistent, distributed storage across server instances).
Basic information
More Other MCP servers
Maestro
mobile-dev-incPainless E2E Automation for Mobile and Web
MCP Go 🚀
mark3labsA Go implementation of the Model Context Protocol (MCP), enabling seamless integration between LLM applications and external data sources and tools.
🚀 Model Context Protocol (MCP) Curriculum for Beginners
microsoftThis open-source curriculum introduces the fundamentals of Model Context Protocol (MCP) through real-world, cross-language examples in .NET, Java, TypeScript, JavaScript, Rust and Python. Designed for developers, it focuses on practical techniques for building modular, scalable,
MCP Toolbox for Databases
googleapisMCP Toolbox for Databases is an open source MCP server for databases.
Nginx UI
0xJackyYet another WebUI for Nginx
Comments