知识图谱内存服务器是一款用于管理和存储知识图谱数据的工具。它能助力模型(如Claude)更好地理解和记忆与用户相关的交互信息。本文档将详细介绍该服务器的功能、使用方法及相关配置。
若想使用知识图谱内存服务器,您需要进行配置文件设置和Smithery安装,具体步骤如下:
在mcp.json或claude_desktop_config.json中添加以下配置:
{
"mcpServers": {
"memory": {
"command": "npx",
"args": [
"-y",
"@itseasy21/mcp-knowledge-graph"
],
"env": {
"MEMORY_FILE_PATH": "/path/to/your/projects.jsonl"
}
}
}
}
通过Smithery平台自动安装:
npx -y @smithery/cli install @itseasy21/mcp-knowledge-graph --client claude
实体是知识图谱中的基本单元,代表具有独立存在意义的人、事物或概念。每个实体包含以下属性:
关系表示两个或多个实体之间的关联。例如:
{
"subject": "张三",
"predicate": "工作于",
"object": "谷歌公司"
}
观察结果是对实体特征的记录,通常以时间戳为索引存储。例如:
{
"entity_id": "12345",
"timestamp": "2023-10-01T12:00:00Z",
"facts": [
{
"key": "年龄",
"value": "30"
},
{
"key": "职业",
"value": "软件工程师"
}
]
}
在mcp.json或claude_desktop_config.json中添加以下配置:
{
"mcpServers": {
"memory": {
"command": "npx",
"args": [
"-y",
"@itseasy21/mcp-knowledge-graph"
],
"env": {
"MEMORY_FILE_PATH": "/path/to/your/projects.jsonl"
}
}
}
}
通过Smithery平台自动安装:
npx -y @smithery/cli install @itseasy21/mcp-knowledge-graph --client claude
POST /entities
{
"entities": [
{
"id": "12345",
"type": "人",
"attributes": {
"name": "张三",
"age": "30"
}
},
{
"id": "67890",
"type": "公司",
"attributes": {
"name": "谷歌公司",
"location": "美国"
}
}
]
}
POST /relations
{
"relation": {
"subject": "张三",
"predicate": "工作于",
"object": "谷歌公司"
}
}
您可以通过以下两种方式指定自定义记忆文件路径:
{
"mcpServers": {
"memory": {
"command": "npx",
"args": ["-y", "@itseasy21/mcp-knowledge-graph", "--memory-path", "/path/to/your/memory.jsonl"]
}
}
}
{
"mcpServers": {
"memory": {
"command": "npx",
"args": ["-y", "@itseasy21/mcp-knowledge-graph"],
"env": {
"MEMORY_FILE_PATH": "/path/to/your/memory.jsonl"
}
}
}
}
如果未指定路径,默认使用memory.jsonl文件。
根据具体应用场景,您可以调整以下系统提示以指导模型如何管理记忆:
作为记忆顾问,请协助我更好地管理和存储与用户相关的交互信息。
通过以上配置和接口,知识图谱内存服务器能够帮助模型更高效地理解和记忆用户信息,提升人机交互体验。