freshcrate
Skin:/
Home > MCP Servers > MegaMemory

MegaMemory

Persistent project knowledge graph for coding agents. MCP server with semantic search, in-process embeddings, and web explorer.

Why this rank:Strong adoptionRelease freshnessHealthy release cadence

Description

Persistent project knowledge graph for coding agents. MCP server with semantic search, in-process embeddings, and web explorer.

README

MegaMemory

Persistent project knowledge graph for coding agents.

npmlicensenodenpm downloadsTwitter Follow MegaMemory web explorer


An MCP server that lets your coding agent build and query a graph of concepts, architecture, and decisions โ€” so it remembers across sessions.

The LLM is the indexer. No AST parsing. No static analysis. Your agent reads code, writes concepts in its own words, and queries them before future tasks. The graph stores concepts โ€” features, modules, patterns, decisions โ€” not code symbols.

The Loop

How MegaMemory works

understand โ†’ work โ†’ update

  1. Session start โ€” agent calls list_roots to orient itself
  2. Before a task โ€” agent calls understand with a natural language query (or get_concept for exact ID lookup)
  3. After a task โ€” agent calls create_concept or update_concept to record what it built

Everything persists in a per-project SQLite database at .megamemory/knowledge.db.


Installation

npm install -g megamemory

Note

Requires Node.js >= 18. The embedding model (~23MB) downloads automatically on first use.

Quick Start

megamemory install

Run the interactive installer and choose your editor:

megamemory install --target opencode

One command configures:

  • MCP server in ~/.config/opencode/opencode.json
  • Workflow instructions in ~/.config/opencode/AGENTS.md
  • Skill tool plugin at ~/.config/opencode/tool/megamemory.ts
  • Bootstrap command /user:bootstrap-memory for initial graph population
  • Save command /user:save-memory to persist session knowledge

Restart opencode after running install.

megamemory install --target claudecode

Configures:

  • MCP server in ~/.claude.json
  • Workflow instructions in ~/.claude/CLAUDE.md
  • Commands in ~/.claude/commands/
megamemory install --target antigravity

Configures:

  • MCP server in ./mcp_config.json (workspace-level)

With Codex

megamemory install --target codex

Configures:

  • MCP server in ~/.codex/config.toml
  • Workflow instructions in ~/.codex/AGENTS.md

With other MCP clients

Add megamemory as a stdio MCP server. The command is just megamemory (no arguments). It reads/writes .megamemory/knowledge.db relative to the working directory, or set MEGAMEMORY_DB_PATH to override.

{
  "megamemory": {
    "type": "local",
    "command": ["megamemory"],
    "enabled": true
  }
}

MCP Tools

Tool Description
understand Semantic search over the knowledge graph. Returns matched concepts with children, edges, and parent context.
get_concept Look up a concept by its exact ID. Returns full context including children, edges, incoming edges, and parent.
create_concept Add a new concept with optional edges and file references.
update_concept Update fields on an existing concept. Regenerates embeddings automatically.
link Create a typed relationship between two concepts.
remove_concept Soft-delete a concept with a reason. History preserved.
list_roots List all top-level concepts with direct children.
list_conflicts List unresolved merge conflicts grouped by merge group.
resolve_conflict Resolve a merge conflict by providing verified, correct content based on the current codebase.

Concept kinds: feature ยท module ยท pattern ยท config ยท decision ยท component

Relationship types: connects_to ยท depends_on ยท implements ยท calls ยท configured_by

Knowledge Graph

MegaMemory knowledge graph example


Web Explorer

Visualize the knowledge graph in your browser:

megamemory serve
  • Nodes are colored by kind and sized by edge count
  • Dashed edges show parent-child links; solid edges show relationships
  • Click any node to inspect summary, files, and edges
  • Search supports highlight/dim filtering
  • If port 4321 is taken, you'll be prompted to pick another
megamemory serve --port 8080   # custom port

How It Works

MegaMemory architecture diagram

