Local-first MCP memory server that gives agent workflows persistent, governed, scope-aware operational knowledge.
It is designed for reusable facts, decisions, assumptions, invalidations, and project-level conventions. It is not a repository code-context retriever. The focus is durable memory with governance, privacy controls, auditability, and explicit scope boundaries.
Most agent workflows handle short-term context well but have no durable memory. llm-memory provides a persistent layer that stays inspectable, governed, portable, and local-first. It targets workstation or small-team use, where memory quality, privacy, and explicit control matter more than chat-history convenience.
- Local persistence with SQLite-backed metadata and vectors
- Tiered memory: strong memory for durable knowledge, fast memory for episodic operational notes
- Scope hierarchy: retrieval can compose
project,workspace, andglobal - Governance: promotion, invalidation, deduplication, and an audit trail close to the write path
- Optional encryption for sensitive payloads (install the
cryptoextra) and a configurable privacy policy - Import/export through JSONL, Markdown (
memory.md), and SQLite-backed data, limited to the entries the caller can read - Optional bearer token authentication for the HTTP transport
- No cloud service required for the default setup
MCP tool surface
|
v
MemoryService
|
+--> persistence policy
+--> importance scoring
+--> privacy controls
+--> audit trail
|
+--> SQLite store
+--> SQLite vector store
+--> embedding provider
Main runtime areas:
src/mcp_server/: MCP tool surface and transport entrypointssrc/service/: persistence policy, scoring, and orchestration logicsrc/storage/: SQLite-backed record persistencesrc/vectordb/: local vector storagesrc/security/: privacy and optional encryption helperssrc/interop/: import/export helpers such asmemory.md
Requires Python 3.11 or newer.
pip install -e ".[dev]"
cp .env.example .env
pytest -qOn Windows cmd, use copy .env.example .env.
Run as MCP stdio:
python -m src.mcp_server.serverRun the local HTTP transport:
python -m src.mcp_server.http_server
curl http://127.0.0.1:8767/healthscripts/serve.py is a cross-platform launcher that applies the local-only defaults (hash embeddings, SQLite, outbound network blocked) and works the same on Linux, macOS and Windows:
python scripts/serve.py # HTTP on 127.0.0.1:8767
python scripts/serve.py --transport stdio
python scripts/serve.py --port 9000Stop the server with Ctrl+C. The former Windows .bat launchers have been removed.
To enable at-rest encryption of sensitive payloads, install the optional extra: pip install -e ".[crypto]".
More detail, including request payload examples, is in QUICKSTART.md. Container usage is described in DOCKER_GUIDE.md.
Configuration is read from environment variables. .env.example lists every key with its default. Important defaults:
MEMORY_STORAGE_BACKEND=sqliteandMEMORY_VECTOR_BACKEND=sqliteMEMORY_SQLITE_PATH=./data/memory.dbMEMORY_IMPORT_EXPORT_BASE_DIR=./data/exchangeEMBEDDING_PROVIDER=hash-local(local hash-based embedding, no model download)MEMORY_ALLOW_OUTBOUND_NETWORK=falseMEMORY_ENCRYPTION_ENABLED=falseMEMORY_MULTI_PROJECT_ENABLED=falseMCP_MEMORY_HOST=127.0.0.1andMCP_MEMORY_PORT=8767LLM_MEMORY_API_TOKENunset (see Authentication)
Discovery and administration:
memory.aboutmemory.list_projectsmemory.get_project_infomemory.create_projectmemory.scope_overview
Operational memory tools:
memory.addmemory.log_fastmemory.list_fastmemory.get_fastmemory.rank_fast_candidatesmemory.prepare_fast_distillationmemory.apply_fast_distillationmemory.summarize_fastmemory.discard_fastmemory.promote_fastmemory.searchmemory.getmemory.invalidatememory.promotememory.reembedmemory.exportmemory.import
Prepare a fast-memory distillation pack from the CLI:
llm-memory-fast-distill prepare --agent-id local-cli --reason "prepare top candidate" --top-k 1Launch a local harness with the fixed prompt:
llm-memory-fast-distill run --agent-id local-cli --reason "distill top candidate" --top-k 1 --harness codexApply a distillation result from a local JSON file:
llm-memory-fast-distill apply --input result.jsonTool limit arguments are capped at 100 (50 for search_inference_memory).
Local admin and health endpoints. /health is always public; the /admin/* endpoints require the bearer token and are disabled when LLM_MEMORY_API_TOKEN is not set:
GET /healthGET /admin/summaryGET /admin/audit(filters:entry_id,action,actor,reason,since;after_id=<id>returns rows with a greater id oldest first, for gap-free polling)GET /admin/projectsGET /admin/fast-memoryGET /admin/fast-memory/candidatesGET /admin/fast-memory/distillation/runsGET /admin/fast-memory/distillation/runs/{run_id}GET /admin/fast-memory/{entry_id}POST /admin/fast-memory/distillation/preparePOST /admin/fast-memory/distillation/apply
The intended fast-memory workflow is:
- write episodic notes with
memory.log_fast - inspect ranked candidates with
memory.rank_fast_candidates - prepare a protected distillation pack with
memory.prepare_fast_distillation - run a local harness or CLI against the prepared pack
- apply the resulting JSON with
memory.apply_fast_distillation
The distillation flow is disabled by default. Enable it explicitly with:
FAST_MEMORY_AGENT_DISTILLATION_ENABLED=trueFAST_MEMORY_AGENT_DISTILLATION_APPLY_ENABLED=true
Set LLM_MEMORY_API_TOKEN to a strong random value (for example python -c "import secrets; print(secrets.token_urlsafe(32))") to enable bearer token authentication on the HTTP transport:
/mcp,/sseand/messages/requireAuthorization: Bearer <token>when the token is set, and stay open on loopback when it is not./admin/*always requires the token and answers403when no token is configured./healthstays public, but only returns diagnostics to authenticated callers when a token is set.- The server refuses to start when
MCP_MEMORY_HOSTis not a loopback address and no token is configured.
Each stored vector is tagged with the embedding version that produced it. At startup the server compares the active version with the configured provider. When they differ it logs an embedding_version_mismatch warning and memory.search is refused with an explicit error until you run memory.reembed without model_id/dim, which re-embeds existing entries with the configured provider and activates it. Writes keep working in the meantime. A write is rejected (reason: embedding-failed) when the provider cannot produce a vector, so every stored entry is searchable.
Outbound network access is blocked by default, the HTTP transport binds to loopback by default, and import/export paths are confined to MEMORY_IMPORT_EXPORT_BASE_DIR. Exports only contain entries the caller is allowed to read. The activity log on stderr records content hashes and lengths, never content. See SECURITY.md for the threat model and how to report vulnerabilities.
pip install -e ".[dev]"
ruff check src tests
pytest -q
pytest --cov=src --cov-report=term-missing --cov-report=xml -qCoverage is enforced at 82% through pyproject.toml. See CONTRIBUTING.md, docs/QUALITY_GATE.md, and docs/RELEASE_CHECKLIST.md.
Active development. The core runtime is functional and covered by automated tests. The current direction is hardening the local operational model rather than expanding into a cloud-first memory service. See CHANGELOG.md.
Built with AI-assisted workflows; architecture, tradeoffs, integration, review, and validation were directed by the author.
MIT. See LICENSE.