Mnemosyne Cache MCP
High-performance MCP response caching server that reduces latency from ~3000ms to ~0.001ms for repeated tool calls using a dual-layer SQLite and LRU memory cache.
README
Mnemosyne Cache MCP
High-performance MCP (Model Context Protocol) response caching server. Reduces latency from ~3000ms to ~0.001ms for repeated tool calls.
Overview
The Mnemosyne Cache MCP server provides transparent caching for MCP tool responses using a dual-layer architecture:
- SQLite: Persistent storage backend
- LRU Memory Cache: Hot entry acceleration
Key Features
- Intelligent TTL Management: Server-specific expiration policies
- Write-Operation Detection: Automatically skips caching for mutations
- SHA256 Cache Keys: Deterministic key generation from tool calls
- Statistics Tracking: Hits, misses, evictions, and hit rate monitoring
- Zero Configuration: Sensible defaults with environment variable overrides
Performance Impact
Uncached serena tool call: ~3000ms
Cached serena tool call: ~0.001ms
Performance improvement: 3,000,000% faster
Installation
npm install -g @zhadyz/mnemosyne-cache-mcp
Or use with npx:
npx @zhadyz/mnemosyne-cache-mcp
Configuration
Environment Variables
# Database location (default: ./mcp_cache.db)
export MNEMOSYNE_CACHE_DB="/path/to/cache.db"
# Memory cache settings (default: enabled, 1000 entries)
export MEMORY_CACHE="true"
export MEMORY_CACHE_SIZE="1000"
Default TTL Values
| Server | TTL (seconds) | Rationale |
|---|---|---|
| serena | 1800 (30 min) | Code changes frequently |
| context7 | 7200 (2 hours) | Docs are stable |
| github | 600 (10 min) | Repos change |
| filesystem | 300 (5 min) | Files change |
| memory | 0 (never) | Mutable state |
| mnemosyne | 0 (never) | Mutable state |
MCP Configuration
Add to your Claude Code MCP settings (.claude/mcp.json):
{
"mcpServers": {
"mnemosyne-cache": {
"command": "npx",
"args": ["@zhadyz/mnemosyne-cache-mcp"],
"env": {
"MNEMOSYNE_CACHE_DB": "./.cache/mcp_cache.db",
"MEMORY_CACHE": "true",
"MEMORY_CACHE_SIZE": "1000"
}
}
}
}
Or with local installation:
{
"mcpServers": {
"mnemosyne-cache": {
"command": "node",
"args": ["/path/to/mnemosyne-cache-mcp/dist/index.js"]
}
}
}
Available Tools
cache_get
Retrieve a cached MCP tool response.
{
"server_name": "serena",
"tool_name": "find_symbol",
"args": {
"name_path": "MyClass",
"relative_path": "src/main.ts"
}
}
Response:
{
"cached": true,
"data": { /* tool response */ }
}
cache_set
Store an MCP tool response with automatic TTL.
{
"server_name": "serena",
"tool_name": "find_symbol",
"args": { /* tool arguments */ },
"response": { /* tool response */ }
}
Response:
{
"success": true,
"message": "Cached response for serena:find_symbol"
}
cache_invalidate
Invalidate cache entries by server or tool.
{
"server_name": "github",
"tool_name": "get_issue" // optional
}
Response:
{
"success": true,
"invalidated_entries": 42
}
cache_stats
Get cache performance statistics.
{}
Response:
{
"hits": 1523,
"misses": 287,
"evictions": 12,
"totalEntries": 1810,
"totalSizeBytes": 15728640,
"sizeMB": 15.0,
"hitRate": 84.14,
"avgHitTimeMs": 0.001,
"avgMissTimeMs": 3127.5
}
Cache Key Generation
Cache keys are deterministically generated using SHA256:
const keyMaterial = `${serverName}:${toolName}:${sortedArgs}`;
const cacheKey = sha256(keyMaterial);
Arguments are JSON-stringified with sorted keys to ensure identical calls produce identical keys regardless of argument order.
Write Operation Detection
The following verbs in tool names are automatically excluded from caching:
- create
- update
- delete
- remove
- modify
- write
Examples of non-cacheable operations:
github__create_issuefilesystem__write_fileserena__replace_symbol_body
Architecture
┌─────────────────────────────────────────┐
│ MCP Client (Claude Code) │
└────────────────┬────────────────────────┘
│
│ stdio transport
▼
┌─────────────────────────────────────────┐
│ Mnemosyne Cache MCP Server │
│ │
│ ┌───────────────────────────────────┐ │
│ │ LRU Memory Cache (Hot) │ │
│ │ - 1000 entries (default) │ │
│ │ - O(1) lookup │ │
│ └───────────┬───────────────────────┘ │
│ │ miss │
│ ▼ │
│ ┌───────────────────────────────────┐ │
│ │ SQLite Database (Cold) │ │
│ │ - Persistent storage │ │
│ │ - TTL expiration │ │
│ └───────────────────────────────────┘ │
│ │
│ Cache Key: SHA256(server:tool:args) │
└─────────────────────────────────────────┘
Development
Build
npm install
npm run build
Local Testing
node dist/index.js
Send MCP protocol messages via stdin:
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/list",
"params": {}
}
License
MIT
Author
ZHADYZ - MENDICANT_BIAS DevOps Agent
Part of the MENDICANT autonomous AI orchestration system.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。