MCP Neo 浩客知识图谱存储服务器基于 Neo4j 原生图数据库,为知识图谱提供高性能、可扩展且可靠的存储与查询解决方案。它支持大规模知识图谱构建,通过 MCP 协议接口实现便捷操作。
npm install @jovanhsu/mcp-neo4j-memory-server
npx mcp-neo4j-memory-server
npm install @jovanhsu/mcp-neo4j-memory-server
npx mcp-neo4j-memory-server
import { McpClient } from '@modelcontextprotocol/sdk/client/mcp.js';
import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js';
// 创建客户端配置
const transport = new StdioClientTransport({
command: 'npx',
args: ['-y', 'mcp-neo4j-memory-server'],
});
const client = new McpClient();
await client.connect(transport);
// 创建新实体
const resultCreate = await client.callTool('create_entities', {
entities: [
{
name: '张三',
entityType: '人物',
observations: ['喜欢编程', '使用TypeScript']
},
{
name: 'Google',
entityType: '公司',
observations: ['总部位于美国加利福尼亚州']
}
]
});
console.log('创建实体结果:', resultCreate);
// 建立关系
const resultRelation = await client.callTool('create_relationships', {
relationships: [
{
fromEntityId: resultCreate.entities[0].id, // 张三的ID
toEntityId: resultCreate.entities[1].id, // Google的ID
relationType: '工作于'
}
]
});
console.log('建立关系结果:', resultRelation);
在 Neo4j 中的存储结构如下:
(Entity:EntityType {name: "实体名称"})
(Entity)-[:HAS_OBSERVATION]->(Observation {content: "观察内容"})
(Entity1)-[:RELATION_TYPE]->(Entity2)
MATCH (a:人物 {name: '张三'})
OPTIONAL MATCH (a)-[r]->(b)
RETURN a, r, b;
MATCH (a)-[:工作于]->(Google:公司 {name: 'Google'})
RETURN a;
欢迎贡献代码、报告问题或提出改进建议!请遵循以下步骤:
git checkout -b feature/amazing-feature)。git commit -m 'Add some amazing feature')。git push origin feature/amazing-feature)。本项目采用 MIT 许可证 - 详见LICENSE文件。