Engram
Engram
Every thought leaves a trace.
Equip your AI Agent with a brain that knows how to forget.
Engram is a fully local MCP memory service. It doesn't just "store and retrieve"—it simulates human memory mechanisms like forgetting, reinforcement, and association, allowing Agents to remember what truly matters across sessions while naturally letting go of unnecessary details.
Zero cloud dependency; your data stays on your machine forever.
Pain Points Solved
Pain Point 1: Broken Cross-Session State
Every AI Agent conversation starts with a blank slate. The preferences you shared yesterday, the architectural decisions made last week, the pitfalls encountered last month—all reset in the next conversation. Clearing the context window is like formatting the brain.
Pain Point 2: File Entropy
Stuffing context into CLAUDE.md or .cursorrules seems to solve the problem but actually creates new ones: files grow indefinitely, outdated information mixes with new, and manual maintenance costs keep rising. You aren't managing memory; you're maintaining an increasingly unreadable document.
Pain Point 3: Lost Engineering State
What the Agent did, where it got stuck, what the next step should be—there's no place to store this structured engineering state. Every new session requires 10 minutes of "re-alignment" before repeating the same work.
Engram's Solution: Instead of "saving everything," it simulates the human forgetting-reinforcement-association mechanism:
Important preferences and decisions decay extremely slowly, remaining almost permanently.
Temporary debugging context naturally fades away after 11 days.
Knowledge that is recalled repeatedly becomes stronger with each use.
Contradictory information is automatically overwritten, preventing internal conflicts.
v0.2 New: Structured session handoff, allowing the next session to continue from a breakpoint rather than from scratch.
v0.4 New: Engineering State Hub — structured failure attribution (
track_failure) and progress tracking (track_progress), enabling the Agent to remember not just information, but engineering state.
Related MCP server: alaya
Core Mechanisms
1. Ebbinghaus Forgetting Curve
Every memory has a strength value that decays over time following an exponential curve:
effective_λ = base_λ × (1 - importance × 0.8)
strength = importance × e^(-λ × days) × (1 + recall_count × 0.2)Three factors determine how long a memory lasts:
Factor | Role | Mechanism |
Importance | The more important, the slower the decay | Can reduce decay rate by up to 80% |
Category | Different half-lives for different types | See table below |
Recall Count | The more frequently used, the stronger | +20% strength per recall |
Four Memory Categories:
Category | Decay Rate λ | Half-life | Use Case |
| 0.10 | ~38 days | Proven methodologies, architectural patterns |
| 0.16 | ~24 days | User preferences, identity, tech stack |
| 0.20 | ~19 days | Inferred context, uncertain information |
| 0.35 | ~11 days | Pitfalls, environment issues, temporary workarounds |
Design Intent: Successful strategies are remembered longest (strategy ~38 days), while lessons from failures are remembered shortest (failure ~11 days)—because environments change, and yesterday's pitfall might be fixed by tomorrow.
2. Intelligent Deduplication and Conflict Resolution
When storing new memories, the system doesn't just append; it performs semantic comparison with existing memories first:
相似度 ≥ 0.85 → REINFORCE 只增加回忆次数,不重复存储
相似度 0.65~0.84 → 检测矛盾
├── 语义矛盾 → REPLACE 用新内容覆盖旧内容
└── 语义兼容 → MERGE 合并为一条更完整的记忆
相似度 < 0.65 → NEW 存为新记忆Conflict detection is achieved through polarity analysis: extracting positive words (prefer/love/adopt) and negative words (avoid/hate/reject), combined with negation (not/don't/never), to determine if two memories express opposing stances.
Example: If "User prefers TypeScript" exists, and "User decides to abandon TypeScript for Go" is stored, the system identifies a conflict and automatically replaces the old memory with the new one.
3. Hybrid Retrieval (Vector + BM25 + Graph)
Retrieval uses a three-way hybrid scoring system:
最终得分 = 0.4 × BM25关键词得分 + 0.6 × (语义相似度 × 衰减强度) + 图谱加成Why not just use vector search?
Retrieval Method | Strengths | Weaknesses |
Vector Search | "That deployment method he mentioned" → Semantic understanding | Precise term matching |
BM25 | "DuckDB" → Precise keywords | Similar semantics but different wording |
Graph Expansion | A→B→C association discovery | Independent, unrelated memories |
Three-way fusion effect: Querying "database performance" not only finds memories that explicitly mention performance but also uses the graph to find related indexing strategies, caching decisions, etc.
4. Semantic Graph
Every memory automatically establishes semantic associations with existing memories upon storage:
Calculate cosine similarity with all existing memories
Establish bidirectional edges for similarity ≥ 0.40, with weight = similarity × 0.5
Each memory connects to at most 5 most similar neighbors
Two Key Roles of the Graph:
Associative Discovery: During retrieval, start from the hit memory and perform BFS (max depth 2) along edges to find associated memories, even if they lack direct semantic similarity to the query. It mimics human "associative thinking."
Chain Protection: When a memory's own strength falls below the threshold, if its neighbors still contain strong memories, it is preserved—as it may be the bridge connecting two important pieces of knowledge.
5. Automatic Consolidation and Pruning
Background maintenance tasks run every 12 hours:
Consolidation:
Identify memory clusters with similarity ≥ 0.70
Keep the one with the highest importance as the primary memory
Merge unique information from other memories
Recalculate vectors and graph relationships
Delete redundant merged memories
Pruning:
Calculate current strength for each memory
Strength < 0.05 and passes chain safety check → Delete
Strength < 0.05 but neighbors are still strong → Preserve (Chain Protection)
This means the memory bank stays lean automatically—no manual cleanup required, and it won't expand infinitely.
Engineering State Hub (v0.4)
Engram is not just a memory plugin for "storing info"—it is a state layer that understands engineering workflows.
Failure Attribution (track_failure)
When an Agent encounters bugs, test failures, or deployment issues, record them in a structured format:
# MCP 调用
track_failure(
error="CSRF token missing on checkout",
component="payment",
severity="critical", # → importance=0.9
root_cause="middleware not loaded after refactor",
fix="re-add CsrfMiddleware to pipeline",
related_test_ids=["test_checkout_01", "test_payment_csrf"]
)Design Decisions:
severityautomatically maps toimportance(critical=0.9, major=0.7, minor=0.5)Fixed
failurecategory (fastest decay λ=0.35, ~11-day half-life)—environments change, old failure records naturally expirecomponentfield supports aggregated statistics by module, quickly locating high-risk areas
Progress Tracking (track_progress)
Track feature/task status across sessions:
track_progress(
feature="login-flow-refactor",
status="in_progress", # → importance=0.8
completion=60,
blockers=["waiting for API design review"],
quality_score=0.85,
notes="auth module done, UI pending"
)Design Decisions:
statusautomatically maps toimportance(blocked=0.9 highest, done=0.5 lowest)Fixed
strategycategory (slowest decay λ=0.10, ~38-day half-life)—progress status should be remembered longestCompleted features naturally decay and disappear, no manual cleanup needed
Engineering Metrics (memory_stats enhancement)
memory_stats now automatically aggregates engineering data:
{
"total": 42,
"categories": {"fact": 20, "failure": 8, "strategy": 14},
"engineering": {
"failures": {
"total": 8,
"by_component": {"auth": 5, "payment": 3},
"by_severity": {"critical": 2, "major": 6}
},
"features": {
"total_tracked": 4,
"active": {
"login-refactor": {"status": "in_progress", "completion": 60},
"payment-fix": {"status": "blocked", "completion": 30}
}
}
}
}Technical Architecture
┌──────────────────────────────────────────────┐
│ MCP Client │
│ (Claude Code / Cursor / ...) │
└──────────────────┬───────────────────────────┘
│ stdio (JSON-RPC)
┌──────────────────▼───────────────────────────┐
│ server.py │
│ 8 MCP tools · APScheduler (12h 维护) │
├──────────────────────────────────────────────┤
│ │
│ ┌─ 写入路径 ──────┐ ┌─ 读取路径 ──────┐ │
│ │ resolve.py │ │ retrieve.py │ │
│ │ 去重/矛盾消解 │ │ 混合检索+评分 │ │
│ └─────────────────┘ └─────────────────┘ │
│ │
│ ┌─ 维护路径 ──────┐ ┌─ 统计路径 ──────┐ │
│ │ consolidator │ │ decay.py │ │
│ │ 聚类合并+剪枝 │ │ 遗忘曲线+强度 │ │
│ └─────────────────┘ └─────────────────┘ │
│ │
├──────────────────────────────────────────────┤
│ embedding.py │ graph.py │
│ 768d / 1024d 向量编码 │ NetworkX 语义图谱 │
├──────────────────────────────────────────────┤
│ db.py — DuckDB │
│ 向量存储 · BM25 全文索引 · CRUD │
└──────────────────────────────────────────────┘
数据文件(~/.engram/):
├── memories.duckdb # 向量数据库(单文件,零运维)
├── graph.json # 语义图谱(JSON 序列化)
└── model_cache/ # 嵌入模型缓存MCP Tool Interface
Tool | Parameters | Purpose |
|
| Semantic retrieval of memories, called at the start of each task. Results include metadata |
|
| Store new memory (auto-deduplication), returns memory_id |
|
| Update existing memory |
|
| Structured session handoff, records current progress for the next session |
|
| v0.4 Structured failure attribution, auto-associates component/severity/fix |
|
| v0.4 Feature progress snapshot, tracks status across sessions |
|
| Manually trigger memory consolidation |
|
| Memory stats + v0.4 Engineering metrics (failure trends, component health, active features) |
Importance Reference
Value | Use Case |
0.9–1.0 | Core identity, permanent facts ("User is a backend engineer") |
0.7–0.8 | Strong preferences, architectural decisions ("Project uses Go + PostgreSQL") |
0.5 | General project facts ("Recently refactoring the login module") |
0.2–0.3 | Temporary session context ("Test account used for this debug") |
Benefits to Users
1. The Agent Truly "Knows" You
No need to re-introduce your tech stack, coding habits, and project background every conversation. The Agent remembers you prefer Go over Java, knows your project uses a monorepo, and understands the architectural decisions you made last week.
2. Knowledge Naturally Evolves
Conflict resolution means the Agent's cognition is always up-to-date. Switching from React to Vue? One conversation automatically updates it. No need to manually maintain a list of "what the Agent should know."
3. Zero Maintenance
No manual cleanup of old memories—forgetting curves prune them automatically
No manual merging of duplicates—the consolidator handles it
No worries about data bloat—automatic maintenance every 12 hours
No external services—DuckDB single-file, ready to use out of the box
4. Complete Privacy
All data is stored in ~/.engram/, no networking, no uploading, no reliance on any cloud service. Embedding models run locally. Your memory is yours.
5. Associative Discovery
Graph expansion allows the Agent to not just "search and return," but to follow semantic associations to find relevant knowledge that doesn't directly match. It's like asking an old colleague a question; they don't just answer the question, they add, "By the way, this is related to that thing from last time."
6. Smarter with Use
Recall reinforcement mechanism: memories recalled repeatedly gain higher strength and decay slower. The Agent automatically learns what knowledge is most valuable to you.
Quick Start
# 安装
pip install mcp-engram
# 初始化(下载模型、创建数据库)
engram-setup
# 按照输出提示将配置块添加到 Claude Code 配置中Claude Code Configuration
{
"mcpServers": {
"engram": {
"command": "engram",
"env": {
"HF_ENDPOINT": "https://hf-mirror.com"
}
}
}
}CLAUDE.md Integration
Add to your project's CLAUDE.md:
## Memory Rules
### Step 1 — 先回忆再行动
每次任务开始时,用请求中的关键词调用 `recall_memory`。
### Step 2 — 学到新东西就存
| 情况 | 操作 |
|------|------|
| 全新知识 | `store_memory(content, importance)` |
| 补充已有 | `update_memory(memory_id, merged_content)` |
| 推翻已有 | `update_memory(memory_id, new_content)` |Environment Variables
Variable | Default | Description |
|
| HuggingFace model mirror |
|
| Embedding model name |
Key Threshold Quick Reference
Parameter | Value | Meaning |
Embedding Dimension | 768 | all-mpnet-base-v2 |
Deduplication REINFORCE | ≥ 0.85 | Almost identical, only increment recall count |
Deduplication MERGE/REPLACE | 0.65~0.84 | Detect conflict or merge |
Consolidation Clustering | ≥ 0.70 | Auto-merge similar memories |
Graph Edge Creation | ≥ 0.40 | Create semantic association |
Pruning Threshold | < 0.05 | Delete decayed memories |
Retrieval High Threshold | ≥ 0.50 | Primary vector search |
Retrieval Low Threshold | ≥ 0.20 | Degraded search |
BM25 Weight | 40% | Keyword matching contribution |
Vector Weight | 60% | Semantic matching contribution |
Graph Bonus | 30% | Extra score for associated memories |
LoCoMo Benchmark Evaluation
Retrieval quality evaluation based on LoCoMo (Snap Research long-term conversation memory benchmark). LoCoMo is the standard evaluation used by products like Mem0/Zep/Memobase/MemMachine.
Evaluation Configuration
Dataset: locomo10.json (2/10 conversations, 233 QA, excluding adversarial)
Retrieval: recall() top-k=5
LLM: DeepSeek-V3.2 / GLM-5.1 (Note: baseline products use GPT-4o-mini)
Metrics: Token-level F1 (official LoCoMo metric) + Hit@5 (LLM-independent retrieval hit rate)
Turn Mode — Best Configuration (bge-m3 + bge-reranker-v2-m3, DeepSeek-V3.2)
Two-stage retrieval: recall top-50 → CrossEncoder rerank to top-5, importance=1.0 correction weight ratio
Category | Count | F1 | Hit@5 |
Single-Hop | 114 | 0.5121 | 76.3% |
Temporal | 63 | 0.4501 | 95.2% |
Multi-Hop | 43 | 0.3181 | 60.5% |
Open-Domain | 13 | 0.1324 | 61.5% |
Overall | 233 | 0.4383 | 77.7% |
Turn Mode — Optimization Path (DeepSeek-V3.2)
Configuration | Overall F1 | Overall Hit@5 |
bge-m3 + reranker + weight fix | 0.4383 | 77.7% |
bge-m3 + reranker (r20) | 0.3913 | 69.1% |
bge-m3 (API, 1024d) | 0.3514 | 61.8% |
all-mpnet-base-v2 (local, 768d) | 0.2916 | 51.5% |
Four rounds of optimization cumulative F1 +50.3% (0.29 → 0.44), Hit@5 +26.2pp (51.5% → 77.7%).
Turn Mode — LLM Comparison (all-mpnet-base-v2)
LLM | Overall F1 | Single-Hop | Temporal | Multi-Hop | Open-Domain | Latency |
DeepSeek-V3.2 | 0.2916 | 0.3470 | 0.3257 | 0.1772 | 0.0192 | 239s |
GLM-5.1 | 0.2477 | 0.2672 | 0.3214 | 0.1430 | 0.0659 | 2011s |
Observation Mode (abstract assertive facts)
Category | Count | F1 |
Single-Hop | 114 | 0.3000 |
Multi-Hop | 43 | 0.1837 |
Open-Domain | 13 | 0.0659 |
Temporal | 63 | 0.0590 |
Overall | 233 | 0.2003 |
Comparison with Industry Baselines
System | Overall F1 | LLM | Embedding |
MemMachine | 0.8487 | GPT-4o-mini | — |
Memobase | 0.7578 | GPT-4o-mini | — |
Zep | 0.7514 | GPT-4o-mini | — |
Mem0 | 0.6688 | GPT-4o-mini | — |
Engram | 0.4383 | DeepSeek-V3.2 | bge-m3 + reranker |
Conclusion: Four rounds of optimization mpnet(0.29) → bge-m3(0.35) → +reranker(0.39) → +weight fix+r50(0.44). Hit@5: 51.5% → 77.7%. The gap with Mem0(0.67) narrowed from 56% to 35%.
Best Config Quick Reference
Recommended Config:
bge-m3(1024d) +bge-reranker-v2-m3two-stage retrieval
Metric
Value
Description
Overall F1
0.4383
Token-level, DeepSeek-V3.2
Overall Hit@5
77.7%
Pure retrieval hit rate, LLM-independent
Temporal Hit@5
95.2%
Outstanding performance on temporal questions
Optimization Magnitude
F1 +50.3%, Hit +26.2pp
Four rounds cumulative (relative to initial mpnet)
Key parameters:
recall top-50 → rerank to top-5,importance=1.0correction weight ratio. Local deployment with zero cloud dependency, gap with Mem0 (using GPT-4o-mini) narrowed to 35%.
Development
git clone https://github.com/hugfeature/engram.git
cd engram
pip install -e ".[dev]"
pytest tests/ -vLicense
MIT
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseAqualityCmaintenancePersistent semantic memory for AI agents. SQLite-backed, local-first, zero config. Semantic search via Ollama embeddings with keyword fallback. Tools: remember, recall, history, forget, stats.17371MIT
- AlicenseNot gradedqualityCmaintenanceA local memory engine for AI agents. Stores conversation episodes, consolidates knowledge through a neuroscience-inspired lifecycle, and builds a personal knowledge graph — all in a local SQLite database.13MIT
- AlicenseNot gradedqualityAmaintenanceOpen-source persistent memory infrastructure for AI agents.183318Apache 2.0
- AlicenseNot gradedqualityDmaintenancePersistent memory for AI coding agents with local-first, zero-cost, privacy-first SQLite/FTS5 storage and biological-inspired decay.152MIT
Related MCP Connectors
Persistent memory and knowledge graphs for AI agents. Hybrid search, context checkpoints, and more.
Persistent memory and knowledge management for AI agents with semantic search and 50+ tools.
Persistent memory for AI agents. Search, store, and recall across sessions.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/hugfeature/engram'
If you have feedback or need assistance with the MCP directory API, please join our Discord server