A portable, Dockerized, Obsidian-backed memory system for AI agents.
Prerequisites: Docker, Make, curl.
-
Clone the repository:
git clone https://github.com/ambushalgorithm/agent-memory-mcp.git cd agent-memory-mcp -
Initialize data directories:
make setup
This creates
~/.agent-memory/brain/and~/.agent-memory/data/with the required subdirectory structure. If you have existing data in the old./brain/or./data/locations (from a previous checkout),make setupmigrates it automatically. -
Configure environment:
cp .env.example .env
-
Build and start:
docker compose up --build
-
Verify it's running:
curl http://localhost:8787/v1/health
- ๐ณ Dockerized โ One-command setup with
docker compose up. No profile selection required. - ๐ Hybrid Search โ FTS5 BM25 keyword search + vector ANN + RRF fusion for best results.
- ๐ง Markdown Brain โ Human-readable markdown files as the source of truth in
~/.agent-memory/brain/. - ๐ฅ Proposal Inbox โ Agents write to
inbox/, not directly to canon. Safety first. - ๐ API Interfaces โ MCP-style JSON-RPC over stdio for agents, HTTP API for apps, CLI for maintenance.
- ๐พ Backup Ready โ Git versioned backups and Rsync file sync modes.
- ๐ Obsidian-Compatible โ Browse and edit brain files with any markdown editor.
- ๐๏ธ Audit Events โ Full event log for all memory operations.
- ๐๏ธ Context Pack Builder โ Build rich context packs for AI agents.
- โก Zero External Dependencies โ Local ONNX embeddings via
fastembed.
The system has three storage layers:
- ๐ Filesystem Brain โ Markdown files in
~/.agent-memory/brain/organized by domain (agents, identity, projects, decisions, knowledge, etc.). This is the human-readable source of truth. - ๐๏ธ SQLite Database โ
~/.agent-memory/data/memory.sqlitestores metadata, FTS5 keyword index, vector embeddings, and the audit log. - ๐ API / Interface Layer โ MCP-style JSON-RPC over stdio (for agents), HTTP API (for apps/bots), and CLI (for maintenance).
query โโโบ SQLite FTS5 (BM25) โโโ
โโโบ RRF fusion โโโบ ranked results
query โโโบ embed() โ vec0 ANN โโโ
Hybrid Search Pipeline: When a query arrives, it runs two parallel searches โ keyword (FTS5 BM25) and semantic (vector ANN via sqlite-vec). Results are fused using Reciprocal Rank Fusion (RRF) to produce a single ranked list. The RRF constant (RRF_K, default 60) controls how aggressively low-ranked results from one method are boosted.
By default, agents do not overwrite canonical memory. They write proposals to ~/.agent-memory/brain/inbox/. A human or trusted process reviews and merges proposals into the appropriate domain directories.
~/.agent-memory/brain/
โโโ inbox/ # Agent proposals (pending review)
โโโ agents/ # Agent-specific rules and context
โโโ identity/ # Core identity documents
โโโ preferences/ # User preferences
โโโ projects/ # Project memory
โโโ _templates/ # Note templates
โโโ decisions/ # Decision records
โโโ knowledge/ # Knowledge base
โโโ logs/ # Activity logs
โโโ systems/ # System-level memory
| Variable | Default | Description | Required |
|---|---|---|---|
EMBEDDING_PROVIDER |
fastembed |
Embedding provider: fastembed (local ONNX) or openai |
No |
EMBEDDING_MODEL |
BAAI/bge-base-en-v1.5 |
Embedding model name | No |
OPENAI_API_KEY |
โ | OpenAI API key | Only when EMBEDDING_PROVIDER=openai |
RRF_K |
60 |
RRF constant for Reciprocal Rank Fusion | No |
EMBEDDING_DIM |
768 |
Embedding vector dimension | No |
๐ See
.env.examplefor the full list of available environment variables.
- fastembed โ Local ONNX embedding generation (default provider)
- sqlite-vec โ Vector ANN search inside SQLite
curl -X GET http://localhost:8787/v1/health \
-H 'Content-Type: application/json'Response:
{"status": "ok", "timestamp": "2026-06-11T12:00:00Z"}curl -X POST http://localhost:8787/v1/memory/search \ -H 'Content-Type: application/json' \ -d '{"query": "communication preferences"}'
Response:
{
"results": [
{"id": "pref-001", "content": "User prefers best answer first, then steps.", "score": 0.89}
]
}curl -X POST http://localhost:8787/v1/memory/propose \ -H 'Content-Type: application/json' \ -d '{ "type": "preference", "tags": ["communication"], "content": "User prefers best answer first, then steps." }'
Response:
{"id": "proposal-042", "status": "accepted", "path": "inbox/proposal-042.md"}# Search from inside the container docker compose exec memory python -m scripts.memory_cli search "preferences" # Reindex the database from brain files docker compose exec memory python -m scripts.memory_cli reindex
Two tiers of reset are available, depending on how much you want to clean up.
Delete the SQLite database to start fresh. Brain files (Markdown source of truth) are preserved โ just run reindex afterward to repopulate.
Use this for: Daily resets when you want to keep your brain files.
# Via Makefile (recommended) make reset make up # Via CLI (from inside a running container) docker compose exec memory python -m scripts.memory_cli reset --force # Manual rm -f ~/.agent-memory/data/memory.sqlite*
After resetting, rebuild the database:
docker compose exec memory python -m scripts.memory_cli reindexStops containers, deletes ALL data including brain files, and reinitializes from scratch.
Use this for: A completely clean slate โ all brain files, database, and directory structure are destroyed and recreated.
# Via Makefile (recommended) make reset-full make up # Via CLI (from inside a running container) docker compose exec memory python -m scripts.memory_cli reset --force --all
Creates a local git commit of all changes in ~/.agent-memory/ with a timestamp. Optionally push to a remote.
# Local timestamped commit make backup # With remote push export [email protected]:user/agent-memory-backup.git make backup
Syncs ~/.agent-memory/ to a configured destination.
# Default destination (~/pCloud/agent-memory-backup) make backup-sync # Custom destination export AGENT_MEMORY_SYNC_DEST=/path/to/backup make backup-sync
๐ See
.env.examplefor backup configuration variables.
scripts/install-backup-launchd.sh
Installs a launchd agent that runs make backup daily at 02:00. Logs are written to ~/Library/Logs/agent-memory-backup.log.
scripts/install-backup-systemd.sh
Installs a systemd user timer that runs make backup daily (OnCalendar=daily).
Both installers check prerequisites, copy the unit files with the correct repository path, and verify the installation. Run them with no arguments for the default setup.
This is a working v1 production scaffold โ actively developed and ready for use.
- ๐ณ Fully Dockerized with
docker compose - โก FastAPI HTTP server with OpenAPI docs
- ๐ MCP-style JSON-RPC stdio server
- ๐๏ธ SQLite schema with FTS5 full-text search
- ๐
sqlite-vecvector ANN search - ๐งช Hybrid search (FTS5 BM25 + semantic vectors + RRF fusion)
- ๐ Markdown parser with YAML frontmatter
- ๐๏ธ Context pack builder
- ๐ฅ Proposal inbox safety model
- ๐๏ธ Audit event logging
- ๐ OpenAPI and MCP schema files
This project is licensed under the MIT License.
Have a suggestion or found a bug? Open an issue or submit a pull request.