Engram MCP

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.

Category
访问服务器

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:

  1. FTS5 keyword matching — exact and stemmed keywords
  2. 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

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选