EvolvMem
A fully-local, three-layer memory plugin for Claude Code with Chinese support, offering hybrid FTS5/trigram and HNSW vector search, self-iterating memory management, consolidation, and a web console.
README
EvolvMem
A fully-local, three-layer memory plugin for Claude Code with Chinese language support — FTS5/trigram + HNSW vector hybrid search.
Features
- L0 Active Memory: SessionStart injection — a project digest layer (recent per-project session summaries from
:progress:log:memories,digest_*config), then pinned memories always injected, normal memories ranked by importance+recency+frequency score, the rest listed as a searchable index (progressive disclosure) - L1 Full History: SQLite + FTS5/trigram exact search, supports Chinese substring matching
- L2 Semantic Index: USearch HNSW vector search for finding related memories expressed differently
- Self-Iteration: Auto-extraction, conflict detection, access-decay forgetting
- Consolidation:
memory_consolidatefinds and merges near-duplicate memories via vector similarity (dry-run by default) - Semantic Merge: Write-time semantic merge — new values automatically supersede near-identical memories instead of duplicating them (
add_merge_threshold) — plus weekly auto-consolidation at SessionStart (consolidate_auto_run_hours) - Expiry: Memories can carry an
expires_atdate; expired memories stop being injected/searched and are archived automatically - Project Relevance: SessionStart scoring boosts memories whose key matches the current project directory (configurable aliases)
- Quality Gate:
memory_add/memory_replacereject values shorter thanvalue_min_chars(default 10) and low-information placeholder phrases (e.g. "等待用户确认", "no action required"), keeping trivial auto-summary noise out of the store
Quick Start
./install.sh
The script will automatically:
- Create
~/.claude/evolvmem/directory andmodels/subdirectory - Install pip dependencies usearch and llama-cpp-python
- Download bge-small-zh-Q5_K_M.gguf (~50MB, skipped if already present)
- Generate default
config.json - Verify the Config module can be imported
Manual Configuration
Add the MCP Server config to ~/.claude/settings.json:
{
"mcpServers": {
"evolvmem": {
"command": "python",
"args": ["-m", "evolvmem.mcp_server"],
"env": {
"PYTHONPATH": "/path/to/evolvmem-plugin"
}
}
}
}
Optional: add a SessionStart hook for automatic active memory injection:
{
"hooks": {
"SessionStart": [
{
"matcher": "",
"hook": "python -c \"from evolvmem.hooks import get_session_start_block; print(get_session_start_block())\"",
"env": {
"PYTHONPATH": "/path/to/evolvmem-plugin"
}
}
]
}
}
Tools
| Tool Name | Description |
|---|---|
memory_search |
FTS5 + HNSW hybrid search, supports Chinese |
memory_status |
View memory system status and statistics |
memory_add |
Manually write a memory (optional importance 1-10, tier pinned/normal, and expires_at date parameters) |
memory_replace |
Replace a memory (old value marked as superseded) |
memory_remove |
Soft-delete a memory |
memory_consolidate |
Find and merge near-duplicate memories by vector similarity; dry_run=true (default) only reports candidates |
Deletion is two-staged: memory_remove soft-deletes (recoverable via restore), while the Web Console's POST /api/memory/<id>/hard_delete permanently removes the row — irreversible, intended for confirmed junk. The quality gate above applies to every live memory_add/memory_replace call, so rejected values never enter the store in the first place.
Web Console
python -m evolvmem.web_server --host 0.0.0.0 --port 9377 serves a local console for browsing, filtering, editing and deleting memories (/api/stats, /api/memories, /api/memory/<id>/<action> with actions update|archive|restore|delete|hard_delete).
The stats "hot list" (top_accessed) ranks by composite heat — importance × (access_count + 1) — instead of raw hit count, so a high-importance memory with few hits outranks a trivial one that was matched often; each entry carries both access_count and importance so the two signals stay visible. Raw access_count still counts every retrieval hit and remains available as a pure frequency signal elsewhere in the console.
Data Directory
All data is stored under ~/.claude/evolvmem/:
| File/Directory | Description |
|---|---|
memory.db |
SQLite database with FTS5/trigram indexes |
vectors.usearch |
USearch HNSW vector index |
models/ |
BGE-small-zh Q5_K_M GGUF model file |
config.json |
Retrieval, forgetting, and other parameters |
Configuration
Edit ~/.claude/evolvmem/config.json to adjust the following parameters:
fts_top_k/vector_top_k: FTS5 and vector search recall counts, default 20 eachfts_weight/vector_weight: Hybrid search weight allocation, default 0.6 / 0.4forget_days_threshold: Days since last access before a memory can be archived, default 90forget_access_count_threshold: Max access count below which memories may be downgraded, default 2embedding_dim: Vector dimension, must match model, default 768embedding_query_prefix/embedding_doc_prefix: Task prefixes applied when embedding queries/documents (nomic defaultssearch_query:/search_document:, set to""to disable)inject_max_count: Max memories injected on SessionStart, default 50inject_max_chars: Total character budget for SessionStart injection, default 8000inject_pinned_max_count/inject_pinned_max_chars: Max count and character budget for the pinned layer, default 10 / 2000inject_index_max_chars: Character budget for the index layer, default 1000 (0 disables the index layer)inject_key_prefix_quota: Max injected memories sharing the same key prefix (first two segments), default 3inject_w_importance/inject_w_recency/inject_w_frequency: Scoring weights for importance/10, recency decay, and log1p(access_count), default 0.5 / 0.3 / 0.2inject_recency_tau_days: Recency decay time constant in days, default 14.0inject_freq_norm_cap: Access-count normalization cap for frequency scoring, default 20inject_w_relevance: Weight of the project-relevance bonus in SessionStart scoring (memories whose key contains the current directory name — or its alias — as a substring), default 0.3inject_project_aliases: Map of directory name → memory key segment for project matching (e.g.{"my-project": "myproj"}), default{}consolidate_similarity_threshold: Similarity threshold above which two memories are near-duplicate merge candidates formemory_consolidate, default 0.92. Note the metric issimilarity = (1+cos)/2(not raw cosine): 0.92 corresponds to a true cosine of ≈ 0.84; for real merges a threshold ≥ 0.97 (≈ cosine 0.94) is recommendedconsolidate_auto_run_hours: Minimum interval between auto-consolidation runs at SessionStart (merges near-identical pairs at a conservative 0.97 threshold; failures never block session start), default 168 (weekly); 0 disablesadd_merge_threshold: Write-time semantic merge threshold — when a new value's similarity to an existing memory meets or exceeds it, the existing memory is superseded instead of adding a near-duplicate, default 0.95expires_at(per-memory field, not config): Optional expiry date set viamemory_add(e.g.2026-12-31); expired memories are excluded from injection and search, and are auto-archivedforget_auto_run_hours: Minimum interval between auto-forgetting runs at SessionStart, default 24forget_rate_limit_days: Minimum interval between two downgrades of the same memory, default 7stop_hook_safe: Prevent Stop Hook infinite loops, default truevalue_max_chars: Hard length cap onmemory_add/memory_replacevalues, default 500value_min_chars: Minimum length formemory_add/memory_replacevalues — shorter values are rejected as having no information content, default 10
Dependencies
Python dependencies (auto-installed by install.sh):
pip install usearch llama-cpp-python
Embedding model: BGE-small-zh Q5_K_M GGUF (~50MB), auto-downloaded by install.sh. For manual download, place bge-small-zh-Q5_K_M.gguf in ~/.claude/evolvmem/models/.
Architecture
Three-layer memory structure: active memory (L0, SessionStart system prompt injection) -> exact retrieval (L1, SQLite + FTS5/trigram) -> semantic retrieval (L2, USearch HNSW). Memories self-iterate through auto-extraction, conflict detection, and access-decay forgetting. All data is stored locally, no external services required.
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。