mem0-mcp
MCP server wrapping a self-hosted mem0 REST API, enabling memory management with deduplication and mention-aware reranked search.
README
mem0-mcp
An MCP server wrapping a self-hosted mem0 REST API, adding two things mem0 doesn't do on its own:
- Exact-content dedupe — identical adds within a time window are skipped before they reach mem0, saving an LLM extraction call per duplicate.
- Mention-aware retrieval reranking — memories that get reconfirmed over time rank higher than a pure similarity search would put them, without needing any extra calls to mem0 itself.
why reranking
mem0's default search ranks purely on embedding similarity. That's fine at low memory counts, but once you're into the hundreds, a fact that's been independently reconfirmed many times (e.g. "user prefers X") and a fact mentioned once in passing score identically if they're similarly worded. This adds a second signal: how often has this memory actually been reinforced, and how recently.
How it works:
-
add_memoryfirst runs a similarity search for the new content against existing memories. A candidate scoring aboveREINFORCEMENT_PREFILTER_THRESHOLDisn't bumped directly — similarity score alone isn't precise enough (tested live: a genuine paraphrase scored 0.833 against its true target, while a separately-worded, topically-adjacent query scored 0.836 against a different, unrelated memory — both land in the same narrow band, so no single threshold cleanly separates a real match from a false one, since short facts sharing a subject/domain cluster tightly in embedding space regardless of whether they're really "the same" fact). Instead the judge LLM (JUDGE_LLM_BASE_URL) is asked directly whether the new content restates the candidate as the same fact; only a yes bumps its mention count (debounced to at most once per memory per window, so a single conversation re-mentioning the same fact several times doesn't inflate the count). LeavingJUDGE_LLM_BASE_URLunset disables this entirely rather than falling back to an unreliable threshold guess. Only after this doesadd_memorycall mem0's own/memoriesendpoint to actually store the content — this detects reinforcement itself rather than relying on mem0's response to signal it, since in practice mem0's/memoriesresponse doesn't reliably surface it: near-duplicate content it classifies as "no update needed" is silently omitted from the response entirely (no event, no id), and a genuineUPDATEevent only fires for a narrow same-memory-text-update judgment call that's rare in normal use. -
search_memoriesover-fetches candidates from mem0's similarity search, then rescales each by:score = similarity × (1 + α · log(1 + mentions)) × recency recency = 0.5 + 0.5 · exp(-days_since_update / halflife)Recency has a 0.5 floor so old memories never fully vanish, just get deprioritized. All of this happens locally against a small SQLite table — no extra round-trips to mem0.
Mention counts are stored locally (SQLite, not in mem0's own metadata), which means they're only visible to whatever's calling through this MCP server — other clients hitting mem0 directly won't see or benefit from them. That's a deliberate tradeoff: writing mention counts back into mem0's own metadata would require a read-modify-write on every reinforcement (mem0's update endpoint needs the full text), which is a lot of extra complexity and API calls for a signal that's only used by this reranking step anyway.
tools exposed
| tool | description |
|---|---|
add_memory(content) |
Store a memory (deduped) |
search_memories(query) |
Semantic search, reranked |
get_all_memories() |
List everything stored |
update_memory(memory_id, content) |
Replace a memory's text |
delete_memory(memory_id) |
Delete a memory |
compatibility
Tested against a self-hosted mem0 server built from mem0ai 2.0.6. The reinforcement-detection approach (see above) deliberately doesn't depend on the event field mem0's /memories response returns, so it isn't tied to a specific mem0 version — it only needs the standard /memories and /search endpoints, which have been stable across mem0's 2.x releases including the newer ADD-only consolidation model (2.0.15+, where /memories always returns event: "ADD" and never UPDATE/NONE).
setup
Requires a running mem0 REST API server (see mem0ai/mem0 or your own deployment) reachable from this container.
cp .env.example .env
# fill in MEM0_URL and MEM0_USER_ID at minimum
docker compose up -d
Transport is streamable-http by default, listening on :8001. Set MCP_TRANSPORT=stdio for stdio instead.
All tuning knobs (dedupe window, mention debounce, reranking weights) are environment-overridable — see .env.example — no rebuild required to change them.
license
MIT
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。