The Memory Cache Server is a Model Context Protocol (MCP) server designed to reduce token consumption by efficiently caching data between language model interactions. It works with any MCP client and language model that uses tokens, optimizing your interactions by storing previously retrieved information.
To install Memory Cache Server automatically via Smithery:
npx -y @smithery/cli install @tosin2013/mcp-memory-cache-server --client claude
git clone https://github.com/tosin2013/mcp-memory-cache-server.git
cd mcp-memory-cache-server
npm install
npm run build
{
"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.
When the server is running properly, you'll see:
You can verify the server is running by:
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)
}
maxEntries (default: 1000)
maxMemory (default: 100MB)
defaultTTL (default: 1 hour)
checkInterval (default: 1 minute)
statsInterval (default: 30 seconds)
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. The caching happens automatically when you interact with any language model through your MCP client.
Here are some examples of what gets cached:
When reading a file multiple times:
When performing calculations or analysis:
When the same data is needed multiple times:
The server automatically manages the caching process by:
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:
To see the cache in action, try these scenarios:
File Reading Test
Data Analysis Test
Project Navigation Test
The cache is working when you notice:
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"cursor-rules-mcp": {
"command": "npx",
"args": [
"-y",
"cursor-rules-mcp"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.