Engram MCP
Engram MCP provides persistent, cross-session memory for AI agents by automatically encoding errors, decisions, and discoveries during development sessions. It enables local, intelligent recall and automated context management to help AI learn from experience and avoid recurring mistakes.
README
Engram MCP — Cognitive Memory for AI
An engram is a unit of cognitive information imprinted in neural tissue — the physical trace of a memory.
Engram gives Claude Code persistent, cross-session memory that learns from experience. It runs locally as an MCP server + hook processor, automatically encoding errors, decisions, and discoveries — then surfacing them when relevant.
What It Does
- Remembers across sessions — knowledge encoded in session 5 surfaces automatically in session 20
- Learns from mistakes — errors resolved in past sessions auto-surface their fix when the same error appears
- Warns about antipatterns — known bad patterns trigger warnings before you write code
- Survives compaction — after context window compression, Engram restores your full project understanding
- Reduces context bloat — deliberate offloading protocol keeps the context window lean
- Self-maintaining — automatic consolidation prunes noise, promotes valuable memories, optimizes storage
Quick Install
# Install
npm install -g @vedtechsolutions/engram-mcp
# Configure Claude Code
npx @vedtechsolutions/engram-mcp setup
That's it. Start a new Claude Code session and Engram activates automatically.
Manual Setup
If you prefer manual configuration, add to ~/.claude/settings.json:
MCP Server
{
"mcpServers": {
"engram": {
"command": "node",
"args": ["/path/to/node_modules/engram-mcp/dist/index.js"],
"env": {
"ENGRAM_DB_PATH": "~/.engram/engram.db",
"ENGRAM_LOG_LEVEL": "info",
"ENGRAM_AUTO_CONSOLIDATE": "true"
}
}
}
}
Hooks
Add these hooks to enable automatic memory encoding:
{
"hooks": {
"UserPromptSubmit": [{
"type": "command",
"command": "node /path/to/node_modules/engram-mcp/dist/hook.js user-prompt-submit",
"input": "stdin"
}],
"PreToolUse": [{
"type": "command",
"command": "node /path/to/node_modules/engram-mcp/dist/hook.js pre-tool-use"
}],
"PostToolUse": [{
"type": "command",
"command": "node /path/to/node_modules/engram-mcp/dist/hook.js post-tool-use"
}],
"SessionStart": [{
"type": "command",
"command": "node /path/to/node_modules/engram-mcp/dist/hook.js session-start",
"input": "stdin"
}],
"SessionEnd": [{
"type": "command",
"command": "node /path/to/node_modules/engram-mcp/dist/hook.js session-end",
"input": "stdin"
}]
}
}
See the setup script output for the complete hook list.
How It Works
Automatic Encoding
Engram hooks into Claude Code events and automatically captures:
| Event | What's Captured |
|---|---|
| Bash errors | Error fingerprint + context → graduates to antipattern after recurring |
| Bash success after errors | Error resolution → links to original error via caused_by |
| Approach pivots | Why approach X failed, what replaced it → contradicts connection |
| Subagent completions | Discoveries, conclusions, lessons extracted from agent output |
| Write operations | File tracking, architecture graph updates |
| Session end | Session summary, Hebbian learning (co-recalled memories strengthen) |
Intelligent Recall
On every prompt, Engram injects relevant memories:
[ENGRAM CONTEXT]— relevant knowledge and past experiences[ENGRAM CAUTION]— warnings from past mistakes (cross-session)[ENGRAM SURFACE]— top domain memories for ambient awareness[ENGRAM REMINDER]— trigger-based prospective memories
Recall uses dual-path search:
- FTS5 keyword matching — exact and stemmed keywords
- TF-IDF cosine similarity — meaning-based matching (512-dim vectors, zero external APIs)
Cross-Session Error Resolution
Session 1: ParseError in views.xml
→ Encoded as error memory
Session 3: Fixed by replacing <tree> with <list>
→ Resolution linked via caused_by connection
Session 8: Same ParseError in different file
→ [ENGRAM CAUTION] Similar past error resolved: Use <list> not <tree>
Context Management
Engram actively manages context window pressure:
| Context % | Behavior |
|---|---|
| > 55% | Full recall and injection |
| 35-55% | Reduced injection, essentials prioritized |
| < 50% | Offload message: "your state is encoded, safe to focus" |
| < 40% | Summary mode: truncated content + recall pointers |
| < 20% | Essential antipatterns only |
Tools
These tools are available in Claude Code after setup:
| Tool | Usage |
|---|---|
engram_recall |
Search memory: engram_recall("how to fix ParseError") |
engram_encode |
Store knowledge: engram_encode("In Odoo 18, use list not tree", type: "semantic") |
engram_learn |
Record experience: engram_learn(action, outcome, lesson) |
engram_strengthen |
Reinforce useful memory |
engram_weaken |
Correct wrong memory |
engram_immune_check |
Check code against known antipatterns |
engram_stats |
Memory health and statistics |
engram_remind |
Create trigger-based reminder ("when X happens, do Y") |
engram_vaccinate |
Pre-register an antipattern |
engram_cleanup |
Remove noise from database (dry-run by default) |
engram_consolidate |
Trigger memory optimization cycle |
engram_self |
View/update persistent self-model |
engram_set_goal |
Set learning goals |
engram_list_goals |
Track learning progress |
engram_list_reminders |
List active reminders |
engram_experience |
Get version-specific knowledge |
Architecture
Layer 6: Primary Memory Protocol (Offloading, bridge file, cross-session learning)
Layer 5: Experience Versioning (Framework knowledge inheritance)
Layer 4: Consolidation Engine (9-phase: replay, prune, promote, transfer, dream)
Layer 3: Cortical Storage (Semantic, Episodic, Procedural, Immune + TF-IDF)
Layer 2: Hippocampal Bridge (Significance detection + encoding)
Layer 1: Sensory Buffer (Context window / working memory)
31 cognitive engines. 14 hook handlers. 16 MCP tools. All running locally.
Data & Privacy
- 100% local — all data stays on your machine in
~/.engram/engram.db - No external APIs — embeddings computed locally via TF-IDF (no OpenAI, no cloud)
- Your memories are yours — each installation starts with a fresh database
- No telemetry — zero network calls, zero tracking
Requirements
- Node.js 20+
- Claude Code CLI
License
Business Source License 1.1 — free for personal and non-commercial use. Converts to Apache 2.0 on 2029-03-05. See LICENSE for details.
For commercial licensing: Contact us
Built by VedTech Solutions
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.