Repository avatar
Search & Data Extraction
v0.1.1
active

mnemograph

io.github.tm42/mnemograph

Event-sourced knowledge graph memory for Claude Code with semantic search

Documentation

Mnemograph

A persistent, event-sourced knowledge graph for Claude Code. Unlike simple key-value memory, Mnemograph captures entities, relations, and observations — enabling semantic search, tiered context retrieval, and git-based version control of your AI's memory.

Why Mnemograph?

Claude Code sessions are ephemeral. Mnemograph gives your AI partner persistent memory that:

  • Survives across sessions — decisions, patterns, learnings persist
  • Supports semantic search — find relevant context by meaning, not just keywords
  • Provides tiered retrieval — shallow summaries to deep subgraphs based on need
  • Versions like code — branch, commit, diff, revert your knowledge graph
  • Enables collaboration — share memory repos across users or projects

Quick Start

Option 1: Let Claude Code install it

Give Claude Code this repo URL and ask it to set up mnemograph:

https://github.com/tm42/mnemograph

Or point Claude to the setup instructions directly:

Read https://raw.githubusercontent.com/tm42/mnemograph/main/SETUP_CLAUDE_CODE.md and follow them

Option 2: Manual installation

# Install from PyPI
pip install mnemograph

# Add to Claude Code (global, available in all projects)
claude mcp add --scope user mnemograph \
  -e MEMORY_PATH="$HOME/.claude/memory" \
  -- uvx mnemograph

# Initialize memory directory
mkdir -p ~/.claude/memory

Option 3: Install from source

git clone https://github.com/tm42/mnemograph.git
cd mnemograph
uv sync

# Add to Claude Code
claude mcp add --scope user mnemograph \
  -e MEMORY_PATH="$HOME/.claude/memory" \
  -- uv run --directory /path/to/mnemograph mnemograph

Usage

MCP Tools (used by Claude)

Mnemograph exposes these tools to Claude Code:

ToolDescription
create_entitiesCreate nodes: concepts, decisions, patterns, projects, questions, learnings
create_relationsLink entities with typed edges (implements, uses, decided_for, etc.)
add_observationsAdd facts/notes to existing entities
delete_entitiesRemove entities (cascades to relations)
delete_relationsRemove specific relations
delete_observationsRemove specific observations
read_graphGet the full knowledge graph
search_nodesText search across names and observations
open_nodesGet specific entities with their relations
search_semanticVector similarity search (meaning-based)
memory_contextTiered retrieval: shallow (summary), medium (search+neighbors), deep (subgraph)
get_state_atTime travel: view graph state at any point in history
diff_timerangeShow what changed between two points in time
get_entity_historyFull changelog for a specific entity
get_relation_weightGet weight breakdown (recency, co-access, explicit)
set_relation_importanceSet explicit importance weight (0.0-1.0)
get_strongest_connectionsFind entity's most important connections
get_weak_relationsFind pruning candidates (low-weight relations)

CLI Tools

mnemograph-cli — Event-level operations:

mnemograph-cli status              # Show entity/relation counts, recent events
mnemograph-cli log                 # View event history
mnemograph-cli log --session X     # Filter by session
mnemograph-cli revert --event ID   # Undo specific events
mnemograph-cli revert --session X  # Undo entire session
mnemograph-cli export              # Export graph as JSON

claude-mem — Git-based version control:

claude-mem init                  # Initialize memory as git repo
claude-mem status                # Show uncommitted changes
claude-mem commit -m "message"   # Commit current state
claude-mem log                   # View commit history
claude-mem graph                 # Open interactive graph viewer
claude-mem graph --watch         # Live reload mode (refresh button)
claude-mem --global graph        # Use global memory (~/.claude/memory)

Graph Visualization — Interactive D3.js viewer:

  • Layout algorithms: Force-directed, Radial (hubs at center), Clustered (by component)
  • Color modes: By entity type, connected component, or degree centrality
  • Edge weight slider: Filter connections by strength
  • Live refresh: --watch mode with Refresh button for real-time updates

Architecture

~/.claude/memory/
├── events.jsonl    # Append-only event log (source of truth)
├── state.json      # Cached materialized state (derived)
├── vectors.db      # Semantic search index (derived)
└── .git/           # Version history

Event sourcing means all changes are recorded as immutable events. The current state is computed by replaying events. This enables:

  • Full history of all changes
  • Revert any operation
  • Branch/merge knowledge graphs
  • Audit trail of what Claude learned and when

Two-layer versioning:

  • mnemograph-cli revert — fine-grained, undo specific events via compensating events
  • claude-mem commit/revert — coarse-grained, git-level checkpoints

Entity Types

TypePurposeExample
conceptIdeas, patterns, approaches"Repository pattern", "Event sourcing"
decisionChoices with rationale"Chose SQLite over Postgres for simplicity"
projectCodebases, systems"auth-service", "mnemograph"
patternRecurring code patterns"Error handling with Result type"
questionOpen unknowns"Should we add real-time sync?"
learningDiscoveries"pytest fixtures simplify test setup"
entityGeneric (people, files, etc.)"Alice", "config.yaml"

Development

git clone https://github.com/tm42/mnemograph.git
cd mnemograph
uv sync                    # Install dependencies
uv run pytest              # Run tests
uv run ruff check .        # Lint
uv run mnemograph          # Run MCP server directly

Based On

Mnemograph builds on ideas from:

  • MCP server-memory — Anthropic's official memory server (baseline)
  • Mem0 — extraction/consolidation patterns
  • Graphiti — bi-temporal modeling inspiration
  • Event sourcing principles — append-only logs, state materialization

License

MIT