Skip to main content

Event-sourced knowledge graph memory system for Claude Code

Project description

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:

Tool Description
create_entities Create nodes: concepts, decisions, patterns, projects, questions, learnings
create_relations Link entities with typed edges (implements, uses, decided_for, etc.)
add_observations Add facts/notes to existing entities
delete_entities Remove entities (cascades to relations)
delete_relations Remove specific relations
delete_observations Remove specific observations
read_graph Get the full knowledge graph
search_nodes Text search across names and observations
open_nodes Get specific entities with their relations
search_semantic Vector similarity search (meaning-based)
memory_context Tiered retrieval: shallow (summary), medium (search+neighbors), deep (subgraph)

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

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

Type Purpose Example
concept Ideas, patterns, approaches "Repository pattern", "Event sourcing"
decision Choices with rationale "Chose SQLite over Postgres for simplicity"
project Codebases, systems "auth-service", "mnemograph"
pattern Recurring code patterns "Error handling with Result type"
question Open unknowns "Should we add real-time sync?"
learning Discoveries "pytest fixtures simplify test setup"
entity Generic (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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mnemograph-0.1.1.tar.gz (60.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mnemograph-0.1.1-py3-none-any.whl (26.5 kB view details)

Uploaded Python 3

File details

Details for the file mnemograph-0.1.1.tar.gz.

File metadata

  • Download URL: mnemograph-0.1.1.tar.gz
  • Upload date:
  • Size: 60.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for mnemograph-0.1.1.tar.gz
Algorithm Hash digest
SHA256 a0fb8e2405436e91adb229d7067b78f0119eda48e428a275a8e56ae406e81841
MD5 9e355c97ef8cdd47556d7250653aa5bc
BLAKE2b-256 f808b793e28a011195e5da8b0355d9e69be20df0d51b5148614312f317509b22

See more details on using hashes here.

Provenance

The following attestation bundles were made for mnemograph-0.1.1.tar.gz:

Publisher: publish.yml on tm42/mnemograph

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mnemograph-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: mnemograph-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 26.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for mnemograph-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9f3f754bf2e8580533b7a61b9a8914bd586dd95a87693be2552fef8dbd09126a
MD5 81a97618ae8ad7ace2a9717e38221364
BLAKE2b-256 f3297c55a501bf370be93a6efd710b69638db6a569fb7f3f46486dbaa2190693

See more details on using hashes here.

Provenance

The following attestation bundles were made for mnemograph-0.1.1-py3-none-any.whl:

Publisher: publish.yml on tm42/mnemograph

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page