Skip to main content

Neo4j MCP 服务器

一个基于 Model Context Protocol 的 Neo4j 图数据库操作服务器。该服务器使 LLM 能够执行 Neo4j 数据库操作,包括运行 Cypher 查询和获取数据库元信息。

可用工具

  • run_query - 执行 Cypher 查询语句

    • 必需参数:
      • query (字符串): Cypher 查询语句
    • 可选参数:
      • parameters (对象): 查询参数
  • get_database_info - 获取 Neo4j 数据库信息

    • 无需参数
  • get_node_labels - 获取数据库中所有节点标签

    • 无需参数
  • get_relationship_types - 获取数据库中所有关系类型

    • 无需参数
  • get_node_properties - 获取指定标签节点的属性信息

    • 必需参数:
      • label (字符串): 节点标签名称

安装

使用 uv (推荐)

当使用 uv 时,不需要特定安装。我们将使用 uvx 直接运行 mcp-server-neo4j。

使用 PIP

您也可以通过 pip 安装 mcp-server-neo4j:

pip install mcp-server-neo4j

安装后,您可以通过以下命令运行:

python -m mcp_server_neo4j

Docker 构建

cd src/neo4j
docker build -t mcp/neo4j .

配置

配置 Claude.app

在 Claude 设置中添加:

使用 uvx
"mcpServers": {
  "neo4j": {
    "command": "uvx",
    "args": ["mcp-server-neo4j", "--uri=bolt://neo4j-server:7687", "--username=neo4j", "--password=your_password"]
  }
}
使用 docker
"mcpServers": {
  "neo4j": {
    "command": "docker",
    "args": ["run", "-i", "--rm", "mcp/neo4j", "--uri=bolt://neo4j-server:7687", "--username=neo4j", "--password=your_password"]
  }
}
使用 pip 安装
"mcpServers": {
  "neo4j": {
    "command": "python",
    "args": ["-m", "mcp_server_neo4j", "--uri=bolt://neo4j-server:7687", "--username=neo4j", "--password=your_password"]
  }
}

配置 Zed

在 Zed 的 settings.json 中添加:

使用 uvx
"context_servers": [
  "mcp-server-neo4j": {
    "command": "uvx",
    "args": ["mcp-server-neo4j", "--uri=bolt://neo4j-server:7687", "--username=neo4j", "--password=your_password"]
  }
],
使用 pip 安装
"context_servers": {
  "mcp-server-neo4j": {
    "command": "python",
    "args": ["-m", "mcp_server_neo4j", "--uri=bolt://neo4j-server:7687", "--username=neo4j", "--password=your_password"]
  }
},

调试

您可以使用 MCP inspector 来调试服务器。对于 uvx 安装:

npx @modelcontextprotocol/inspector uvx mcp-server-neo4j

或者,如果您在特定目录中安装了该包或正在开发:

cd path/to/servers/src/neo4j
npx @modelcontextprotocol/inspector uv run mcp-server-neo4j

示例交互

  1. 执行 Cypher 查询:
{
  "name": "run_query",
  "arguments": {
    "query": "MATCH (n:Person) RETURN n.name, n.age LIMIT 10"
  }
}

响应:

{
  "data": [
    {
      "n.name": "张三",
      "n.age": 30
    },
    {
      "n.name": "李四",
      "n.age": 25
    }
  ],
  "summary": {
    "counters": {
      "nodes_created": 0,
      "nodes_deleted": 0,
      "relationships_created": 0,
      "relationships_deleted": 0,
      "properties_set": 0,
      "labels_added": 0,
      "labels_removed": 0,
      "indexes_added": 0,
      "indexes_removed": 0,
      "constraints_added": 0,
      "constraints_removed": 0
    }
  }
}
  1. 获取数据库信息:
{
  "name": "get_database_info",
  "arguments": {}
}

响应:

{
  "name": "Neo4j",
  "version": "5.14.0",
  "node_count": 1000,
  "relationship_count": 5000,
  "labels": ["Person", "Movie", "Director"],
  "relationship_types": ["ACTED_IN", "DIRECTED", "FRIEND_OF"]
}

Claude 使用示例问题

  1. "你能帮我查询图数据库中的所有人物节点吗?"
  2. "请告诉我数据库中有哪些类型的节点标签和关系"
  3. "执行查询,找出所有演员和他们参演的电影"
  4. "Person 节点有哪些属性?"

贡献

我们鼓励您对 mcp-server-neo4j 进行贡献。无论您想添加新的 Neo4j 相关工具、增强现有功能,还是改进文档,您的贡献都是宝贵的。

有关其他 MCP 服务器和实现模式的示例,请参阅: https://github.com/modelcontextprotocol/servers

欢迎提交拉取请求!欢迎贡献新想法、错误修复或增强功能,以使 mcp-server-neo4j 更加强大和有用。

许可证

mcp-server-neo4j 遵循 MIT 许可证。这意味着您可以自由使用、修改和分发该软件,但须遵守 MIT 许可证的条款和条件。有关更多详细信息,请参阅项目代码库中的 LICENSE 文件。

Metadata

Release files for mcp-server-neo4j 0.1.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mcp-server-neo4j 0.1.8
File Size Uploaded Provenance
mcp_server_neo4j-0.1.8.tar.gz 28.0 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for mcp-server-neo4j 0.1.8
File Interpreter ABI Platform
mcp_server_neo4j-0.1.8-py3-none-any.whl Python 3 none any Details

Total release size: 35.5 kB

Release files / mcp_server_neo4j-0.1.8.tar.gz

Download URL mcp_server_neo4j-0.1.8.tar.gz
Size 28.0 kB
Tags Source
SHA-256 checksum
How to use checksums
19a248c44b21030fa4569e156ee1dc0fa264ce33264a2fd370902de00701cab0
BLAKE2b-256 checksum
How to use checksums
040cb2df2ed4ce354a51983426e9b9c310a61fab3ee03ca335ce0c81a645a70d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.11

Release files / mcp_server_neo4j-0.1.8-py3-none-any.whl

Download URL mcp_server_neo4j-0.1.8-py3-none-any.whl
Size 7.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8ee1ec893903590894e37a49c9cb034eccde7bc1f9bed7fe123d5d65f8dd34b9
BLAKE2b-256 checksum
How to use checksums
0c6a7cfdfff590d82ead7b1aa82684ff4d67c80b0110565a4f1d023027c8b610
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.11

Security for mcp-server-neo4j 0.1.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page