src/
  index.ts       CLI entry + MCP server (9 tools)
  tools.ts       Tool handlers (understand, get_concept, create, update, link, remove, list_conflicts, resolve_conflict)
  db.ts          SQLite persistence (libsql, WAL mode, schema v3)
  embeddings.ts  In-process embeddings (all-MiniLM-L6-v2, 384 dims)
  merge.ts       Two-way merge engine for knowledge.db files
  merge-cli.ts   CLI handlers for merge, conflicts, resolve commands
  types.ts       TypeScript types
  cli-utils.ts   Colored output + interactive prompts
  install.ts     multi-target installer (opencode, Claude Code, Antigravity, Codex)
  web.ts         HTTP server for graph explorer
plugin/
  megamemory.ts  Opencode skill tool plugin
commands/
  bootstrap-memory.md  /user command for initial population
  save-memory.md       /user command to save session knowledge
web/
  index.html     Single-file graph visualization (d3-force + Canvas)
  • Embeddings โ€” In-process via Xenova/all-MiniLM-L6-v2 (ONNX, quantized). No API keys, and no network calls after the first model download.
  • Storage โ€” SQLite with WAL mode, soft-delete history, and schema migrations (currently v3).
  • Search โ€” Brute-force cosine similarity over node embeddings; fast enough for graphs with <10k nodes.
  • Merge โ€” Two-way merge with conflict detection by concept ID, with AI-assisted conflict resolution via MCP tools.

CLI Commands

Command Description
megamemory Start the MCP stdio server
megamemory install Configure editor/agent integration
megamemory serve Launch the web graph explorer
megamemory merge Merge two knowledge.db files
megamemory conflicts List unresolved merge conflicts
megamemory resolve Resolve a merge conflict
megamemory --help Show help
megamemory --version Show version

Merging Knowledge Graphs

When branches diverge, each may update .megamemory/knowledge.db independently. Since SQLite files cannot be auto-merged by git, megamemory provides dedicated merge commands.

Merge two databases

megamemory merge main.db feature.db --into merged.db

Concepts are compared by ID: identical nodes are deduplicated, and conflicting nodes are kept as ::left/::right variants under one merge group UUID. Use --left-label and --right-label to replace default side labels with branch names.

megamemory merge main.db feature.db --into merged.db --left-label main --right-label feature-xyz

View conflicts

megamemory conflicts            # human-readable summary
megamemory conflicts --json     # machine-readable output
megamemory conflicts --db path  # specify database path

Resolve conflicts manually

megamemory resolve <merge-group-uuid> --keep left    # keep the left version
megamemory resolve <merge-group-uuid> --keep right   # keep the right version
megamemory resolve <merge-group-uuid> --keep both    # keep both as separate concepts

AI-assisted resolution

When an AI agent runs /merge, it calls list_conflicts, verifies both versions against current source files, then calls resolve_conflict with resolved: {summary, why?, file_refs?} plus a verification reason. It does not pick a side blindly; it resolves to what the codebase currently reflects.


License

MIT

Release History

