R421 · Agent architecture › Memory and context

MegaMemory: an agent-written concept graph for project memory, and what keeps it true

Read the original

agent-memory, knowledge-management, mcp, agent-harness, docs-as-code

MegaMemory is an MCP server that lets a coding agent write down what it understands about a project (features, modules, patterns, decisions and why they were made) as a small graph, then search it at the start of later sessions. The model is the indexer: there is no AST parsing or static analysis, so the graph is exactly as good, and as current, as the agent's own notes. The useful ideas are the why field on every concept, soft deletion with a reason, and an AI-assisted merge that resolves conflicts against the current code. The weak points are that file references are bare paths with no commit or hash, so nothing detects a stale concept, and that the database is a binary SQLite file in the repository.

Source: AI Engineering's LinkedIn post (2026-11-30) and the 0xK3vin/MegaMemory repository: README, commands/bootstrap-memory.md, commands/save-memory.md, package.json, src/install.ts, src/db.ts and src/merge.ts.

What it is

ItemDetail
Packagemegamemory on npm, version 1.6.2 in package.json; Node 18 or later; MIT
Repository787 stars; created 2026-02-06; last push 2026-05-03, about seven months before the post
InterfaceStdio MCP server with 9 tools, plus a CLI (install, serve, merge, conflicts, resolve)
StorageOne SQLite file per project at .megamemory/knowledge.db (libsql, WAL mode, schema v3)
RetrievalIn-process embeddings (Xenova all-MiniLM-L6-v2, 384 dimensions, quantized ONNX, about 23 MB downloaded on first use), brute-force cosine over nodes; the README says it is fast enough under 10,000 nodes
IntegrationsInstaller targets Claude Code, Codex, OpenCode and Antigravity; any other MCP client by config
Explorermegamemory serve draws the graph in a browser (d3-force on canvas, port 4321 by default)

How it works

The workflow is understand, work, update. At session start the agent calls list_roots; before a task it calls understand (semantic search returning matched concepts with children, edges and parent) or get_concept by exact id; after a task it calls create_concept, update_concept, link or remove_concept.

Tradeoffs

Failure modes

  1. Silent staleness. file_refs is stored as a JSON list of path strings, with no commit, hash or line range. When the code changes and the agent skips update_concept, the concept goes on describing the old behaviour and nothing flags it. This is the experience-rot pattern: a remembered answer is reused without re-checking the thing it was learned from.

  2. Instructions applied everywhere. For Claude Code and Codex the installer appends a section to the GLOBAL ~/.claude/CLAUDE.md or ~/.codex/AGENTS.md, saying the agent must query the graph before reading source files and must record after each task. That applies to every project on the machine, including ones with no graph.

  3. Every two-branch edit is a conflict. The merge is two-way, with no common ancestor: any concept present on both sides and not identical becomes a conflict, even if only one branch changed it. Resolution then costs an agent call per concept, and on a busy repository the conflict queue will grow with ordinary work.

  4. Duplicates and drift in wording. Search-before-create is an instruction, not an enforced check; two sessions can add near-identical concepts under different ids.

  5. Unmaintained-looking project. No push since 2026-05-03. Before adopting, check open issues and whether the MCP SDK and embedding dependencies still install cleanly.

Review checklist

Connections

See R421 on the knowledge map

Part of the Research notes on nowucca.com. Figures and claims are the source's own unless the summary says otherwise.