Open source, local-first persistent memory system for LLMs
Project description
⚡ MemVault
Open source, local-first memory system for Claude and MCP workflows.
Zero data leaves your machine. Ever.
The Problem
LLMs are stateless mathematical functions — y = f(x, θ) — that forget everything between sessions.
| Metric | Value |
|---|---|
| 6-month AI conversation history | ~19.5 million tokens |
| Largest context window (Claude) | ~200k tokens |
| MemVault wake-up cost | ~350 tokens |
| Annual cost estimate | ~$10/yr |
| Data leaving your machine | Zero |
Quick Start
# Install
pip install memvault
# Initialize
memvault init
# For manual backfill, mine a project's Claude sessions first
memvault mine-convos ~/.claude/projects/-Users-you-my-project --project my-project --track auth
# Recall project decisions from session memory
memvault recall "What database did we choose for the auth service?" --project my-project --track auth
# Index project code/docs separately when needed
memvault index-project /path/to/repo --project my-project --track auth
# Search indexed project files separately
memvault search-project "database migrations" --project my-project --track auth
# Generate wake-up context for a new AI session
memvault wake-up
Recommended Beta Workflow
MemVault is most useful when we keep session memory and project indexing separate.
- Use
mine-convosandrecallfor session recall, decisions, and prior discussions. - Use
index-projectandsearch-projectonly when you explicitly want code/docs indexing. - Scope search to a project whenever possible.
- Use
--trackto narrow within a project, for exampleauth,infra, oronboarding. - Avoid broad mixed ingestion as the default beta workflow.
- For Claude, prefer the automatic hook flow for new sessions and use
mine-convosfor backfills.
For decision-style questions, MemVault now favors conversational memory before raw file text.
Automatic Claude Setup
For a one-time Claude installation with automatic session-start injection, automatic session-end mining, and MCP tool wiring:
memvault init
memvault install --client claude
After that, Claude will:
- inject MemVault context automatically at session start
- mine the finished transcript automatically at session end
- infer
projectandtrackfrom the working directory and transcript when possible - expose MemVault MCP tools during the session
Recommended Claude pattern:
- Install once with
memvault install --client claude - Work normally in Claude inside a project folder such as
/Users/you/keystone/backend/auth - Let the stop hook file the session into the
keystoneproject andauthtrack automatically - Use
memvault recall --project keystone --track authonly when you want to inspect what got stored manually
MCP Integration (Cursor, VS Code, etc.)
Add to your MCP settings:
{
"mcpServers": {
"memvault": {
"command": "memvault",
"args": ["serve"]
}
}
}
The AI assistant automatically gets 20 MCP tools for search, context retrieval, duplicate checks, memory management, knowledge graph access, and contradiction workflows.
If your MCP client can send its current working directory, MemVault can now infer:
projectfrom the active repo pathtrackfrom the current sub-area such asauth,infra, oronboarding- the best retrieval lane automatically, with a softer fallback if the first lane is empty
Architecture
4-Layer Memory Stack
┌──────────────────────────────────────────────────┐
│ L0 Identity ~50 tokens ALWAYS │
├──────────────────────────────────────────────────┤
│ L1 Critical Facts ~300 tokens ALWAYS │
├──────────────────────────────────────────────────┤
│ L2 Project Context ~2,000 tokens ON-DEM │
├──────────────────────────────────────────────────┤
│ L3 Deep Search ~5,000 tokens ON-DEM │
└──────────────────────────────────────────────────┘
Wake-up loads L0+L1 only (~350 tokens). Deeper context is fetched only when needed through MCP tool calls.
Memory Types
| Type | Store | Examples |
|---|---|---|
| Episodic | ChromaDB | Past events, sessions, decisions |
| Semantic | SQLite KG | Facts about user, projects, entities |
| Procedural | SQLite | Preferences, coding style, guardrails |
Retrieval Strategy
MemVault keeps two retrieval lanes:
- Session memory for decisions, prior discussions, and corrections
- Project memory for code/docs context that you explicitly index
Each lane can be narrowed with:
- project for the overall codebase or initiative
- track for a narrower thread inside that project, such as auth, infra, or onboarding
For beta, the intended flow is:
- Let Claude auto-mine new sessions through hooks
- Backfill older conversations with
mine-convoswhen needed - Recall within a project and optional track
- Index project files separately only when needed
- Pull only the relevant memories needed for the current question
Hybrid Search Pipeline
Query ─┬─► BM25 Keyword Search ──┐
│ ├─► RRF Fusion (k=60) ─► Scoring ─► [Reranker] ─► Results
└─► ChromaDB Vectors ─────┘
Scoring formula: final = relevance×0.40 + confidence×0.35 + recency×0.25
Intelligence Features
- Contradiction Detection — Rule-based + optional NLI (DeBERTa-v3-base). Every fact is checked against existing knowledge.
- Entity Detection — 80+ technologies, concepts, and person names auto-detected and registered in the Knowledge Graph.
- Memory Decay — Time-based confidence decay (soft at 180 days, hard at 365 days). Keeps memory fresh.
- Extractive Summarization — Decision-focused sentence scoring. No external LLM required.
Benchmark Results
Current benchmark results from local runs:
Config: Vector-only
Queries: 15
R@1: 86.7%
R@3: 100.0%
R@5: 100.0%
R@10: 100.0%
MRR: 0.9333
Avg Latency: 384.3ms
Config: BM25 + Vector + RRF (Hybrid)
Queries: 15
R@1: 86.7%
R@3: 93.3%
R@5: 100.0%
R@10: 100.0%
MRR: 0.9167
Avg Latency: 309.5ms
Config: BM25 + Vector + RRF + CrossEncoder
Queries: 15
R@1: 86.7%
R@3: 93.3%
R@5: 100.0%
R@10: 100.0%
MRR: 0.9167
Avg Latency: 739.3ms
Detailed report: benchmarks/REAL_BENCHMARK_REPORT.md
Run benchmarks: python benchmarks/longmemeval_bench.py
Tech Stack
| Component | Technology |
|---|---|
| Language | Python 3.9+ |
| Package Manager | uv |
| Vector Store | ChromaDB ≥0.4.0 (embedded, no server) |
| Knowledge Graph | SQLite temporal entity-relationship triples |
| Embeddings | all-MiniLM-L6-v2 (local, 80MB) |
| Keyword Search | rank-bm25 with RRF hybrid fusion |
| Re-ranking | ms-marco-MiniLM-L-6-v2 (optional, local) |
| Contradiction | DeBERTa-v3-base NLI (optional, local) |
| MCP Server | mcp Python SDK |
| CLI | Typer + Rich |
CLI Commands
# Core
memvault init [--dir DIR] # Initialize MemVault
memvault install [--client claude] # One-time client integration install
memvault status # System status
memvault mine <dir> [--mode convos] [--project P] # Beta default: conversation-first ingestion
memvault mine-convos <dir> [--project P] [--track T] # Session memory only
memvault index-project <dir> [--project P] [--track T] # Project files/docs only
memvault search "query" [--scope auto] [--cross] # Hybrid search with lane control
memvault recall "query" [--project P] [--track T] # Session-first recall
memvault search-project "query" [--project P] [--track T] # Project/document search
memvault wake-up [--raw] # L0+L1 context
# Memory Ops
memvault health # Memory health dashboard
memvault explain "query" [--project P] [--track T] # Why MemVault would answer this
memvault inspect-memory <id> # Show stored memory text + metadata
memvault edit-memory <id> [--text] # Correct stored memory text/metadata
memvault save-memory "text" [--kind decision] [--project P] [--track T] # Durable manual filing
memvault tracks --project P # Review known tracks within a project
memvault dashboard [--project P] # Pilot-friendly project/track dashboard
memvault review-stale [--project P] # Review stale memories that need cleanup
memvault contradictions [-p PROJ] # List contradictions
memvault resolve <id> [--keep new] # Resolve contradiction
memvault decay [--dry-run] # Apply memory decay
memvault forget [concept|--project] # Selective deletion
memvault rebuild-layers # Refresh derived L0/L1 context inputs
# Server
memvault install-claude # Claude-specific installer
memvault serve # Start MCP server (stdio)
MCP Tools
| Tool | Description |
|---|---|
memvault_status |
System status and memory counts |
memvault_search |
Hybrid search across all stores |
memvault_get_context |
Wake-up context (L0+L1, ~350 tokens) |
memvault_get_project_context |
Project-specific L2 context |
memvault_list_projects |
List tracked projects |
memvault_list_entities |
List KG entities |
memvault_check_duplicate |
Check whether a memory likely already exists |
memvault_explain_answer |
Explain which stored memories support an answer |
memvault_get_memory |
Inspect one stored memory by ID |
memvault_add_memory |
Add a memory directly through MCP |
memvault_edit_memory |
Edit a stored memory and its scope/metadata |
memvault_delete_memory |
Delete a memory by ID |
memvault_forget |
Forget by concept, project, or entity |
memvault_update_confidence |
Update a memory confidence score |
memvault_detect_entities |
Detect + register entities from text |
memvault_kg_query |
Query the knowledge graph |
memvault_kg_add |
Add a knowledge graph triple |
memvault_kg_invalidate |
Invalidate a knowledge graph triple |
memvault_kg_timeline |
Show an entity timeline |
memvault_kg_cross_project |
Query KG facts across projects |
memvault_health |
Return memory health metrics |
memvault_contradictions |
List detected contradictions |
memvault_resolve |
Resolve a contradiction |
Optional Dependencies
# Cross-encoder re-ranking (improves precision)
pip install memvault[reranker]
# NLI contradiction detection (semantic)
pip install memvault[nli]
# Everything
pip install memvault[reranker,nli]
Development
# Clone and install
git clone https://github.com/memvault/memvault.git
cd memvault
uv pip install -e ".[dev]"
# Run tests
pytest tests/ -v
# Run benchmarks
python benchmarks/longmemeval_bench.py --all -v
# Lint
ruff check memvault/ tests/
# Type check
mypy memvault/
Project Structure
memvault/
├── memvault/
│ ├── __init__.py # Package exports
│ ├── cli.py # Typer CLI
│ ├── config.py # Configuration + constants
│ ├── knowledge_graph.py # SQLite temporal KG
│ ├── user_model.py # User preferences + memory metadata
│ ├── vectorstore.py # ChromaDB wrapper
│ ├── convo_parser.py # Multi-format parser
│ ├── session_scorer.py # Session quality scoring
│ ├── ingestor.py # Chunking + embedding pipeline
│ ├── searcher.py # Hybrid search (BM25+Vector+RRF)
│ ├── reranker.py # Cross-encoder re-ranking
│ ├── layers.py # L0-L3 memory stack
│ ├── context_builder.py # Dynamic token budget packing
│ ├── fact_checker.py # NLI contradiction detection
│ ├── entity_detector.py # Entity detection + registration
│ ├── memory_pipeline.py # End-to-end orchestrator
│ ├── summarizer.py # Extractive summarization
│ ├── claude_integration.py # Claude lifecycle + MCP installer
│ ├── mcp_server.py # MCP server tools for search, save, inspect, and KG access
│ └── onboarding.py # Guided setup flow
├── tests/ # 329 tests
├── benchmarks/ # LongMemEval benchmark suite
├── hooks/ # Legacy shell hook examples
└── pyproject.toml
How It Works
- Mine Conversations — Parse sessions first, score them, chunk them, embed them, and register entities in the KG.
- Index Projects — Index code/docs separately when you want implementation lookup.
- Recall — Decision queries favor session memory before file text.
- Inspect / Edit — Use
explain,inspect-memory, andedit-memoryto debug or correct what MemVault stored. - Search Projects — Implementation queries can target indexed project files explicitly.
- Wake-Up — Load ~350 tokens of identity + critical facts at session start. No expensive retrieval.
- On-Demand — When the AI needs deeper context, MCP tools fetch scoped memory on the fly.
- Integrity — New facts are checked against existing knowledge for contradictions. Stale memories decay over time.
Claude Lifecycle
memvault install --client claude writes three Claude hooks plus the MemVault MCP server entry into ~/.claude/settings.json:
SessionStartrunspython -m memvault hook session-startand injects wake-up context automatically.Stoprunspython -m memvault hook stopand mines the Claude session transcript automatically.PreCompactrunspython -m memvault hook precompactand applies memory decay before compaction.
The installer is safe to re-run: it updates existing MemVault hooks, preserves unrelated Claude settings, and creates a timestamped backup before modifying an existing settings file.
Beta Notes
- Conversation-first mining is the recommended default for Claude workflows.
- Project indexing is optional and should be used intentionally.
- Dependency folders and generated content are excluded from raw file mining by default.
- The cross-encoder reranker is optional and slower; the hybrid default is usually the best latency/quality tradeoff.
- The intended workflow is
mine-convos+recallfirst, thenindex-project+search-projectwhen code/docs lookup is needed.
Pilot Workflow
For an internal pilot, the most practical workflow is:
- Install once for Claude:
memvault init memvault install --client claude
- Work normally in Claude inside a repo or sub-area like
keystone/backend/auth - Let Claude auto-mine sessions on exit
- Ask recall questions naturally in a new Claude session
- Use the inspection tools when needed:
memvault explain "What database did we choose for keystone auth?" --project keystone --track auth memvault inspect-memory <memory-id> memvault edit-memory <memory-id> --confidence 0.95 memvault dashboard memvault review-stale --project keystone
License
MIT — see LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file memvault_ai-0.1.0.tar.gz.
File metadata
- Download URL: memvault_ai-0.1.0.tar.gz
- Upload date:
- Size: 7.1 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
701c086cb348e4766e9770216880605f0581a11882896a54423eaf0545f42a3b
|
|
| MD5 |
f8c40df604443ceddeb5a829640d13db
|
|
| BLAKE2b-256 |
b5ff5ff5335ad9378de441a7cf0eb91075b1c4979ce4130b890aec0a990abea7
|
Provenance
The following attestation bundles were made for memvault_ai-0.1.0.tar.gz:
Publisher:
publish.yml on Koushik-1729/memvault-ai
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
memvault_ai-0.1.0.tar.gz -
Subject digest:
701c086cb348e4766e9770216880605f0581a11882896a54423eaf0545f42a3b - Sigstore transparency entry: 1463434818
- Sigstore integration time:
-
Permalink:
Koushik-1729/memvault-ai@f1d12aaeca4de70059d0b8194bf8469a6a38f56f -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Koushik-1729
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f1d12aaeca4de70059d0b8194bf8469a6a38f56f -
Trigger Event:
release
-
Statement type:
File details
Details for the file memvault_ai-0.1.0-py3-none-any.whl.
File metadata
- Download URL: memvault_ai-0.1.0-py3-none-any.whl
- Upload date:
- Size: 115.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3068b458acfff7202397fad2f26681c637b4f59e0e6d66cf6b50160d621b53b5
|
|
| MD5 |
c4702a288c25b4f8d44db8d5c89997df
|
|
| BLAKE2b-256 |
64f95b9609560a43367220ac9275d61b22198ef8f2d54f7730e385995d14d296
|
Provenance
The following attestation bundles were made for memvault_ai-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on Koushik-1729/memvault-ai
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
memvault_ai-0.1.0-py3-none-any.whl -
Subject digest:
3068b458acfff7202397fad2f26681c637b4f59e0e6d66cf6b50160d621b53b5 - Sigstore transparency entry: 1463434854
- Sigstore integration time:
-
Permalink:
Koushik-1729/memvault-ai@f1d12aaeca4de70059d0b8194bf8469a6a38f56f -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Koushik-1729
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f1d12aaeca4de70059d0b8194bf8469a6a38f56f -
Trigger Event:
release
-
Statement type: