openmem
This server exposes OpenMem's unified memory hub over MCP for storing, maintaining, searching, and querying shared AI-agent memory.
Write memory: add knowledge or memories with source, layer, category, tags, confidence, and pinned status via
mh_write.Update memory in place: edit content/metadata by UUID without breaking references via
mh_update.Search memory: hybrid vector + metadata retrieval with filters for layer, category, source, tags, date, archived items, and result count via
mh_search.Fetch exact entries: retrieve a full memory item by UUID via
mh_get.Look up services: query the local nssm service ledger by name or list all service names via
mh_service.Ask synthesized questions: get AI-generated, cited answers based on all memories via
mh_ask.Use preset answers: list and call pre-generated cached answers for standard questions via
mh_tools_listandmh_tool.Check health/statistics: view counts, pinned/archived items, pending conflicts, tool count, and consultation count via
mh_status.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@openmem search my memories for lessons about PostgreSQL connection timeouts"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
openmem
个人多 Agent 的统一记忆中枢:一个 PostgreSQL 库,一处写、全体读。
其他 AI 通过 MCP 接入;人通过 Web 控制台检索、问答、治理记忆。
它解决什么
问题 | openmem 的做法 |
记忆散落在多个 agent / 文件 | 统一进 |
标准问题每个 bot 都重推一遍 |
|
需要「像问本人一样」的综合回答 |
|
Related MCP server: Cerefox
架构
MCP clients (Claude / Codex / bots / …)
│
▼
server.js ──spawn──► mem_core.py ──► PostgreSQL (openmem)
:3466 MCP │
├── Embeddings API(OpenAI 兼容)
└── Chat LLM API(OpenAI 兼容)
web_server.py :3467 ────────┘
(Web 控制台,复用同一内核)server.js:MCP 层(stdio / Streamable HTTP),工具转发到 Python 内核mem_core.py:业务内核 + CLI(写入、混合检索、咨询、预设工具、导入)web_server.py+web_page.html:Web 控制台cred_guard.py:写库前打码(防明文密钥进记忆)
数据表
表 | 用途 |
| 记忆正文 + embedding + pinned / superseded 链 |
| 治理待审冲突 |
| 预生成答案(prompt + 缓存 + 保鲜周期) |
| 咨询日志与引用 |
| 运行配置(persona / 模型 / key 等,覆盖环境变量默认值) |
建库:
createdb openmem
psql openmem -f schema.sql快速开始
1. 依赖
Node.js 18+
Python 3.10+:
psycopg2-binary、requests(见requirements.txt)PostgreSQL 14+
OpenAI 兼容的 embeddings 与 chat 端点
npm install # @modelcontextprotocol/sdk + zod(若未提供 package.json,按需安装)
python -m pip install -r requirements.txt2. 配置
cp .env.example .env
# 编辑 .env:PG、LLM、embedding 等进程启动时会自动读项目根目录的 .env(不要提交)。
可选本地文件(均 gitignore):
文件 | 用途 |
|
|
| 短口令精确替换表(公开仓 |
3. 启动
# MCP over HTTP
node server.js --http 3466
# MCP over stdio
node server.js
# Web 控制台
python web_server.py --port 3467MCP 接入
HTTP:
{ "mcpServers": { "openmem": { "url": "http://127.0.0.1:3466/mcp" } } }stdio:
{ "mcpServers": { "openmem": { "command": "node", "args": ["./server.js"] } } }MCP 工具
工具 | 作用 |
| 写入记忆( |
| 按 id 原地更新(保留 id,重算向量) |
| 混合检索(向量 + 元数据过滤) |
| 按 id 取单条 |
| 服务台账按名查询(若已导入 agent-matrix) |
| AI 对 AI 咨询,答案带 |
| 预生成答案(秒回) |
| 健康与统计 |
建议优先级:标准问题 → mh_tool → 需要原始片段 → mh_search → 需要综合口吻 → mh_ask。
写入示例:
mh_write(content="…结论/坑…", source="<agent名>", layer="m",
category="lessons", tags=["…"], confidence=0.8)Web 控制台
默认 https://127.0.0.1:3467(无鉴权,勿对公网裸奔;2026-10-22 起单栈 https,证书 C:\D\opt\certs\localhost\,缺证书自动回落 http;curl 测试加 --ssl-no-revoke)。
页签 | 能力 |
检索 | 语义检索 + 高亮,可编辑/删除 |
浏览 | 分页 + 分类/来源过滤 |
问问 | 流式问答、引用卡片、历史 |
预设工具 | 查看/刷新缓存答案 |
入职包 | 导出新 agent 需要的钉住事实与工具清单 |
AI 设置 | 提示词 / 模型 / key(写入 |
主要 API:/api/stats /api/search /api/browse /api/ask_stream /api/tools /api/config /api/health 等。
CLI(不经 MCP)
python mem_core.py write --content "..." --source me --layer m --category lessons
python mem_core.py search --query "..." --top_k 5
python mem_core.py ask --query "..." --agent mybot
python mem_core.py status辅助脚本
文件 | 用途 |
| 从本地 markdown 目录批量导入(路径请按环境改) |
| 服务总表目录指纹同步导入 |
| 命令行调用 MCP 工具 |
| 一次性审计/聚类辅助 |
配置优先级
对 AI 问答相关项(模型、key、persona 等):
数据库 app_config > 环境变量 / .env > 代码默认值安全
密钥只放
.env或服务环境变量,不要写进源码或提交 gitcred_guard是写入时的尽力打码,不能替代密钥治理Web / MCP 默认无鉴权:本机或反向代理 + 认证后再暴露
License
按你的仓库选择(例如 MIT)。
Available Tools
9 toolsmh_askA
AI 对 AI 咨询:像直接问老大陈丹本人一样提问,openmem 基于全部记忆给出完整、准确、口语化的答案(走 litellm GwV4F,数秒级,较慢)。只在 mh_tool 里没有对应成品答案、且问题需要理解+综合时才用:要标准答案走 mh_tool(秒回),要原始记忆片段走 mh_search(更快)。
Inputs: query (required), agent.
mh_getA
按 id 取单条记忆完整内容。
Inputs: id (required).
mh_searchA
检索老大的统一记忆,返回原始条目(适合查历史细节、具体事件、某个坑的完整经过)。混合检索:向量语义 + 元数据过滤(layer/category/source/tags/时间)。⚠️ 但「老大是什么人 / 什么偏好 / 本机环境 / 服务与端口 / 某项目怎么改」这类标准问题请先试 mh_tools_list → mh_tool(成品答案,秒回、后台已保鲜),不要直接搜、更不要猜。注意:nssm 服务台账(agent-matrix/services)默认不返回,要查某服务的启动参数/端口用 source="agent-matrix" 显式指定。
Inputs: query (required), tags, layer, since, +4 more.
mh_serviceA
查本机 nssm 服务台账:按服务名返回该服务的启动参数/端口/路径等配置明细(不走语义检索,按名精确匹配)。不知道确切名字就先不传 name,会列出全部服务名。
Inputs: name.
mh_statusB
openmem 健康状态:总条数/钉住数/归档数/待审冲突/工具数/咨询次数。
Inputs: no named parameters.
mh_toolA
【首选 · 秒回】调用预生成答案工具:标准化提示词 + 后台已备好最新最准的答案,不走 LLM、几乎零等待。凡「老大是什么人 / 偏好习惯 / 铁律清单 / 本机环境 / 服务与端口 / 12 bot 花名册 / 项目索引 / openmem 使用手册」这类标准问题一律先用这个,别用 mh_search 现搜、更别凭印象猜。不知道有哪些成品答案就先调 mh_tools_list(一次看清全部 + 新鲜度)。
Inputs: name (required), force_refresh.
mh_tools_listB
列出全部预生成答案工具及答案新鲜度。
Inputs: no named parameters.
mh_updateA
按 id 原地更新一条记忆(改错字、补内容、转 pinned、换 category 都用这个)。只改传了的字段,未传的保持不动;改了 content 会自动重算向量与 hash。保留 id,不打断 superseded_by / 冲突记录引用链——优于"删了重写"。改内容前建议先 mh_get 看一眼原文。
Inputs: id (required), tags, layer, pinned, +4 more.
mh_writeC
写入一条记忆/知识到老大的统一记忆中枢(openmem)。source 必填=写入方 agent 名。layer: k=知识 m=记忆。category: rules/facts/projects/lessons/knowledge/archive/verification/services/capabilities/misc(或项目名如 dsh / agents-to-feishu)。重要结论不写入=任务不算完成。
Inputs: source (required), content (required), tags, layer, +3 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 9 tools
The tools have distinct purposes, and the descriptions explicitly separate raw memory search (mh_search), synthesized answers (mh_ask), and pre-generated answers (mh_tool). Some risk remains because these three query-ish tools overlap in intent, but the guardrails in the descriptions are strong enough to guide selection.
All tool names use the consistent lowercase mh_ prefix and mostly follow a verb-based pattern like write, update, search, get, ask, and status. The noun-style exceptions mh_service, mh_tool, and mh_tools_list are minor deviations, and tools_list also reverses the expected order slightly.
Nine tools is well-scoped for a memory hub: core memory operations (write/get/search/update), specialized lookups (service/tool), and meta/status tools are all represented. Each tool has a clear role and none feel redundant.
The surface covers create, read, update, query, status, and specialized lookup workflows well. There is no explicit delete or conflict-resolution tool even though mh_status surfaces pending conflicts, but this may be intentional and can be worked around via archive/update and category changes.
Maintenance
Related MCP Connectors
Shared cross-LLM long-term memory over MCP: semantic recall, sessions, and media (pgvector).
Analytical memory for AI agents: a real Postgres queried in plain English over MCP. One command.
Persistent memory, knowledge graph, task management and more for AI agents via MCP.
Hosted memory for AI agents over MCP. One memory shared by all your agents.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to store, retrieve, and manage contextual knowledge across sessions using semantic search with PostgreSQL and vector embeddings. Supports memory relationships, clustering, multi-agent isolation, and intelligent caching for persistent conversational context.62 npm50MIT
- AlicenseNot gradedqualityAmaintenanceUser-owned shared memory for AI agents, providing a persistent, curated knowledge layer with hybrid search and cross-agent coordination via Postgres + pgvector.19Apache 2.0
- AlicenseNot gradedqualityDmaintenancePersistent, semantically-searchable memory for AI agents using local PostgreSQL, pgvector, and Ollama embeddings, exposed via MCP with hybrid retrieval, knowledge graph, and auto-recall hook.2 npmMIT

HAMofficial
AlicenseNot gradedqualityCmaintenanceProvides persistent, scoped shared memory for collaborating AI agents, with tools for storing observations, semantic recall, and handoff workflows. Backed by PostgreSQL and exposed through MCP.1Apache 2.0