Memkeeper is a local-first memory storage engine for AI agents, built around a single SQLite database. It requires no server, cloud service, or telemetry, and does not require network or LLM calls. Its goal is to give agents persistent, retrievable context rather than a "goldfish-like memory." This repository is the core of the memkeeper memory engine and is part of a larger control plane that also covers persistent memory, project context, coordinated task handoff, and default-deny permissions, all running deterministically and locally.
Purpose and Positioning Memkeeper is used to store, rank, and retrieve agents' persistent contextual memory. It is suitable for scenarios where reusable facts, decisions, preferences, and experiences are to be retained locally. It is a deliberate, carefully maintained memory store, not an automatic transcription log. Memories can be written directly via the CLI (memkeeper remember --json '{"content":"…"}') or automatically captured by MCP clients calling remember during a session.
Key Capabilities
- Local-first: a single SQLite database, no server, no cloud, no telemetry.
- Fast retrieval on prompt: deterministic BM25/FTS retrieval, with optional ONNX semantic embeddings and cross-encoder reranking.
- Durable by design: atomic writes, schema-versioned storage, and a retention model that promotes high-signal repeated memories to a durable layer.
- Spatial model: agents call remember to capture durable facts and search to recall them; retrieval is consistent with the CLI and available across sessions.
- Retrieval modes: local semantic (default, ONNX entirely on-device), off-device semantic (OpenAI-compatible embedding API, no model download required), and lexical fallback (BM25/FTS, zero network and zero model). Local semantic is the recommended mode and requires running pull-models first to fetch models; when models are missing, it does not silently degrade—it records the missing models and marks semantic-unavailable while falling back to lexical retrieval; setting MEMKEEPER_REQUIRE_SEMANTIC=1 forces failure instead of degradation. Embeddings are computed when memories are written, and existing memories need to be backfilled with reindex --embed.
- Document storage (RAG): a document chunking layer independent of the curated memory layer, located in the documents space by default, supporting ingest, document-search,document-get, document-duplicates, document-prune, promotion-candidates, and other commands, used to import and retrieve entire documents.
- Entity graph: MCP's remember captures bounded entities, aliases, and typed relationships when the host agent provides graph fields, and commits them atomically; raw CLI calls can also pass the same graph structure. Graph visualization and bare memories are different layers.
- MCP adaptation: memkeeper supports MCP (JSON-RPC 2.0 over stdio), and any MCP client (such as Claude Code, Cursor) can read and write memories during a session. There is also a Claude Code UserPromptSubmit hook client, hook retrieve, which can inject relevant memories into prompts.
- HTTP dashboard: memkeeper serve --http starts a read-only local dashboard (default http://127.0.0.1:7777),用于浏览记忆与实体图;写入需设置 MEMKEEPER_HTTP_WRITE_TOKEN.
- Memory granularity recommendation: each remember should be a self-contained memory, retaining context and intent (for example, store "the user likes pineapple on pizza" rather than just "pineapple"). Avoid being too small (bare keywords) or too large (an entire document), because the curated memory layer does not chunk, and the embedder only sees about the first 512 tokens of an entry.
How to use Installation: the release page provides a self-contained binary, requiring no runtime network, LLM, or API key, and also provides .sha256 verification; the default storage path is ~/.memkeeper/store.sqlite (can be overridden with --store). The --json value can also be @<file> or - (standard input), which helps avoid shell quoting issues (especially useful under Windows PowerShell). Upgrade: v0.3.0 introduced an upgrade from schema 5 to 6, and v0.4.0 through v0.5.3 keep schema 6 unchanged. Migration is transactional, but a schema 6 store cannot be opened by v0.2.x; before upgrading, it is recommended to stop long-running memkeeper processes and back up the store with a v0.2.x binary, and after upgrading, explicitly run the migration and verify. init can be safely rerun; rollback requires first restoring a schema 5 backup. MCP usage: point the client's MCP configuration at the native binary (no Python, no extra dependencies). Semantic model: pull-models writes models into ~/.memkeeper/models/ (can be overridden with MEMKEEPER_MODELS_DIR or --dir), which is exactly the default lookup path, and after that running search enables semantics. If you do not want to download a local model, you can also configure an OpenAI-compatible API (OpenAI, OpenRouter, or a compatible proxy). Switching embedding models (between local and off-device, or between models) requires modifying the embedding environment variables and running reindex --embed once; old vectors are cleared and the new model is recorded, and partial mixing is not supported. Building from source: optional. Requires a Rust stable toolchain (edition 2021, Rust 1.56+) and a C toolchain (built-in SQLite and ONNX runtime); macOS requires Xcode Command Line Tools, and Debian/Ubuntu requires build-essential. The first build fetches dependencies from crates.io, and afterward it can work offline. Using --no-default-features builds a leaner lexical-only binary.
Use cases
- Long-term agent memory that needs to be local and free of cloud dependencies.
- Remembering facts, decisions, and preferences across sessions in MCP clients such as Claude Code and Cursor.
- Projects that need hybrid retrieval (lexical + semantic + reranking) with a separate RAG document layer.
- Environments that are privacy-sensitive and require memory content not to leave the device.
Limitations and status Currently in pre-release status v0.5.3, and the API and wire protocol may change before 1.0; this repository is a release mirror generated from a private development repository, the main branch may be regenerated, and it is recommended to pin to tagged releases or release artifacts. Prebuilt binaries are released for macOS (Apple Silicon) and Linux x86_64; Windows is experimental, with no prebuilt binaries, but it can be built and run from source, and serve --socket on Windows is Unix-only (the HTTP dashboard and stdio serve are cross-platform). Off-device semantics send memory text to an embedding provider, so use it only when acceptable; both on-device modes do not send content externally. On the LoCoMo benchmark (10 multi-session dialogues, 1982 evidence-bearing questions), the default semantic retrieval has public results; on a warm serve daemon (with the ONNX model already loaded), a prompted search is about 25 ms p50/p95, roughly 32 times faster than reloading the model cold on every invocation. More design notes, benchmarks, and reproduction scripts are in the repository documentation and blog.