mcpField
M
MCP Neo4j Server

MCP Neo4j Server

本地服务
github.com/da-okazaki数据库6042 周前更新

关于 MCP Neo4j Server

MCP Neo4j Server 将 Neo4j 图数据库操作提供给 Claude Desktop 和其他 MCP 客户端,可通过自然语言执行查询及管理图数据。它支持指定 Neo4j Enterprise 数据库,并提供参数化 Cypher 查询。

主要功能

  1. 01执行 Cypher 查询
  2. 02创建节点并设置属性
  3. 03创建带方向的关系
  4. 04选择 Neo4j Enterprise 数据库
  5. 05结构化返回查询结果

适用场景

  1. 01用自然语言查询图数据
  2. 02向图中添加节点和关系
  3. 03连接 Neo4j Enterprise 指定数据库

MCP 相关

该 MCP 服务向客户端提供 Neo4j 查询、节点创建和关系创建工具。客户端可通过这些工具读取或修改图数据库。

配置

本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。

mcp.json · 通用配置
{
"mcpServers": {
"da-okazaki_mcp-neo4j-server": {
"command": "npx",
"args": [
"-y",
"@alanse/mcp-neo4j"
]
}
}
}
启动命令npx -y @alanse/mcp-neo4j

本地服务需要在你的电脑上安装运行环境(如 Node.js 18+)。各客户端的配置文件位置不同,请参考客户端文档。

安装包
npm@alanse/mcp-neo4j

工具

还没有获取到工具列表

本地服务需要在你的电脑上运行后才能读取工具,维护者暂未提供工具列表。

详细介绍

MCP Neo4j 服务

smithery badge

一个 MCP 服务,提供 Neo4j 图数据库与 Claude Desktop 之间的集成,可通过自然语言交互实现图数据库操作。

Neo4j Server MCP server

快速开始

你可以直接使用 npx 运行此 MCP 服务:

npx @alanse/mcp-neo4j

或将其添加到你的 Claude Desktop 配置中:

{
  "mcpServers": {
    "neo4j": {
      "command": "npx",
      "args": ["@alanse/mcp-neo4j-server"],
      "env": {
        "NEO4J_URI": "bolt://localhost:7687",
        "NEO4J_USERNAME": "neo4j",
        "NEO4J_PASSWORD": "your-password",
        "NEO4J_DATABASE": "neo4j"
      }
    }
  }
}

功能

此服务提供用于与 Neo4j 数据库交互的工具:

Neo4j 企业版支持

此服务现在支持连接到 Neo4j 企业版中的特定数据库。默认情况下,它会连接到 “neo4j” 数据库,但你可以使用 NEO4J_DATABASE 环境变量指定其他数据库。

工具
  • execute_query:在 Neo4j 数据库上执行 Cypher 查询

    • 支持所有类型的 Cypher 查询(READ、CREATE、UPDATE、DELETE)
    • 以结构化格式返回查询结果
    • 可以传入参数以防止注入攻击
  • create_node:在图数据库中创建新节点

    • 指定节点标签和属性
    • 返回创建的节点及其内部 ID
    • 支持属性的所有 Neo4j 数据类型
  • create_relationship:在两个现有节点之间创建关系

    • 定义关系类型和方向
    • 向关系添加属性
    • 需要源节点和目标节点的节点 ID

安装

通过 Smithery 安装

通过 Smithery 为 Claude Desktop 自动安装 MCP Neo4j 服务:

npx -y @smithery/cli install @alanse/mcp-neo4j-server --client claude
用于开发
  1. 克隆仓库:
git clone https://github.com/da-okazaki/mcp-neo4j-server.git
cd mcp-neo4j-server
  1. 安装依赖:
npm install
  1. 构建项目:
npm run build

配置

此服务需要以下环境变量:

  • NEO4J_URI:Neo4j 数据库 URI(默认:bolt://localhost:7687)
  • NEO4J_USERNAME:Neo4j 用户名(默认:neo4j)
  • NEO4J_PASSWORD:Neo4j 密码(必填)
  • NEO4J_DATABASE:Neo4j 数据库名称(默认:neo4j)——使用此项连接到 Neo4j 企业版中的特定数据库

使用示例

以下示例展示如何通过自然语言与 Neo4j 数据库交互:

连接到特定数据库

对于拥有多个数据库的 Neo4j 企业版用户,你可以指定要连接的数据库:

{
  "env": {
    "NEO4J_URI": "bolt://localhost:7687",
    "NEO4J_USERNAME": "neo4j",
    "NEO4J_PASSWORD": "your-password",
    "NEO4J_DATABASE": "myCustomDatabase"
  }
}

这将连接到 “myCustomDatabase”,而不是默认的 “neo4j” 数据库。

查询数据

你可以提出如下问题:

  • “向我展示销售部门的所有员工”
  • “找出年龄最大的 5 位客户”
  • “谁在上个月购买了超过 3 件产品?”

示例:

User: "Show me all employees in the Sales department"

Claude: Let me query the database for Sales department employees.

[Executes query internally: MATCH (e:Employee)-[:WORKS_IN]->(d:Department {name: 'Sales'}) RETURN e.name, e.position]

Result:
- John Smith (Sales Manager)
- Sarah Johnson (Sales Representative)
- Mike Brown (Account Executive)
创建数据

你可以给出如下指令:

  • “添加一个名为 John Doe 的新人员,年龄 30 岁”
  • “创建一个名为 ‘Premium Coffee’ 的产品,价格为 $24.99”
  • “添加一个名为 ‘Research & Development’ 的新部门”

示例:

User: "Add a new person named John Doe who is 30 years old"

Claude: I'll create a new Person node with the provided information.

[Creates node internally with label 'Person' and properties {name: 'John Doe', age: 30}]

Result: Created new person node with ID: 123
创建关系

你可以请求如下关系:

  • “让 John Doe 与 Jane Smith 成为朋友”
  • “将产品 A 设为产品 B 的组件”
  • “将 John Doe 分配到销售部门”

示例:

User: "Make John Doe friends with Jane Smith"

Claude: I'll create a friendship relationship between these two people.

[Creates relationship internally: MATCH (a:Person {name: 'John Doe'}), (b:Person {name: 'Jane Smith'})
CREATE (a)-[:FRIENDS_WITH {since: '2024-01-05'}]->(b)]

Result: Created friendship relationship between John Doe and Jane Smith
复杂操作

你可以使用自然语言执行更复杂的操作:

  • “找出所有居住在纽约的客户购买的产品”
  • “向我展示 John Doe 的朋友的朋友”
  • “计算每个部门员工的平均年龄”

示例:

User: "Find all products purchased by customers who live in New York"

Claude: I'll query the database for this information.

[Executes query internally:
MATCH (c:Customer {city: 'New York'})-[:PURCHASED]->(p:Product)
RETURN c.name, collect(p.name) as products]

Result:
- Alice Wilson: [Premium Coffee, Tea Set, Cookies]
- Bob Miller: [Premium Coffee, Water Bottle]

测试

运行测试套件:

npm test

许可证

MIT

评论

支持 Markdown

第一次接触 MCP?

从协议是什么,到在客户端里装上第一个服务,这几条回答覆盖了大多数入门问题。

一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。