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

Installation

# Install from PyPI
pip install mnemograph

# Or install from source
git clone https://github.com/tm42/mnemograph.git
cd mnemograph
uv sync  # or: pip install -e .

# Initialize memory (creates ~/.claude/memory/)
claude-mem init

Configure Claude Code

Add to your MCP settings (~/.claude.json or project .mcp.json):

{
  "mcpServers": {
    "mnemograph": {
      "command": "uv",
      "args": ["run", "--directory", "/path/to/mnemograph", "mnemograph"],
      "env": {
        "MEMORY_PATH": "/Users/YOU/.claude/memory"
      }
    }
  }
}

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 commit -m "msg" -a    # Commit with auto-summary
claude-mem log                   # View commit history
claude-mem log --oneline         # Compact commit log

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

uv sync                    # Install dependencies
uv run pytest              # Run tests (56 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.0.tar.gz (59.5 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.0-py3-none-any.whl (26.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mnemograph-0.1.0.tar.gz
  • Upload date:
  • Size: 59.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.24 {"installer":{"name":"uv","version":"0.9.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for mnemograph-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c1c11946a696a1ff8b14944d41b089ceab4cace33f44a261c284330233b26871
MD5 a94509592871ebd230789fc6d024e8df
BLAKE2b-256 9549902fda9fe8033670185ee363e88ddbaff64b995e6d3c7b433430d7797b8a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mnemograph-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 26.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.24 {"installer":{"name":"uv","version":"0.9.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for mnemograph-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 efb8e659e37ef99411f45208b3782b5fba9d4c70218e7f7343a018f62e691b94
MD5 b67e31694a4426ca453785ed4b0d836a
BLAKE2b-256 9615d81c28ac668e7d35ab1515ab5e63e43f0544e1981e8704166560edd47159

See more details on using hashes here.

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