Fully local, persistent, semantic memory for your AI coding agents. No external API keys required.
Give every agent in your project the same long-term memory: architecture decisions, TDD rules, coding conventions, bug-fix lessons, and anti-patterns — retrieved automatically before coding, updated automatically after coding.
Works with: Claude Code, OpenCode, Qwen Code, KiloCode, Antigravity, and any MCP-compatible agent.
Global Qdrant (Docker) Ollama (Embeddings)
│ │
└────── Mem0 MCP Server ───────┘
│
┌───────┬───────┼───────┬───────────┐
Qwen Claude OpenCode KiloCode Antigravity
- Qdrant — Vector store, one global instance shared across all projects
- Ollama — Local LLM (
gemma3:4b) + embedding model (nomic-embed-text) - Mem0 — Memory orchestration layer
- MCP Server — Exposes memory tools to your agents over stdio
- Python 3.11+
- Docker (for Qdrant)
- Ollama running locally with
nomic-embed-textandgemma3:4bmodels
docker run -d --name qdrant-mem0 --restart unless-stopped \
-p 6333:6333 -v qdrant_mem0_global:/qdrant/storage \
qdrant/qdrant:latestollama pull nomic-embed-text
ollama pull gemma3:4bgit clone https://github.com/sanprat/agent-memory.git
cd agent-memory
python3 -m venv .venv
.venv/bin/pip install -r requirements.txt./init_project.sh /path/to/your/projectThis copies the memory server, rules files, and agent MCP configs into your project, and creates its virtualenv.
Edit seed_memories.py in your project to add project-specific memories (TDD rules, architecture decisions, coding conventions, anti-patterns), then:
cd /path/to/your/project
.venv/bin/python3 seed_memories.pyEvery agent reads .agent-memory-rules.md on startup and automatically:
- Searches memory before coding (finds TDD rules, conventions, past decisions)
- Follows retrieved rules during coding
- Updates memory after coding (stores bug fixes, architecture decisions, learnings)
Every project gets these files:
| File | Purpose | Loaded by |
|---|---|---|
.agent-memory-rules.md |
Universal brain — rules for before/during/after coding | All agents |
CLAUDE.md |
Tells Claude Code to load the rules file | Claude Code |
AGENTS.md |
Tells OpenCode to load the rules file | OpenCode |
.mcp.json |
MCP config | Claude Code |
.kilocode/mcp.json |
MCP config + native instruction injection | KiloCode |
mcp_config.json |
MCP config | Antigravity |
.qwen/mcp.json |
MCP config | Qwen Code |
The mem0_mcp_server.py exposes 4 tools to agents:
| Tool | Description |
|---|---|
mem0_add |
Store a new memory with optional category |
mem0_search |
Semantic search across memories |
mem0_list |
List all memories for an agent |
mem0_delete |
Delete a memory by ID |
All memories are stored under a single shared agent ID (shared_rules by default), so every agent in the project sees the same memory.
A smoke test verifies the MCP server starts and exposes its tools:
.venv/bin/python3 test_smoke.py| Variable | Description | Default |
|---|---|---|
MEM0_AGENT_ID |
Shared agent identifier | shared_rules |
MEM0_COLLECTION |
Qdrant collection name | agent_memory |
LLM_MODEL |
Ollama LLM model | gemma3:4b |
EMBED_MODEL |
Ollama embedding model | nomic-embed-text |
OLLAMA_BASE_URL |
Ollama URL | http://localhost:11434 |
QDRANT_URL |
Qdrant URL | http://localhost:6333 |
- Ollama LLM quality — memory extraction/summarisation uses a small local model (
gemma3:4b); complex memories may be summarised imperfectly. Swap in a larger model viaLLM_MODELif needed. - Single shared agent ID — all agents in a project share one memory scope by default; per-agent scoping is possible via
agent_idtool arguments but not yet a first-class workflow. - No sync across machines — Qdrant is a single instance; teams need a shared Qdrant deployment to share memory.
- Memory growth is unmanaged — memories accumulate; periodic curation (via
mem0_list/mem0_delete) is manual.
Read the full write-up on PyBankers — Build Real Products with AI: practical guides on AI agents, coding tools, and finance automation for Indian developers.
MIT — see LICENSE.