Memory Cache Server
A Model Context Protocol (MCP) server that efficiently caches data to reduce token consumption in language model interactions, improving performance for repeated operations.
Store Data: Cache data with a unique key and optional time-to-live (TTL)
Retrieve Data: Fetch cached data using its key
Clear Cache: Remove specific entries or clear the entire cache
Get Cache Stats: Access statistics to monitor cache effectiveness and usage
Automatic Caching: Automatically cache frequently accessed data and computation results
Custom Configuration: Configure cache size, memory limits, TTL, and cleanup intervals
Seamless Integration: Works with any MCP client and language model, requiring minimal setup
Click on "Deploy 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., "@Memory Cache Server cache the results of my last data analysis"
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.
Memory Cache Server
A Model Context Protocol (MCP) server that reduces token consumption by efficiently caching data between language model interactions. Works with any MCP client and any language model that uses tokens.
Installation
Installing via Smithery
To install Memory Cache Server for Claude Desktop automatically via Smithery:
npx -y @smithery/cli install @tosin2013/mcp-memory-cache-server --client claudeInstalling Manually
Clone the repository:
git clone https://github.com/tosin2013/mcp-memory-cache-server.git
cd mcp-memory-cache-serverInstall dependencies:
npm installBuild the project:
npm run buildAdd to your MCP client settings:
{
"mcpServers": {
"memory-cache": {
"command": "node",
"args": ["/path/to/ib-mcp-cache-server/build/index.js"]
}
}
}The server will automatically start when you use your MCP client
Related MCP server: Claude Continuity MCP Server
Verifying It Works
When the server is running properly, you'll see:
A message in the terminal: "Memory Cache MCP server running on stdio"
Improved performance when accessing the same data multiple times
No action required from you - the caching happens automatically
You can verify the server is running by:
Opening your MCP client
Looking for any error messages in the terminal where you started the server
Performing operations that would benefit from caching (like reading the same file multiple times)
Configuration
The server can be configured through config.json or environment variables:
{
"maxEntries": 1000, // Maximum number of items in cache
"maxMemory": 104857600, // Maximum memory usage in bytes (100MB)
"defaultTTL": 3600, // Default time-to-live in seconds (1 hour)
"checkInterval": 60000, // Cleanup interval in milliseconds (1 minute)
"statsInterval": 30000 // Stats update interval in milliseconds (30 seconds)
}Configuration Settings Explained
maxEntries (default: 1000)
Maximum number of items that can be stored in cache
Prevents cache from growing indefinitely
When exceeded, oldest unused items are removed first
maxMemory (default: 100MB)
Maximum memory usage in bytes
Prevents excessive memory consumption
When exceeded, least recently used items are removed
defaultTTL (default: 1 hour)
How long items stay in cache by default
Items are automatically removed after this time
Prevents stale data from consuming memory
checkInterval (default: 1 minute)
How often the server checks for expired items
Lower values keep memory usage more accurate
Higher values reduce CPU usage
statsInterval (default: 30 seconds)
How often cache statistics are updated
Affects accuracy of hit/miss rates
Helps monitor cache effectiveness
How It Reduces Token Consumption
The memory cache server reduces token consumption by automatically storing data that would otherwise need to be re-sent between you and the language model. You don't need to do anything special - the caching happens automatically when you interact with any language model through your MCP client.
Here are some examples of what gets cached:
1. File Content Caching
When reading a file multiple times:
First time: Full file content is read and cached
Subsequent times: Content is retrieved from cache instead of re-reading the file
Result: Fewer tokens used for repeated file operations
2. Computation Results
When performing calculations or analysis:
First time: Full computation is performed and results are cached
Subsequent times: Results are retrieved from cache if the input is the same
Result: Fewer tokens used for repeated computations
3. Frequently Accessed Data
When the same data is needed multiple times:
First time: Data is processed and cached
Subsequent times: Data is retrieved from cache until TTL expires
Result: Fewer tokens used for accessing the same information
Automatic Cache Management
The server automatically manages the caching process by:
Storing data when first encountered
Serving cached data when available
Removing old/unused data based on settings
Tracking effectiveness through statistics
Optimization Tips
1. Set Appropriate TTLs
Shorter for frequently changing data
Longer for static content
2. Adjust Memory Limits
Higher for more caching (more token savings)
Lower if memory usage is a concern
3. Monitor Cache Stats
High hit rate = good token savings
Low hit rate = adjust TTL or limits
Environment Variable Configuration
You can override config.json settings using environment variables in your MCP settings:
{
"mcpServers": {
"memory-cache": {
"command": "node",
"args": ["/path/to/build/index.js"],
"env": {
"MAX_ENTRIES": "5000",
"MAX_MEMORY": "209715200", // 200MB
"DEFAULT_TTL": "7200", // 2 hours
"CHECK_INTERVAL": "120000", // 2 minutes
"STATS_INTERVAL": "60000" // 1 minute
}
}
}
}You can also specify a custom config file location:
{
"env": {
"CONFIG_PATH": "/path/to/your/config.json"
}
}The server will:
Look for config.json in its directory
Apply any environment variable overrides
Use default values if neither is specified
Testing the Cache in Practice
To see the cache in action, try these scenarios:
File Reading Test
Read and analyze a large file
Ask the same question about the file again
The second response should be faster as the file content is cached
Data Analysis Test
Perform analysis on some data
Request the same analysis again
The second analysis should use cached results
Project Navigation Test
Explore a project's structure
Query the same files/directories again
Directory listings and file contents will be served from cache
The cache is working when you notice:
Faster responses for repeated operations
Consistent answers about unchanged content
No need to re-read files that haven't changed
Available Tools
4 toolsclear_cacheC
Clear specific or all cache entries
Inputs: key.
get_cache_statsC
Get cache statistics
Inputs: no named parameters.
retrieve_dataC
Retrieve data from the cache
Inputs: key (required).
store_dataC
Store data in the cache with optional TTL
Inputs: key (required), value (required), ttl.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 4 tools
Each tool has a clearly distinct purpose: clear_cache removes entries, get_cache_stats provides metrics, retrieve_data fetches data, and store_data saves data. There is no overlap or ambiguity between these operations.
Three tools use verb_noun naming (clear_cache, get_cache_stats, retrieve_data), which is consistent, but store_data uses a verb_noun pattern that slightly deviates from the others in verb choice. Overall, the naming is mostly predictable and readable.
With 4 tools, this server is well-scoped for a memory cache domain. Each tool serves a clear, essential function (store, retrieve, clear, stats), and no tool feels redundant or missing for basic cache operations.
The toolset covers core cache operations: store, retrieve, clear, and stats. A minor gap is the lack of an update or delete specific entry tool, but agents can work around this by clearing and re-storing. The surface supports basic workflows effectively.
Maintenance
Related MCP Connectors
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
LLM cost optimization gateway, repo token-waste auditor & model arbitrage MCP server.
An MCP memory server. One memory your agents share — across models, devices and apps.
A Model Context Protocol server for Wix AI tools
Related MCP Servers
- FlicenseBqualityDmaintenanceA Model Context Protocol server that reduces token consumption by efficiently caching data between language model interactions, automatically storing and retrieving information to minimize redundant token usage.425-
- AlicenseNot gradedqualityDmaintenanceA Model Context Protocol server that provides persistent memory and conversation continuity for Claude Desktop and Claude Code, allowing users to save and restore project context when threads hit token limits.MIT
- AlicenseAqualityDmaintenanceAn MCP server that helps AI agents reduce token usage by compressing, summarizing, and managing conversation/context data more efficiently.11MIT
- AlicenseNot gradedqualityDmaintenanceA Model Context Protocol server providing pre-curated canonical memory, prose/code provenance checking, and benchmark metrics to improve accuracy and reduce costs across AI tools.AGPL 3.0