Mcp Neo4j Memory Server

Mcp Neo4j Memory Server

🚀 MCP Neo4j 知识图谱内存服务器

MCP Neo4j 知识图谱内存服务器是一款强大的工具,它能让你轻松地管理和查询知识图谱数据。通过集成 Neo4j 图数据库,该服务器提供了高效的数据存储和快速查询功能,满足各种知识图谱应用场景的需求。

🚀 快速开始

首先,你需要安装并配置 MCP Neo4j 知识图谱内存服务器,然后就可以开始使用它来管理和查询知识图谱数据了。

📦 安装指南

通过 NPM 安装

npm install mcp-neo4j

手动安装

  1. 下载源代码:
    git clone https://github.com/your-repository.git
    cd mcp-neo4j
    
  2. 安装依赖项:
    npm install
    

📚 详细文档

配置

环境变量配置

设置以下环境变量以配置服务器行为:

变量名 类型 默认值 描述
MCP_PORT 整数 3000 服务运行的端口
MCP_DB_URI 字符串 http://localhost:7474 Neo4j 数据库 URI
MCP_DB_USER 字符串 neo4j 数据库用户名
MCP_DB_PASSWORD 字符串 password 数据库密码

示例配置

export MCP_PORT=3001
export MCP_DB_URI=http://localhost:7687

项目特定知识图谱数据库切换

数据库管理命令

命令 描述 示例
get_current_database 返回当前活动数据库 get_current_database
switch_database 切换到不同的数据库,可选创建新数据库 switch_database my-project true
list_databases 列出所有可用数据库 list_databases

💻 使用示例

基础用法

在 JavaScript 中使用:

const { MemoryKnowledgeGraph } = require('mcp-neo4j');
const graph = new MemoryKnowledgeGraph({
port: 3000,
dbUri: 'http://localhost:7474',
dbUser: 'neo4j',
dbPassword: 'password'
});

// 查询知识图谱
async function queryKnowledgeGraph() {
const results = await graph.search('查找用户信息');
console.log(results);
}

queryKnowledgeGraph();

高级用法

模糊搜索

const results = await graph.fuzzySearch('部分匹配内容');

数据库管理 API

获取当前数据库

graphGetCurrentDatabase(): Promise;

切换数据库

graphSwitchDatabase(newDbName: string, createIfNotExists: boolean): Promise<void>;

列出所有数据库

graphListDatabases(): Promise;

🔧 技术细节

图数据库结构

知识图谱存储在 Neo4j 中,以下是架构图:

graph TD
E[实体] -->|HAS_OBSERVATION| O[观察]
E1[实体] -->|RELATES_TO| E2[实体]
P[项目] -->|CONTAINS| F[文件]
F -->|HAS_FUNCTION| Fn[函数]
F -->|HAS_CLASS| C[类]
P -->|HAS_ERROR| Er[错误]
P -->|HAS_REQUIREMENT| R[需求]

classDef entity fill:#f9f,stroke:#333,stroke-width:2px;
classDef observation fill:#bbf,stroke:#333,stroke-width:1px;
classDef project fill:#fdf,stroke:#333,stroke-width:3px;
classDef file fill:#fff,stroke:#333,stroke-width:1px;
classDef function fill:#ffw,stroke:#333,stroke-width:1px;
classDef error fill:#fww,stroke:#333,stroke-width:1px;
classDef requirement fill:#www,stroke:#333,stroke-width:1px;

E, E1, E2 -> entity
O -> observation
P -> project
F -> file
Fn -> function
Er -> error
R -> requirement

实现优势

  • 高效查询:使用 Cypher 查询语言实现快速数据检索。
  • 扩展性:支持自定义插件扩展功能。
  • 安全性:集成身份验证和访问控制机制。

开发

安装依赖

pnpm install

运行测试

npm test

构建项目

npm run build

📄 许可证

MIT License

  • 0 关注
  • 0 收藏,17 浏览
  • system 提出于 2025-09-20 05:48

相似服务问题

相关AI产品