{
  "markdown": "<p align=\"center\">\n  <h1 align=\"center\">DeepMem</h1>\n  <p align=\"center\"><strong>Drop-in AI memory layer with 2× faster response and 10× lower cost.<br>\n  Fully compatible with Mem0 API. Migrate in 5 minutes - one import line.</strong></p>\n  <p align=\"center\">Self-hostable. No auth, no payment, no lock-in. Or use the managed cloud at <a href=\"https://deepmem.dev\">deepmem.dev</a>.</p>\n</p>\n\n<p align=\"center\">\n  <a href=\"https://hub.docker.com/r/langdeepmem/deepmem\">\n    <img src=\"https://img.shields.io/docker/v/langdeepmem/deepmem?color=blue&label=docker\" alt=\"Docker Image\">\n  </a>\n  <a href=\"https://deepmem.dev\">\n    <img src=\"https://img.shields.io/badge/cloud-deepmem.dev-8A2BE2\" alt=\"DeepMem Cloud\">\n  </a>\n  <a href=\"LICENSE\">\n    <img src=\"https://img.shields.io/badge/license-MIT-blue.svg\" alt=\"License: MIT\">\n  </a>\n</p>\n\n<p align=\"center\">\n  <a href=\"https://deepmem.dev\">Cloud</a>\n  ·\n  <a href=\"#quick-start\">Self-host</a>\n  ·\n  <a href=\"#benchmarks\">Benchmarks</a>\n  ·\n  <a href=\"benchmarks/README.md\">Reproduce them</a>\n</p>\n\n<p align=\"center\">\n  <img src=\"demo.gif\" alt=\"DeepMem quickstart demo\" width=\"720\">\n</p>\n\n---\n\n**Migrate from Mem0 in one line** - same `MemoryClient`, same method signatures:\n\n```python\n# Before - Mem0\nfrom mem0 import MemoryClient\nclient = MemoryClient(api_key=\"m0-...\")\n\n# After - DeepMem (only the import changes)\nfrom deepmem import MemoryClient\nclient = MemoryClient(api_key=\"dm_live-...\")   # get a key at deepmem.dev\n```\n\n```bash\npip install deepmem-client\n```\n\nTurn conversations into searchable long-term memory: a FastAPI HTTP API in\nfront of a Qdrant vector store, with LLM fact extraction, hybrid retrieval\n(vector + BM25 + entity boost + time-decay), semantic caching, async batched\ndistillation, GDPR controls, and a built-in MCP server. It runs in **open\nmode** - no API key, no user registration - so you can deploy it for your own\nagents in minutes. Multi-tenant isolation is driven by `user_id` in the\nrequest body.\n\n> **Prefer not to self-host?** **DeepMem Cloud** is the managed version of\n> this exact engine at **[deepmem.dev](https://deepmem.dev)** - same API, no\n> infra. Sign up, grab a key (`dm_live_...`), point your base URL at\n> `https://deepmem.dev`, done. The cloud and the open-source server speak the\n> same Mem0-compatible API, so client code is identical.\n\n## Migrate from Mem0\n\nAlready using Mem0? Switch to DeepMem cloud in one line. The `deepmem-client`\npackage mirrors `mem0.MemoryClient` - same class name, same method signatures,\nsame `filters={\"user_id\": ...}` style - so everything after the import stays\nuntouched.\n\n```bash\npip install deepmem-client\n```\n\n```python\n# before (Mem0)\nfrom mem0 import MemoryClient\nclient = MemoryClient(api_key=\"m0-...\")\nclient.add(messages, user_id=\"alex\")\nclient.search(\"What can Alex cook?\", filters={\"user_id\": \"alex\"})\n\n# after (DeepMem cloud) - change one import line\nfrom deepmem import MemoryClient\nclient = MemoryClient(api_key=\"dm_live_...\")        # key at https://deepmem.dev\nclient.add(messages, user_id=\"alex\")                # identical calls\nclient.search(\"What can Alex cook?\", filters={\"user_id\": \"alex\"})\n```\n\n<details><summary>Behavioral notes</summary>\n\n- **`add(infer=True)` (the default) is asynchronous on DeepMem cloud** - it\n  returns `pending=True` with `results=[]` and extracted facts land a few\n  seconds later. (Mem0 cloud's `add` is async too - it returns `PENDING`.) Pass\n  `infer=False` for synchronous raw-text storage that's immediately searchable.\n- **No graph relations** - DeepMem uses hybrid vector retrieval (vector + BM25\n  + time-decay), so `relations` is always `[]`. Mem0's graph features aren't\n  replicated.\n- **`reset` differs** - Mem0's is account-wide; DeepMem's is per-`user_id` with\n  a confirm guard.\n\n</details>\n\n## Pricing\n\nDeepMem Cloud is **10x cheaper than Mem0** at every paid tier - the same shape\nof plans, a tenth of the price.\n\n| Tier | DeepMem | Mem0 cloud |\n|---|---|---|\n| Hobby | Free | Free |\n| Starter | **$1.9/mo** | $19/mo |\n| Growth | **$7.9/mo** | $79/mo |\n| Professional | **$24.9/mo** | $249/mo |\n\nSelf-host instead and it's **$0** - you pay only your own LLM/embedding\nprovider (the same LLM cost Mem0 charges on top of its plan price), with no\nmemory-service markup. Batched distillation also cuts LLM calls ~80%, so even\nyour provider bill is smaller than per-message extractors.\n\nPlans and limits: [deepmem.dev](https://deepmem.dev) · [mem0.ai](https://mem0.ai/pricing).\n\n## Benchmarks\n\nNo cherry-picked headline. The scripts and workload ship in\n[`/benchmarks`](benchmarks/README.md) - run them yourself. Here's what we\nmeasured and the exact config that produced it:\n\n| Metric | DeepMem self-hosted ¹ | DeepMem cloud | Mem0 cloud |\n|---|---|---|---|\n| **Search p50** | **73 ms** | **643 ms** | 653 ms |\n| **Search p95** | 86 ms | 811 ms | 710 ms |\n| **Search hits** (40 queries) | - | **195** | 84 |\n| **Add p50** (raw store) | 899 ms ² | 792 ms | 695 ms ³ |\n\n> ¹ BGE-M3 on a GTX 1070 GPU (2016-era), local file Qdrant, `infer=False`,\n> 100 ops, concurrency 1. ² Dominated by local-file Qdrant I/O - a Qdrant\n> server cuts this sharply. ³ Mem0 has no raw-store mode; `add` always runs\n> LLM extraction, so this row isn't apples-to-apples.\n\n- **Self-hosted is where intrinsic latency lives** - no internet RTT, your\n  embedder, your Qdrant. 73 ms p50 search on an old consumer GPU.\n- **DeepMem cloud beats Mem0 cloud on search p50** (643 ms vs 653 ms) and\n  returns **~2.3x more candidates per search** (195 vs 84 hits across 40\n  queries).\n- **Cloud latency is RTT-dominated** - both cloud columns were measured\n  through a proxy from mainland China; run-to-run jitter is ~±10%. Run\n  [`/benchmarks`](benchmarks/README.md) from a low-RTT location for your own\n  numbers.\n\n## Why DeepMem\n\nAgent frameworks keep re-discovering that they need persistent, retrievable\nmemory. The hosted options bill per call and send your data to someone else's\ncloud. DeepMem is the self-hostable alternative: the same Mem0-shaped API you\ncan drop in, but it runs on your box, with your embedder, your LLM key, and\nyour Qdrant - and the code is right here to verify it.\n\n\n**How does DeepMem compare to other Mem0 alternatives?** Most are hosted-only or layer memory on top of someone else's vector DB. DeepMem combines three things at once: it's **self-hostable** (your data stays on your box - $0 beyond your own LLM key), **MCP-native** (Claude Desktop / Cursor read and write memories directly as tools), and **fully open-source** - and the managed cloud runs the exact same engine, so cloud and self-host are one API, not two products.\n\n| Without DeepMem | With DeepMem |\n|---|---|\n| Re-explain who you are and what you're working on every session | The agent recalls identity, projects, and preferences automatically |\n| Lose debugging and research context between sessions | Past root causes, dead ends, and findings are recalled, so work isn't repeated |\n| Manually restate preferences every session | Preferences persist across sessions, agents, and projects |\n| Hosted memory services that bill per call and hold your data | Self-host on your infra, or use the cloud - your call, same API |\n\n### What it is (honestly)\n\n- **Hybrid retrieval, not a knowledge graph.** Search fuses vector similarity,\n  BM25 keyword match, entity boost, and time-decay scoring. There is no\n  temporal graph layer; if that's what you need, look at Zep.\n- **Stores preferences, not code dumps.** Large fenced code blocks are\n  stripped before LLM extraction, so the store fills with durable\n  user/project facts instead of pasted implementations.\n- **BYOK, multi-provider.** Bring your own LLM (OpenAI / Anthropic / any\n  OpenAI-compatible endpoint) and embedding (BGE-M3 / Google / OpenAI-compatible).\n- **MCP-native.** Ships an MCP server so Claude Desktop / Cursor can read and\n  write memories directly.\n\n## Quick start\n\nThree ways to run. All speak the same Mem0-compatible API.\n\n### 1. Cloud (zero ops)\n\n```bash\nexport DEEPMEM_API_KEY=dm_live_...      # from https://deepmem.dev\ncurl https://deepmem.dev/v1/memories \\\n  -H \"Authorization: Bearer $DEEPMEM_API_KEY\" -H \"Content-Type: application/json\" \\\n  -d '{\"messages\":[{\"role\":\"user\",\"content\":\"I am Pat, I live in Lisbon.\"}],\"user_id\":\"pat\",\"infer\":false}'\ncurl https://deepmem.dev/v1/memories/search \\\n  -H \"Authorization: Bearer $DEEPMEM_API_KEY\" -H \"Content-Type: application/json\" \\\n  -d '{\"query\":\"Where does Pat live?\",\"user_id\":\"pat\"}'\n```\n\n### 2. Docker (one command)\n\n```bash\ncp .env.example .env          # add an LLM key\ndocker compose up --build     # DeepMem (HTTP :8000 + MCP :8001) + Qdrant sidecar\ncurl http://localhost:8000/health\n```\n\nOr pull the published image:\n\n```bash\ndocker pull langdeepmem/deepmem:latest\ndocker run -p 8000:8000 -p 8001:8001 -e DEEPSEEK_API_KEY=sk-... langdeepmem/deepmem:latest\n```\n\nThe image exposes **`:8000` (HTTP)** and **`:8001` (MCP)**. The `Dockerfile`\nand `docker-compose.yml` cover the GPU variant (CUDA torch + `BGE_DEVICE=cuda`)\nand BGE-M3 model-download options (HF mirror, proxy, or local mount).\n\n### 3. From source\n\n```bash\ngit clone https://github.com/deepmemteam/deepmem.git && cd deepmem\npip install -r requirements.txt\ncp .env.example .env          # add an LLM key + embedder config\npython server/start.py        # HTTP :8000 + MCP :8001\n```\n\nWrite and search in three lines:\n\n```python\nimport httpx\nhttpx.post(\"http://localhost:8000/v1/memories\",\n    json={\"messages\":[{\"role\":\"user\",\"content\":\"I'm Pat, I live in Lisbon.\"}],\n          \"user_id\":\"pat\"})\nprint(httpx.post(\"http://localhost:8000/v1/memories/search\",\n    json={\"query\":\"Where does Pat live?\",\"user_id\":\"pat\"}).json()[\"results\"])\n```\n\n> `user_id` is optional (defaults to `\"default\"`); send different `user_id`s\n> to isolate end-users. `infer: false` stores raw text immediately\n> (test-friendly); the default `infer: true` queues for LLM fact extraction.\n\n## Feature highlights\n\n**Multi-provider by config, not code.** Both layers switch on env vars:\n\n| Layer | Options | Selector |\n|---|---|---|\n| **LLM** (fact extraction) | OpenAI · Anthropic (native SDK) · any OpenAI-compatible (DeepSeek / vLLM / Ollama / Groq / LM Studio) | `LLM_PROVIDER` + `LLM_API_KEY` / `ANTHROPIC_API_KEY` / `DEEPSEEK_API_KEY` |\n| **Embeddings** | BGE-M3 (local, GPU/CPU) · Google Gemini · any OpenAI-compatible | `EMBEDDING_PROVIDER` + `BGE_M3_PATH` / `GOOGLE_API_KEY` / `OPENAI_API_KEY` |\n\n`BGE_DEVICE=auto|cpu|cuda` picks GPU when available, else CPU (force `cpu`\non small-VRAM cards to avoid multi-process contention). BYOK overrides the\nLLM per-request.\n\n**Hybrid retrieval.** Vector similarity + BM25 keyword + entity boost +\ntime-decay, fused into one score. Over-fetch, re-rank, return.\n\n**Async batched distillation.** Writes queue behind a silence window and are\nextracted in batches - ~80% fewer LLM calls than per-message extraction.\n\n**Semantic cache.** Repeat adds/searches hit a similarity-gated cache and\nreturn cached facts without re-embedding or re-querying Qdrant.\n\n**Stores preferences, not code.** `extraction_filter` strips large fenced\ncode blocks before LLM extraction, so the store fills with durable facts,\nnot pasted implementations.\n\n**MCP server.** `deepmem_write` / `deepmem_search` / `deepmem_delete` tools\nfor Claude Desktop, Cursor, and any MCP client.\n\n**GDPR.** Soft-delete with retention window, hard-delete `reset`, SHA-256\nid masking in logs, export/import for portability.\n\n## API\n\n| Method | Path | Description |\n|--------|------|-------------|\n| POST | `/v1/memories` | Write messages; LLM-extract facts (`infer=false` stores raw) |\n| POST | `/v1/memories/search` | Semantic search (vector + BM25 + entity + time-decay) |\n| GET | `/v1/memories` | List all for a `user_id` (paginated) |\n| GET | `/v1/memories/{id}` | Get one by ID |\n| PUT | `/v1/memories/{id}` | Update one memory's text |\n| DELETE | `/v1/memories/{id}` | Soft-delete one |\n| DELETE | `/v1/memories` | Soft-delete all for a `user_id` (GDPR) |\n| GET | `/v1/memories/{id}/history` | ADD/UPDATE/DELETE audit log |\n| POST | `/v1/reset` | Hard-delete all + history (needs `confirm_user_id`) |\n| GET | `/v1/export` · POST `/v1/import` | Portable JSON export / import |\n| GET | `/health` · `/ready` | Liveness / readiness probes |\n\n`agent_id` / `run_id` optionally scope writes/reads (mirrors Mem0's three-level\nisolation: user -> agent -> run). Interactive docs at `/docs`.\n\n### MCP integration\n\nThe cloud exposes a remote MCP endpoint (streamable HTTP):\n\n```\nURL:    https://deepmem.dev/mcp\nAuth:   Authorization: Bearer dm_live_...   (your deepmem.dev API key)\nTools:  deepmem_write / deepmem_search\n```\n\nWorks with Claude Code, Claude Desktop, Cursor, and any MCP-compatible client.\n\n**Claude Code** - one command:\n\n```bash\nclaude mcp add --transport http deepmem https://deepmem.dev/mcp \\\n  --header \"Authorization: Bearer dm_live_...\"\n```\n\nOr install the plugin (bundles a `/deepmem:setup` command that guides API-key\nconfiguration):\n\n```\n/plugin marketplace add deepmemteam/deepmem-claude-plugin\n/plugin install deepmem@deepmem\n```\n\n**Cursor** → Settings → MCP → Add new MCP server, or edit\n`~/.cursor/mcp.json` (global) / `.cursor/mcp.json` (per project). Cursor\nresolves `${env:NAME}` variables in `url` and `headers`, so the key can live\nin an environment variable instead of the config file:\n\n```json\n{\n  \"mcpServers\": {\n    \"deepmem\": {\n      \"url\": \"https://deepmem.dev/mcp\",\n      \"headers\": { \"Authorization\": \"Bearer ${env:DEEPMEM_API_KEY}\" }\n    }\n  }\n}\n```\n\n(with `DEEPMEM_API_KEY=dm_live_...` exported in your shell, or paste the\nliteral key if you prefer). Community MCP listings with one-click \"Add to\nCursor\" live on [cursor.directory](https://cursor.directory); official\nplugins ship in the Cursor Marketplace.\n\n**DeepSeek Harness (dsh)** - one overlay file, no dsh plugin needed (dsh\nconnects any MCP server through its generic `dsh-mcp-client` bridge):\n\n```sh\nexport DEEPMEM_API_KEY=dm_live_...\ndsh web --patch \"$PWD/examples/dsh/deepmem.cordis.yml\"\n```\n\nSee [examples/dsh](examples/dsh/README.md) for details and self-hosted\nvariants.\n\n**Self-hosted** (stdio, bundled server, no key needed in open mode):\n\n```json\n{\n  \"mcpServers\": {\n    \"deepmem\": {\n      \"command\": \"python\",\n      \"args\": [\"server/mcp_server.py\"],\n      \"env\": { \"DEEPMEMORY_BASE_URL\": \"http://localhost:8000\" }\n    }\n  }\n}\n```\n\nThis repo ships a [.cursor/mcp.json](.cursor/mcp.json) preconfigured for the\nself-hosted server - open the repo in Cursor and enable it under Settings → MCP.\n\n## Architecture\n\n```\nclient (HTTP / MCP)\n  -> FastAPI (:8000)\n       -> rate-limit middleware (per-IP token bucket on add/search)\n       -> SemanticCache.check            (return cached facts on similarity hit)\n       -> AsyncBatchDistiller.enqueue    (POST /v1/memories, infer=true)\n            ↳ silence-window or max_batch triggers on_batch_ready\n                ↳ VectorStore.process_batch  (LLM extraction -> Qdrant upsert)\n       -> VectorStore.search             (vector + BM25 + entity + time-decay)\n  -> LLM: OpenAI / Anthropic / OpenAI-compatible (fact extraction)\n  -> BGE-M3 / Gemini / OpenAI-compatible (embeddings)\n  -> Qdrant (vectors)  +  SQLite (audit history)\n  -> MCP server (:8001)  deepmem_write / deepmem_search / deepmem_delete\n```\n\nSingle Qdrant collection (`memories`), hard-filtered by `user_id` payload.\n`TenantValidator` NFC-normalizes and enforces a `[A-Za-z0-9._:-]{1,256}`\ncharset on `user_id` - never trust the raw request value.\n\n## Configuration\n\nConfig loads once from env vars (`.env`, auto-loaded) > `config.json` > defaults.\nKey variables:\n\n| Variable | Required | Description |\n|----------|----------|-------------|\n| `DEEPSEEK_API_KEY` / `LLM_API_KEY` / `ANTHROPIC_API_KEY` | one LLM key | LLM for fact extraction |\n| `LLM_PROVIDER` | no | `auto` / `openai` / `anthropic` / `openai_compatible` (default `auto`) |\n| `EMBEDDING_PROVIDER` | no | `bge-m3` / `google` / `openai` (default `bge-m3`) |\n| `BGE_M3_PATH` | no | local BGE-M3 dir or HF model id (default `BAAI/bge-m3`) |\n| `BGE_DEVICE` | no | `auto` / `cpu` / `cuda` (default `auto`) |\n| `QDRANT_URL` / `QDRANT_API_KEY` | no | remote Qdrant; omit for local file store |\n| `CORS_ORIGINS` | yes | comma-separated allowed origins (no `*` in prod) |\n| `RATE_LIMIT_ADD` / `RATE_LIMIT_SEARCH` | no | per-minute limits (default 30 / 60) |\n\nBackends auto-switch on env vars - no code changes:\n- `QDRANT_URL` set -> remote Qdrant; unset -> local file Qdrant under `./data/qdrant`.\n- `CORS_ORIGINS=*` is refused at boot unless `DEEPMEMORY_DEBUG=1`.\n\n### Production (systemd)\n\n```bash\nsystemctl restart deepmem.service     # scripts/start.sh -> uvicorn :8000\njournalctl -u deepmem -f\n```\n\nFor HTTPS, put Caddy or Nginx in front; `scripts/start.sh` runs under systemd\nor any process manager.\n\n## Benchmarks\n\nTwo reproducible scripts in [`/benchmarks`](benchmarks/README.md):\n\n- **Cloud vs cloud** - DeepMem cloud vs Mem0 cloud. Register keys at\n  [deepmem.dev](https://deepmem.dev) + [mem0.ai](https://mem0.ai), then\n  `python benchmarks/benchmark_cloud.py`.\n- **Self-hosted** - your DeepMem, your hardware (no key, no external service):\n  `python benchmarks/run_benchmark.py`.\n\nBoth ship a self-contained workload and report P50/P95/P99 + throughput. The\nnumbers at the top of this README were produced with these scripts - rerun\nthem and read your own percentiles.\n\n## FAQ\n\n**Do I need the cloud?** No. The open-source server is fully functional on its\nown. The cloud ([deepmem.dev](https://deepmem.dev)) is the zero-ops option -\nsame API.\n\n**Does it work offline?** Retrieval and raw-store (`infer=false`) work with no\nnetwork. LLM fact extraction (`infer=true`) needs an LLM key - or run a local\nOpenAI-compatible model (Ollama / vLLM / LM Studio) and point `LLM_BASE_URL`\nat it.\n\n**Where is my data?** In your Qdrant (local file or server) + a SQLite audit\nlog. Nothing leaves your machine except the LLM/embedding calls you configure.\n\n**Multi-tenant?** Yes - single Qdrant collection hard-filtered by `user_id`.\n`agent_id` / `run_id` add agent and session scope.\n\n**Is it production-ready?** Used in production under systemd with a remote\nQdrant. Local file Qdrant is fine for dev/single-worker; use a Qdrant server\nfor multi-worker or high-throughput.\n\n## Development\n\n```bash\npip install -r requirements.txt\nDEEPMEMORY_DEBUG=1 python -m uvicorn server.main:app --reload --host 0.0.0.0 --port 8000\npytest tests/ -x -v\n```\n\n## License\n\n[MIT](LICENSE).\n",
  "bytes": 18463,
  "sha": "f79b0c96e5339f8c79ec7de47147d483c62dee65515836fef72c9f91463418cb",
  "repo_slug": "deepmemteam/deepmem",
  "fonte": "repo",
  "truncated": false,
  "api": "https://agentalog.com/api/listings/mcp_io_github_deepmemteam_deepmem_90901e90/readme"
}