VersionChangesUrgencyDate
v1.6.2## Summary - Treat empty `parent_id` values as omitted when creating root concepts. - Make installer updates non-destructive for existing user configs and unmarked plugin/command files. - Add multi-process database concurrency regression coverage. ## Validation - `npm test` - `npm run build`High5/3/2026
v1.6.1## What's Changed * Add get_concept tool for exact ID lookup by @mikaelj in https://github.com/0xK3vin/MegaMemory/pull/10 **Full Changelog**: https://github.com/0xK3vin/MegaMemory/compare/v1.6.0...v1.6.1Medium3/20/2026
v1.6.0## What's New ### Codex install target (#9) - `megamemory install --target codex` now configures megamemory for OpenAI's Codex CLI/IDE/App - Primary path uses `codex mcp add` CLI; falls back to writing TOML directly to `~/.codex/config.toml` - Writes `~/.codex/AGENTS.md` with knowledge graph workflow instructions ### SQLite concurrency fix (#8) - `softDeleteNode()`, `hardDeleteNode()`, and `resolveConflict()` now wrapped in transactions to prevent orphaned edges under concurrent multi-process Low3/16/2026
v1.5.0## Concurrency Safety & Schema v4 This release adds robust multi-process SQLite safety and schema improvements for concurrent MCP access. ### Changes - **SQLite busy_timeout & synchronous pragmas** โ€” `busy_timeout=5000` and `synchronous=NORMAL` for multi-process safety - **Atomic createConcept transactions** โ€” node + edges wrapped in a single transaction - **Migration serialization** โ€” `BEGIN IMMEDIATE` prevents concurrent migration races - **UNIQUE constraint on edges with auto-deduplicationLow3/3/2026
v1.4.1Strengthen megamemory prompt wording from suggestive to mandatory. Models with large thinking budgets were rationalizing away soft instructions โ€” upgraded to 'You must call' language with explicit ordering and 'no implicit memory' framing. Ref #6.Low3/3/2026
v1.4.0Add timeline playback to web explorerLow2/17/2026
v1.3.3- Fix: Restore full `megamemory stats` command with all 5 sections (Database, Graph, list_roots, Kinds, Size) - Fix: Add missing `await` for async stats command in CLI router - Includes timeline functionality merged from visualization branchLow2/11/2026
v1.3.1- Replace `init` with interactive `install` command supporting opencode, Claude Code, and Antigravity - Add semantic search to web explorer - Standardize error formatting (via @mikaelj)Low2/10/2026
v1.2.1Add test coverage for embedding validation and Buffer deserialization fixes from PR #2.Low2/8/2026
v1.2.0**Full Changelog**: https://github.com/0xK3vin/MegaMemory/compare/v1.1.2...v1.2.0Low2/7/2026
v1.1.2Add `/save-memory` command for persisting session knowledge into the megamemory graph. Prompts the agent to reflect on what it learned during a session and write it to the knowledge graph โ€” no git changes required. ### Changes - New `/user:save-memory` slash command (installed via `megamemory init`) - Generalized command installer in init (`setupCommand()` helper) - Updated READMELow2/6/2026
v1.1.1Fix Windows path handling in init command - Use `fileURLToPath()` instead of `new URL().pathname` to avoid double drive letter (`C:\C:\...`) on Windows - Use `os.homedir()` instead of `process.env.HOME` which is unset on Windows - Support `OPENCODE_CONFIG_DIR` env var override for custom config location - Use `where` instead of `which` on win32 for global install detectionLow2/6/2026
v1.1.0Replace better-sqlite3 with libsql for zero-compilation installs - libsql ships prebuilt binaries for all platforms โ€” no Python, C++ build tools, or node-gyp needed - Remove @types/better-sqlite3 (libsql has built-in types) - Fix pragma() return value difference between the two librariesLow2/6/2026
v1.0.1Fix: exclude test files from published package.Low2/6/2026
v1.0.0Initial release โ€” MCP server with 6 tools, web explorer, CLI with colored output, in-process embeddings, SQLite persistence.Low2/6/2026

Dependencies & License Audit

Loading dependencies...

Similar Packages

mcp-verified-repo-memoryProvide reliable, repository-scoped memory for AI coding agents with code citations, just-in-time verification, and stale-proof data management.main@2026-06-02
sdl-mcpSDL-MCP (Symbol Delta Ledger MCP Server) is a cards-first context system for coding agents that saves tokens and improves context.v0.11.4
ClawMemOn-device context engine and memory for AI agents. Claude Code, Hermes and OpenClaw. Hooks + MCP server + hybrid RAG search.main@2026-05-20
discord-opsAgency-grade Discord MCP server โ€” multi-guild project routing, AI-native notifications, and DevOps workflows for Claude Code and other AI agentsv0.23.3
ori-cliAgentic coding harness with persistent memory and a REPL body. Built on Ori Mnemos. Open source must win.master@2026-05-08

More in MCP Servers

AstrBotAgentic IM Chatbot infrastructure that integrates lots of IM platforms, LLMs, plugins and AI feature, and can be your openclaw alternative. โœจ
agentscopeBuild and run agents you can see, understand and trust.
claude-plugins-officialOfficial, Anthropic-managed directory of high quality Claude Code Plugins.
langchain4jLangChain4j is an open-source Java library that simplifies the integration of LLMs into Java applications through a unified API, providing access to popular LLMs and vector databases. It makes impleme