mnemosyne-mcp
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., "@mnemosyne-mcpRemember that I prefer Python for data tasks and dislike JavaScript"
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.
mnemosyne-mcp
AI Agent 记忆管理 MCP Server — 分层记忆 · 时间衰减 · 关键词检索 · 知识图谱
为 Claude Desktop / Cursor / Windsurf 等 MCP 客户端提供结构化记忆能力。基于 Mnemosyne 架构设计,走本地优先、SQLite + 知识图谱路线。
记忆层级: session (会话级) → global (全局共享),经 sleep() 归档
检索: hybrid 评分 (BM25 词频 + 重要性 + 可选时间衰减)
图谱: subject-predicate-object 三元组 + 多跳 BFS
归档: sleep() 把低重要性 session 记忆提升为 global/episodic说明:当前实现是两级 scope(session / global),不是三���记忆。 检索是纯 BM25 + 加权,未接入向量嵌入(
embeddings附加依赖为 规划中能力)。详见 ROADMAP.md。
与 mem0 的差异
特性 | mem0 | mnemosyne-mcp |
存储 | 需 Qdrant / PGVector | 纯 SQLite,零外部服务 |
检索 | embedding API | 纯 BM25 + 重要性 + 时间衰减(无向量库依赖) |
知识图谱 | 实体链接 | 三元组 + 时序 + 多跳 BFS |
部署 | 需 Docker / 服务端 | 单文件 |
数据所有权 | 云端可选 | 本地 SQLite 文件,100% 可控 |
Related MCP server: Engram-Mem
快速开始
# 安装
pip install mnemosyne-mcp
# 初始化记忆库
mnemosyne-mcp init --path ~/.mnemosyne/data
# 启动 MCP Server (stdio)
mnemosyne-mcp serve
# 或 SSE 模式(本地回环)
mnemosyne-mcp serve --transport sse --port 8080Claude Desktop 配置
{
"mcpServers": {
"mnemosyne": {
"command": "mnemosyne-mcp",
"args": ["serve"]
}
}
}核心 API
记忆操作
工具 | 说明 |
| 写入记忆(user/feedback/project/reference,支持 importance / temporal_halflife) |
| 关键词检索(BM25 + 重要性 + 可选时间衰减加权) |
| 按 ID 精确读取 |
| 更新已有记忆 |
| 按 ID 删除 |
| 标记过期/被取代 |
| 多方验证(attest / update / invalidate / delete) |
知识图谱
工具 | 说明 |
| 写入三元组 (subject, predicate, object) |
| 图谱查询(支持 as_of 历史回溯) |
| 过期三元组(不删除,保留审计链路) |
| 显式声明记忆间的语义边 |
| 多跳 BFS 遍历(max_hops / min_weight) |
记忆管理
工具 | 说明 |
| 运行 consolidate 周期(旧 working → episodic 摘要) |
| 临时便签(进程级,不持久化) |
| 读取临时便签 |
| 清空临时便签 |
| 审计噪声(terminal spam / secret / stack trace) |
| 清理噪声(delete / archive / flag) |
| 记忆库统计(working / episodic / triples / graph_edges) |
| 从远程同步服务器拉取记忆 ⚠️ 占位实现 |
| 推送本地记忆到远程 ⚠️ 占位实现 |
工具总数 21。其中
mnemosyne_sync_pull/mnemosyne_sync_push目前是占位实现(直接返回提示信息,不做实际同步)—— 远程同步服务端尚未提供,见 ROADMAP.md。
批量操作
from mnemosyne_mcp import MnemosyneClient
client = MnemosyneClient(path="~/.mnemosyne/data/mnemosyne.db")
# 批量写入 —— 单个事务,全有或全无
results = client.batch([
{"action": "remember", "content": "用户偏好 Python", "scope": "global", "importance": 0.9},
{"action": "triple_add", "subject": "user", "predicate": "prefers", "object": "Python"},
{"action": "graph_link", "source_id": "...", "target_id": "...", "relationship": "references"},
])支持的 action:remember / triple_add / graph_link / update / forget。
原子性:任一条操作失败,整批回滚并抛出异常,不会留下半截数据。 半截导入比完全失败更难收拾 —— 这正是批量场景下最需要的行为。
Python 直接使用(无需 MCP)
from mnemosyne_mcp import MnemosyneClient
client = MnemosyneClient(path="./my_memory.db")
# 写入
mem_id = client.remember(
content="用户喜欢简洁的代码风格",
memory_type="user",
scope="global",
importance=0.8,
)
# 检索
results = client.recall("代码风格偏好", limit=5)
# 知识图谱
client.triple_add("user", "prefers", "Python", confidence=1.0)
graph = client.graph_query(seed_id=mem_id, max_hops=2)
# 记忆归档
client.sleep(force=True)💡
mnemosyne_mcp.client保留为兼容别名(0.2.0 起实现合并进mnemosyne_mcp.core),旧代码from mnemosyne_mcp.client import MnemosyneClient仍可正常工作。新代码请直接from mnemosyne_mcp import MnemosyneClient。
架构
mnemosyne-mcp/
├── src/mnemosyne_mcp/
│ ├── __init__.py # 公共 API 导出
│ ├── core.py # 客户端 + MCP Server + 工具路由(0.2.0 起合并)
│ └── client.py # 兼容别名模块(转发到 core)
├── tests/
│ ├── conftest.py
│ ├── test_client.py
│ └── test_tools.py
├── examples/
│ ├── basic_usage.py
│ └── knowledge_graph.py
└── .github/
├── workflows/ci.yml
└── ISSUE_TEMPLATE/依赖: mcp >= 1.0.0(协议层)+ Python 标准库 sqlite3
全部存储与检索基于 Python 标准库 sqlite3,不依赖任何向量数据库。 可选的
embeddings/sse/sqlite-vec附加依赖按需安装:pip install "mnemosyne-mcp[sse]"
数据安全
所有记忆存储在本地 SQLite 文件,不上传任何云端
支持
MNEMOSYNE_DATA_DIR环境变量自定义存储路径SSE 模式默认绑定 loopback,LAN 暴露必须设置
MNEMOSYNE_MCP_TOKENmnemosyne_hygiene_clean默认是 dry-run,必须显式confirm=True才会真删
⚠️ 记忆库是明文 SQLite 文件,不含加密。存放敏感信息前请自行 使用加密卷或文件系统权限保护,详见 SECURITY.md。
License
Apache-2.0
This server cannot be deployed
Maintenance
Related MCP Connectors
Persistent memory, knowledge graph, task management and more for AI agents via MCP.
Persistent memory for AI agents to retain, retrieve, and recall conversation context through MCP.
Persistent, portable memory for AI assistants — your private memory graph, from any MCP client.
Persistent personal memory for AI assistants — save, search, and recall across every MCP client.
Related MCP Servers
- AlicenseCqualityAmaintenanceProvides persistent, local-first AI memory across sessions via MCP tools for storing, searching, and retrieving context from past interactions.31786 PyPI1MIT
- AlicenseNot gradedqualityCmaintenanceEnables persistent memory for AI agents, combining episodic and semantic memory with LLM reasoning, accessible via MCP.2MIT
- AlicenseAqualityAmaintenanceProvides persistent, graph-based memory for AI agents via MCP, enabling semantic search, wikilink traversal, reminders, and injection protection.934Apache 2.0
- AlicenseCqualityAmaintenanceProvides AI agents with a human-inspired memory layer via MCP, enabling episodic and semantic memory recall, forgetting curves, consolidation, and contradiction detection. It integrates with MCP clients to offer local-first, dependency-free memory management.981MIT