MemVault
The Shared Memory Layer for Every AI Agent You Run
Not "agent learns to search memory" — memory finds the agent.
MCP Native · Hybrid Retrieval · Auto-Injection · Zero-Config Sync
Open Source · Self-Hosted · Private · MIT Licensed
English · 简体中文
If MemVault solves a real problem for you, a star helps others find it.
curl -fsSL https://raw.githubusercontent.com/dreamor/memvault/master/scripts/install.sh | bash
Every AI agent session starts from scratch. Claude Desktop doesn't know what Cursor just learned. DeepSeek Harness (dsh) doesn't know what you told Claude Code yesterday. Whatever agent you're running — international or domestic, IDE plugin or CLI harness — it forgets your preferences every time you start a new conversation.
You've been manually repeating context — project conventions, personal preferences, past decisions — across agents that should already know. This isn't a limitation of the models. It's a missing infrastructure layer.
MemVault is that layer. A lightweight, self-hosted memory router that sits between your agents and their context. It speaks plain MCP — no MemVault-specific SDK, no per-agent API integration. Any MCP-compatible agent, from any vendor, automatically shares the same persistent memory the moment it connects.
Who it's for:
- Anyone running an MCP-capable agent — Claude Code, Claude Desktop, Cursor, Cline, Continue, DeepSeek Harness (dsh), or any other MCP client, domestic or international — who wants preferences, project context, and past decisions to persist across sessions without repeating yourself
- Multi-agent power users running several of the above side by side, on different models, from different vendors — all sharing the same memory without configuration
- Platform teams deploying AI-assisted workflows where consistency matters across a mixed agent fleet: code review conventions, architecture decisions, project-specific preferences
- Anyone tired of telling their AI the same thing twice — MemVault works the way your brain should: you say it once, it's there when you need it, no matter which agent is asking
Quick Start · How It Works · What MemVault Gives You · Why MemVault · MCP Server · CLI Reference · Integrations · Architecture · Project Status · Testing · Documentation · Contributing · License
Quick Start
Don't install MemVault by hand — paste this one prompt into Claude Code, Codex, Cursor, dsh, or any other MCP-capable agent. It points the agent at a machine-readable install guide, so the agent does the whole setup itself:
Install MemVault as your long-term memory and wire it into this agent. Fetch and follow https://raw.githubusercontent.com/dreamor/memvault/master/docs/AGENT-INSTALL.md — install the binaries, register MemVault as an MCP server for this host, and verify recall works. Then keep saving my preferences, project decisions, and lessons from each session so my next agent starts with them instead of from scratch.
Or install manually:
# Install (Linux / macOS): official script, auto-verifies SHA-256
curl -fsSL https://raw.githubusercontent.com/dreamor/memvault/master/scripts/install.sh | bash
export PATH="$HOME/.memvault/bin:$PATH"
# Windows (PowerShell):
# powershell -ExecutionPolicy Bypass -File scripts\install.ps1
# Homebrew (Apple Silicon):
# brew install dreamor/tap/memvault
# Or from crates.io:
# cargo install memvault-cli memvault-mcp
# The installers auto-start the local REST backend (host of the Web
# Dashboard). Open it, or start it on demand:
memvault-cli dashboard
# Save a MUST-level preference (injected as instruction, agent must follow)
memvault-cli save --content "User prefers Python" --priority MUST --type preference \
--instruction "Use Python for code, not Java" --tags "coding,python"
# Search across all memory (hybrid: keyword + semantic when embedding is enabled)
memvault-cli search --query "Python"
# See what context gets injected when a specific agent connects
memvault-cli session-start --agent-id claude-desktop --context "Help me write code"
# Extract structured memories from free text
memvault-cli extract --text "I prefer dark mode. Our project uses Rust." --save
# Auto-generate agent instruction files from memory
memvault-cli sync
# All in one: dedup, decay, archive stale memories
memvault-cli dedup && memvault-cli decay
System requirements:
- Prebuilt Linux binaries (install script / GitHub release): glibc ≥ 2.38 + GLIBCXX_3.4.31 (GCC 13-era runtime — Ubuntu 24.04+ / Fedora 39+ / Arch;
memvault-proxyadditionally wants glibc ≥ 2.39). TLS is rustls, so no OpenSSL dependency. Ubuntu 22.04 / RHEL or EL8/EL9 users: use the Docker image (dreamor/memvault) or build from source.- Building from source (
cargo install/cargo build): links fastembed's prebuilt ONNX Runtime static library and needs a GCC 13-class toolchain. Older toolchains (e.g. GCC 8, CentOS 7/8-era libstdc++) fail at link time with missing C++20/23 stdlib symbols (std::format,std::to_chars). macOS / Windows (MSVC) / Homebrew / Docker are unaffected.
Verify your install in 5 seconds:
memvault-cli --version
# memvault 0.6.8
# sanity check: list saved memories (verifies DB is healthy)
memvault-cli list
Local Ollama Demo (Zero Cost, Stays on Your Machine)
MemVault is plug-and-play with a local Ollama: unconfigured LLM extraction (full-text understanding / failure reflection / relation extraction) auto-detects a local Ollama; embeddings use the local model with the ollama or auto provider.
# 1. Install and start Ollama
brew install ollama && brew services start ollama # or the official installer
# 2. Pull models
ollama pull nomic-embed-text # embeddings, 768-dim (default for ollama/auto)
ollama pull qwen2.5:3b-instruct # chat: LLM extraction/reflection (default qwen2.5:7b, use 3b on small machines)
# 3. (Optional) Pin the providers explicitly — persist them in ~/.memvault/.env
# (shell exports also work — env vars take precedence over the file — but the file survives reboots)
mkdir -p ~/.memvault
cat >> ~/.memvault/.env <<'EOF'
MEMVAULT_EMBEDDING_PROVIDER=ollama
MEMVAULT_LLM_EXTRACTION_PROVIDER=ollama
MEMVAULT_LLM_EXTRACTION_MODEL=qwen2.5:3b-instruct
EOF
# 4. Verify
memvault-cli status # Embedding provider: configured and reachable
memvault-cli save --content "Build server IP is 10.20.30.40" # output (embedded int8)
memvault-cli outcome --task "Deploy trading service" --status failure --cause "Disk space insufficient" --task-type deploy
# → Lesson (Llm): ... means failure reflection ran through the local LLM (not the rule-based fallback)
With no configuration at all (neither env vars nor ~/.memvault/.env), LLM extraction auto-detects a local Ollama and enables itself (default model qwen2.5:7b; pull it in advance with ollama pull qwen2.5:7b, or point MEMVAULT_LLM_EXTRACTION_MODEL at an installed model). Embeddings still default to the in-process native embedder; set MEMVAULT_EMBEDDING_PROVIDER=auto in ~/.memvault/.env to prefer Ollama and fall back to native when it isn't running. The native model's first launch downloads the weights from HuggingFace silently in the background — the server/dashboard come up immediately and hot-swap to semantic search once the download finishes, so a fresh install never blocks on it (set MEMVAULT_EMBEDDING_PROVIDER=none to run pure keyword and skip the download).
How It Works
MemVault is a pipeline, not a single script. Every stage below is a shipping module:
Agent connects (MCP stdio/SSE)
│
▼
┌───────────────────┐
│ Agent Router │ ← match agent type/tag → filter relevant memory
│ (Agent Registry) │
└────────┬──────────┘
│
▼
┌───────────────────┐
│ Memory Retrieval │ ← keyword (BM25) + vector (embedding) + RRF fusion
│ (3 search modes) │ synonym expansion · scoring · soft filtering
└────────┬──────────┘
│
▼
┌───────────────────┐
│ Auto-Injection │ ← MUST-level → instruction prompt
│ │ REFERENCE → context resource
│ │ NORMAL → search result
└────────┬──────────┘
│
▼
Agent receives context ──→ makes better decisions
- Storage: SQLite with bundled FTS5 (full-text search); embeddings stored int8-quantized (~1/4 the size of f32 at near-identical ranking quality, legacy f32 rows still readable)
- Retrieval: BM25 keyword search over FTS5 with CJK bigram tokenization (Chinese two-character words match correctly) and tiered match fallback (strict → relaxed unigram → synonym OR; relaxations are reported, never silent), local-first embedding (in-process native by default — switch to local Ollama or any OpenAI-compatible model), RRF fusion with per-result recall provenance (
kw#2/vec#5), synonym expansion, relevance scoring, soft intent filtering - Pipeline: Automatic entity extraction, delta-write on save (near-duplicates skipped, similar memories absorb only the residual), semantic deduplication, time-based decay, archive of stale memories
- Sync: Zero-invasion file generation —
memvault-cli syncproduces CLAUDE.md, AGENTS.md, etc. directly from database contents
What MemVault Gives You
- Auto-Injected Context: Session start automatically pulls relevant memory by agent identity — MUST-level rules land as instructions, not just chat history
- Hybrid Retrieval: BM25 + vector + RRF fusion with synonym expansion, relevance scoring, and per-result provenance (which path recalled each memory, at what rank) — available via CLI, MCP tool, and REST API
- Explainable Injection: every candidate dropped on the way into an agent's context is recorded with a reason (budget, caps, intent/type penalties) — "why didn't the agent get this memory?" always has an answer
- MUST Enforcement: MUST-priority memories are never filtered or truncated. Always in context, always obeyed — trust comes from provenance (human-authored/reviewed), with an opt-in fallback for memories independently corroborated by multiple identity-verified agents (
MEMVAULT_CORROBORATION_GATE), so a single spoofed/compromised agent can't unilaterally inject a binding MUST - Multi-Agent Awareness: Agent Registry with type/tag-based soft filtering (score demotion, not hard exclusion)
agent_idIs Provenance, Not a Filter: retrieval never filters byagent_id— the field only records which agent wrote a memory (source_agent). Every agent searches the same shared corpus; per-agent differences apply only at injection time (type/tag soft scoring viaagents.yamlinject_rules)- MCP Proxy: Transparent proxy that injects memory into ANY upstream MCP server's responses — zero client changes
- Compliance Tracking:
inject_session_idtraces what was injected and measures follow-through rate - Cross-Platform: CLI + MCP Server (stdio & SSE) + Web Dashboard (browser) + Obsidian Plugin
- Zero-Invasion Sync: Generate AGENTS.md / CLAUDE.md from memory — no per-agent config files to edit
- Contextual Extraction, Local-First: Rule-based keyword extraction by default; optionally understands a full user+assistant exchange via an LLM, auto-detecting a local Ollama for free before ever touching a remote API
- History & Rollback: Every update/delete is snapshotted into
memory_history—memvault-cli checkpoints+memvault-cli restoreroll one memory back without touching the rest - Self-Diagnostics:
memvault-cli statusreports exactly which features are degraded when no embedding provider is configured, plus a schema fingerprint (migration version + checksum) for cross-database comparison - Episodic Memory:
record_outcomerecords task results; failures are distilled into lessons and auto-injected next time (REFERENCE → MUST only with human approval), so the same trap isn't hit twice - Procedural Skill Activation: skills whose
triggermatches intent are injected as structured[SKILL]blocks with success-rate stats (shown after ≥3 runs); failures flag the skill for revision (version++on human edit), repeated successes auto-draft new skills into the review inbox - Semantic Knowledge Links: lightweight relation triples, repeated facts consolidated into a linked semantic fact with provenance, and superseded facts archived (never re-injected, still listable & restorable)
- Team Shared Pool & SOP Import: memories marked
sharedare injected into every session (capped at 20); Markdown SOPs can be batch-imported as verifiable skills - Delta-Write on Save: every save is checked against its namespace first — near-duplicates are skipped, similar memories absorb only the residual (what's genuinely new) and get their strength refreshed, so the library converges instead of accumulating near-copies;
--force/force_insertbypasses - Task-Level Evaluation:
memvault-cli benchsamples your own failure history (episodes that distilled a lesson) and measures lesson retrieval/injection rates — and with--judge, an LLM scores "plan without vs. with memory" against the known failure cause, so you see task-success lift, not just retrieval recall - Two-Phase Injection (never blocks): MUST rules resolve deterministically with zero embedding calls and are served immediately; the semantic pipeline prefetches in the background and lands within a short window (250ms) — if it doesn't, the deterministic baseline is served and the request moves on (two-phase design)
- Conversation-N-Gram Retrieval: retrieval keys are conditioned on the recent turn window, weighted by recency so the current focus dominates — not a single flat query
- Single Canonical Injection Channel: per-agent
inject_channel(mcp/proxy/syncinagents.yaml) restricts automatic injection to one delivery path, so the same memory is never sent to the same agent twice - Data You Own: Single SQLite file. Full export/import. No cloud dependency. Your data, your machine.
Why MemVault
Looking for a self-hosted alternative to Mem0, Zep, or Letta/MemGPT? Those are hosted APIs or Python frameworks tied to one SDK. MemVault ships as a single Rust binary with no hosted service and no vendor lock-in, speaks plain MCP instead of a proprietary SDK, and shares one memory store across every agent you run — Claude Code, Cursor, Claude Desktop, dsh — not just one.
MemVault complements your existing agent setup rather than replacing it. Keep your LLM, your IDE, and your workflow exactly as they are. MemVault adds the memory layer underneath.
MCP Server
Tier-1 agents (Claude Code, OpenCode, dsh, Gemini CLI, Codex) have one-command plugin installs — see Installing into your agents first. Everything below is the universal fallback for any other MCP client.
stdio (any standard MCP client)
MemVault speaks plain MCP stdio — the same mcpServers JSON works verbatim in Claude Desktop, Cursor, Cline, Continue, and any other client that reads this format:
{
"mcpServers": {
"memvault": {
"command": "/path/to/memvault-mcp",
"args": ["--db", "~/.memvault/data.db"],
"env": { "OPENAI_API_KEY": "sk-..." }
}
}
}
A couple of clients use their own one-liner instead of hand-editing JSON:
# Claude Code
claude mcp add memvault /path/to/memvault-mcp -- --db ~/.memvault/data.db
DeepSeek Harness (dsh) — a domestic (China) agent harness — gets deeper treatment than a generic stdio config: a native Cordis plugin (dsh-plugin/) that auto-injects memory into the system prompt and auto-extracts at turn end, with no per-turn cooperation required from the agent. See docs/INSTALL.md §2.5 for both the zero-code MCP route and the deep-integration plugin.
Other MCP-compatible agents — international or domestic, IDE plugin or CLI harness — should work the same way: any client implementing standard MCP stdio/SSE can connect without MemVault-side changes. The ones above are the ones we've actually verified; if you get MemVault working with another one, a PR to this list is welcome.
SSE (multi-client, network-accessible)
memvault-mcp --transport sse --port 3777
# Clients connect at http://127.0.0.1:3777/mcp
SSE features: multi-client simultaneous connections, auto-triggered embedding backfill on initialization, HTTP remote access.
Note:
--transport sseonly mounts the MCP-over-HTTP endpoint (/mcp) — it does not expose the REST API (/api/*). The Web Dashboard is served by the REST backend (memvault-mcp --transport http --serve-web <dist>), and the Obsidian plugin also uses the REST API and requires--transport httpinstead. See docs/INSTALL.md §2.6.
20 MCP Tools
2 MCP Resources
Configuration (.env file & environment variables)
Copy .env.example to ~/.memvault/.env and uncomment what you need — it is also the single source of truth documenting every key.
Precedence (high → low): CLI flags > process environment > ~/.memvault/.env > built-in defaults. Every binary loads the env file first thing at startup; --env-file <path> or MEMVAULT_ENV_FILE points elsewhere, and a missing file is silently skipped. memvault-cli status prints where each setting came from (env / file / default).
Two groups are intentionally not in the table below: the host installation contract (MEMVAULT_AGENT_ID, MEMVAULT_HOOK_EXTRACT, … — per-agent values authored in each host's plugin/mcpServers config), and the proxy's upstreams topology (structured data, lives in ~/.memvault/proxy.yaml).
CLI Reference
save · outcome · search · list · review · delete · session-start · resource · extract · dedup · decay · forget · forget-log · doctor · promote · backup · export · export-skill · import · import-skills · import-agent · ingest · confirm-read · backfill-embeddings · sync · reindex · migrate-to-markdown · checkpoints · restore · supersede · status · bench · eval-history · server start|status|stop · dashboard
memvault-cli <command> --help # detailed usage per command
Key Commands
Integrations
Installing into your agents
MemVault ships native adapters for most agents — one shared store, per-host identity via MEMVAULT_AGENT_ID, four tiers (Tier 1/2/3 details below; per-client registration snippets in integrations/mcp-clients/).
Core packages & versions:
Shipped plugins & versions — each bumps on its own schedule:
Tier 1 — one-command native plugins (memory injected by hooks; extraction opt-in where the host exposes lifecycle hooks):
⚠️ = the host has no injection hooks; recall is rule-driven (the agent calls session_start once) with the bundled canonical rule text.
Tier 2 — paste an MCP snippet. Strict-JSON registrations with per-host identities in integrations/mcp-clients/ (target paths in its README): Cursor · Windsurf · Cline/Roo · Continue · Zed · JetBrains AI/Junie · VS Code (Copilot Chat) · Claude Desktop.
Tier 3 — native manifests, verify-on-install. Qoder (.qoder/rules/ + .qoder-plugin/ + a UserPromptSubmit hook template), Grok Build (grok plugin install dreamor/memvault --trust), the Hermes Python plugin (integrations/hermes/, pre_llm_call recall + extraction helper) and the pi extension (pi-extension/, pi install git:github.com/dreamor/memvault) ship in-repo; OpenClaw and Swival consume the generated root skills/ (also exported to .openclaw/skills/); Devin stays a manual recipe in integrations/README.md.
Tier 4 — instruction-only rule copies. Canonical text + scripts/gen-rule-copies.sh (parity-checked in CI) produce AGENTS.md/CLAUDE.md blocks, .cursor/rules/, .clinerules/, .kiro/steering/, Junie guidelines; memvault-cli sync --watch keeps them fresh from the store.
Any other MCP-speaking client (domestic or international, IDE plugin or CLI harness) connects with zero MemVault-side changes via the standard stdio config below — not individually verified; PRs adding a verified entry are welcome.
GUI surfaces are independent of agent installs: Web Dashboard (9 tabs) · Obsidian plugin (α — Vault sync + browse/capture) · MCP Proxy (transparent memory injection for any upstream server).
Architecture
┌────────────────────────────────────────────────┐
│ Clients (any MCP-compatible agent) │
│ ┌────────────┐ ┌────────┐ ┌─────┐ ┌────────┐ │
│ │ Claude Code│ │ Cursor │ │ dsh │ │ Others │ │
│ └────────────┘ └────────┘ └─────┘ └────────┘ │
└──────────────────┬───────────────────────────────┘
│ MCP (stdio / SSE / HTTP)
┌──────────────────▼───────────────────────────────┐
│ memvault-mcp (rmcp 3.1.1) │
│ ┌──────────────┐ ┌────────────────┐ ┌────────┐ │
│ │ 20 tools │ │ 2 Resources │ │ SSE │ │
│ │ + REST API │ │ + Auto-Inject │ │ Server │ │
│ └──────┬───────┘ └──────┬─────────┘ └────────┘ │
│ └────────┬───────┘ │
│ ┌───▼────────┐ │
│ │ Agent │ (Agent Registry │
│ │ Router │ type/tag filter) │
│ └───┬────────┘ │
├──────────────────┼────────────────────────────────┤
│ memvault-core │ │
│ ┌──────────┐ ┌─▼───────┐ ┌────────────┐ ┌───┐ │
│ │ storage │ │retrieval│ │ pipeline │ │sync│ │
│ │ SQLite │ │BM25+Vec │ │extractor │ │ │ │
│ │ │ │RRF+syn │ │dedup/decay │ │ │ │
│ │embed │ │onym │ │export/ │ │ │ │
│ │backfill │ │scoring │ │import │ │ │ │
│ └──────────┘ └─────────┘ └────────────┘ └───┘ │
└────────────────────────────────────────────────┘
Project Status
MemVault is in beta. The Rust core (storage / search / injection) is CI-gated and stable; plugin adapters and GUI surfaces evolve faster. All configuration is environment-driven (see .env.example), and every change is recorded in CHANGELOG.md.
Testing
cargo test # ~1300 tests (full workspace)
cargo clippy --all-targets # zero warnings
cargo fmt --all -- --check # format check
cargo llvm-cov --workspace --all-features # CI gate: line ≥92% / region ≥90% / function ≥85%
Documentation
Contributing
- 🐛 Bugs: Issue Tracker
- 💡 Ideas: Feature Request
- 📖 Guide: CONTRIBUTING.md
- 🔒 Security: SECURITY.md
- ♿ Accessibility: ACCESSIBILITY.md
License
MemVault is released under the MIT License.