A Claude Code plugin that saves conversation context to MemoryGraph before compaction, so agents can recall it afterward.
MemoryGraph is a graph-based persistent memory server for AI coding agents. This plugin hooks into Claude Code's compaction lifecycle to extract session context and store it as linked memories in your local MemoryGraph instance.
When Claude Code compacts a conversation (automatically or via /compact), this plugin:
- Lets the compaction run (works alongside other plugins like Metzger)
- Extracts key context from the messages about to be compacted
- Stores structured memories in MemoryGraph via the MCP server
- Links related memories with typed relationships using
create_relationship - Optionally nudges the agent to recall what was stored
The plugin uses MemoryGraph's native type system:
| Type | When | Relationship |
|---|---|---|
conversation |
Every compaction — session goal, active files, decisions, last status | Root memory |
decision |
Each approach the assistant committed to | RELATED_TO → session |
solution |
Errors that were resolved during the session | SOLVES → session |
error |
Errors still unresolved at compaction time | RELATED_TO → session |
file_context |
When 3+ files were touched | RELATED_TO → session |
Every memory carries structured context metadata (source, project path, tool name, file count) so you can filter and scope recall later.
[decision] ──RELATED_TO──▶ [conversation] ◀──SOLVES── [solution]
[decision] ──RELATED_TO──┘ ▲
│
[file_context] ──RELATED_TO──────┘
[error] ──────RELATED_TO─────────┘
After compaction, the agent (or a future session) can use recall_memories or search_memories to reload what it needs. MemoryGraph's project_path filter scopes recall to the current project.
The plugin ships one hooks module, hooks/memorygraph-bridge.ts, which hooks
the session.compact event. It first lets compaction run normally (including
any other compaction plugin), then reads the messages being compacted and
works out up to maxMemories memories from them.
It calls these tools by itself, without the model asking, once per compaction:
| Tool | Server | When |
|---|---|---|
store_memory |
the MCP server named by mcpServer (default memorygraph) |
Once per extracted memory, up to maxMemories |
create_relationship |
the same server | Once per link between two memories it just stored |
What it sends: memory titles, short summaries, and excerpts from the
conversation (the session goal, decisions, errors and their fixes, and the
paths of files that were touched), plus tags, an importance score and the
projectPath you configure. Text that looks like a secret (API keys, tokens,
passwords) is replaced with [REDACTED] before it is sent. It sends this only to the MemoryGraph MCP server
you registered in Claude Code. If that server is local (the default pipx
install with SQLite), nothing leaves your machine; if you pointed MemoryGraph
at a remote or cloud backend, the data goes wherever that backend stores it.
The plugin makes no network calls of its own.
When nudge is on and at least one memory was stored, it adds a single line
to the compacted conversation telling the agent it can use recall_memories.
It does not change or remove any other message.
You need MemoryGraph running as an MCP server in Claude Code:
# Install via pipx (recommended)
pipx install 'memorygraphmcp<2'
# Register as an MCP server
claude mcp add memorygraph memorygraphSee the MemoryGraph docs for backend options (SQLite, Neo4j, FalkorDB, Turso, cloud).
claude plugin install memorygraph-bridge@memorygraph-bridgeSet these in ~/.claude/settings.json under pluginConfigs.memorygraph-bridge:
| Option | Default | What it does |
|---|---|---|
mcpServer |
memorygraph |
Name of the MemoryGraph MCP server as registered in Claude Code |
importance |
0.7 |
Importance score (0.0–1.0) for stored memories |
maxMemories |
5 |
Cap on memories stored per compaction |
nudge |
true |
Append a reminder after compaction telling the agent to check MemoryGraph |
projectPath |
"" |
Working directory attached as context metadata for project-scoped recall |
Metzger replaces Claude Code's default compaction summarizer with a local scoring model that keeps important tool calls verbatim and cuts the rest. The two plugins work together: Metzger handles what stays in context, memorygraph-bridge handles what gets saved externally to MemoryGraph.
npm install
npm run typecheck
npm testMIT