基本能力
产品定位
mcp-memory-domain-knowledge 是一个知识图谱记忆服务器,用于实现AI模型的持久化记忆功能。
核心功能
- 实体管理:创建、删除和查询知识图谱中的实体
- 关系管理:建立、删除实体间的关联关系
- 观察管理:添加、删除和查询实体的观察信息
- 图谱搜索:支持关键词搜索和特定节点查询
- 持久化存储:支持将记忆数据保存到本地JSON文件
适用场景
- AI聊天机器人的个性化记忆
- 跨会话的用户信息管理
- 知识图谱构建和维护
- 信息检索和关联查询
工具列表
- create_entities:创建多个新实体
- create_relations:创建实体间关系
- add_observations:为实体添加观察信息
- delete_entities:删除实体及其关联关系
- delete_observations:删除特定观察信息
- delete_relations:删除特定关系
- read_graph:读取整个知识图谱
- search_nodes:基于关键词搜索节点
- open_nodes:按名称检索特定节点
常见问题解答
- 如何配置存储路径:通过设置
MEMORY_FILE_PATH
环境变量指定 - 如何处理重复实体:创建时会自动忽略已存在的实体
- 搜索是否区分大小写:搜索是大小写不敏感的
- 如何更新记忆:通过
add_observations
和create_relations
等工具
使用教程
使用依赖
- 安装Docker或Node.js环境
安装教程
Docker方式
json
{
"mcpServers": {
"memory": {
"command": "docker",
"args": ["run", "-i", "--rm", "mcp/memory"]
}
}
}
NPX方式
json
{
"mcpServers": {
"memory": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-memory"
]
}
}
}
自定义配置
json
{
"mcpServers": {
"memory": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-memory"
],
"env": {
"MEMORY_FILE_PATH": "/path/to/custom/memory.json"
}
}
}
}
调试方式
- 构建Docker镜像
sh
docker build -t mcp/memory -f src/memory/Dockerfile . - 检查日志输出
- 验证记忆文件是否生成
系统提示示例
```
Follow these steps for each interaction:
- User Identification:
- You should assume that you are interacting with default_user
-
If you have not identified default_user, proactively try to do so.
-
Memory Retrieval:
- Always begin your chat by saying only "Remembering..." and retrieve all relevant information from your knowledge graph
- Always refer to your knowledge graph as your "memory"
- When searching your memory, you can use multiple keywords to find related information
-
Example searches:
- Single concept: "programming"
- Related concepts: "programming python"
- Specific domain with role: "work engineer"
-
Memory Creation:
- While conversing with the user, be attentive to any new information that falls into these categories:
a) Basic Identity (age, gender, location, job title, education level, etc.)
b) Behaviors (interests, habits, etc.)
c) Preferences (communication style, preferred language, etc.)
d) Goals (goals, targets, aspirations, etc.)
e) Relationships (personal and professional relationships up to 3 degrees of separation) -
When storing information, use specific and descriptive keywords that will help in future searches
-
Memory Update:
- If any new information was gathered during the interaction, update your memory as follows:
a) Create entities for recurring organizations, people, and significant events
b) Connect them to the current entities using relations
c) Store facts about them as observations
d) Use clear and searchable terms in entity names and observations to facilitate future retrieval
```