neo4j-mcp-skill
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseNeo4j MCP Skill
Neo4j MCP 技能
Installs and configures the official Neo4j MCP server so AI agents can connect to Neo4j via any MCP-compatible client.
安装并配置官方Neo4j MCP服务器,使AI Agent能够通过任何兼容MCP的客户端连接到Neo4j。
When to Use
适用场景
- Connecting Claude Code, Claude Desktop, Cursor, Windsurf, VS Code, Kiro, or another editor to Neo4j via MCP
- Installing and writing the correct config for a specific editor
neo4j-mcp-server - Switching between stdio and HTTP transport
- Enabling or disabling write access ()
NEO4J_READ_ONLY - Troubleshooting "MCP server not found" or connection errors
- 将Claude Code、Claude Desktop、Cursor、Windsurf、VS Code、Kiro或其他编辑器通过MCP连接到Neo4j
- 安装并为特定编辑器编写正确的配置
neo4j-mcp-server - 在stdio和HTTP传输之间切换
- 启用或禁用写入权限()
NEO4J_READ_ONLY - 排查“MCP服务器未找到”或连接错误
When NOT to Use
不适用场景
- Writing or optimizing Cypher queries → use
neo4j-cypher-skill - Provisioning a new Neo4j Aura instance → use
neo4j-aura-provisioning-skill - Agent long-term memory → use
neo4j-agent-memory-skill - neo4j-admin / cypher-shell / aura-cli → use
neo4j-cli-tools-skill
- 编写或优化Cypher查询 → 使用
neo4j-cypher-skill - 部署新的Neo4j Aura实例 → 使用
neo4j-aura-provisioning-skill - Agent长期内存 → 使用
neo4j-agent-memory-skill - neo4j-admin / cypher-shell / aura-cli → 使用
neo4j-cli-tools-skill
Available MCP Tools
可用MCP工具
| Tool | Type | What it does |
|---|---|---|
| read | Returns labels, relationship types, property keys, and indexes |
| read | Executes read-only Cypher ( |
| write | Executes write Cypher ( |
| read | Lists available Graph Data Science procedures (requires GDS plugin) |
| 工具 | 类型 | 功能 |
|---|---|---|
| 只读 | 返回标签、关系类型、属性键和索引 |
| 只读 | 执行只读Cypher语句( |
| 可写 | 执行写入型Cypher语句( |
| 只读 | 列出可用的图数据科学(GDS)过程(需要安装GDS插件) |
Installation
安装步骤
Step 1 — Install and find the absolute path
步骤1 — 安装并获取绝对路径
bash
undefinedbash
undefinedOption A: pip (recommended)
选项A:pip(推荐)
pip install neo4j-mcp-server
pip install neo4j-mcp-server
Option B: Download binary
选项B:下载二进制文件
https://github.com/neo4j/mcp/releases -- macOS, Linux, Windows binaries
https://github.com/neo4j/mcp/releases -- 提供macOS、Linux、Windows二进制文件
Option C: Docker
选项C:Docker
docker pull neo4j/mcp
**Get the absolute path — you will need this in Step 3:**
```bash
which neo4j-mcp # e.g. /usr/local/bin/neo4j-mcp
# or: /Users/you/project/.venv/bin/neo4j-mcp (if installed in venv)
neo4j-mcp --version # confirm it runsWhy absolute path matters: editors (Claude Code, Cursor, Claude Desktop) spawn the MCP server as a subprocess using their own restricted PATH — not your shell's PATH. On macOS, GUI apps do not inheritor.zshrc. Using.zprofileas the command will silently fail; usingneo4j-mcpalways works. Always use the output of/full/path/to/neo4j-mcpin thewhich neo4j-mcpfield below.command
docker pull neo4j/mcp
**获取绝对路径——步骤3会用到:**
```bash
which neo4j-mcp # 示例:/usr/local/bin/neo4j-mcp
# 或:/Users/you/project/.venv/bin/neo4j-mcp (如果安装在虚拟环境中)
neo4j-mcp --version # 确认程序可运行为什么绝对路径很重要:编辑器(Claude Code、Cursor、Claude Desktop)会使用自身受限的PATH环境变量来启动MCP服务器子进程——而非你的Shell的PATH。在macOS上,GUI应用不会继承或.zshrc中的配置。直接使用.zprofile命令会静默失败;而使用neo4j-mcp则始终有效。请务必将/完整路径/neo4j-mcp的输出填入下方的which neo4j-mcp字段。command
Step 2 — Prepare credentials
步骤2 — 准备凭证
bash
undefinedbash
undefined.env (gitignored)
.env(已加入git忽略)
NEO4J_URI=neo4j+s://<instance>.databases.neo4j.io # Aura
NEO4J_URI=neo4j+s://<instance>.databases.neo4j.io # Aura实例
or bolt://localhost:7687 # local
或 bolt://localhost:7687 # 本地实例
NEO4J_USERNAME=neo4j
NEO4J_PASSWORD=<password>
NEO4J_DATABASE=neo4j
Verify connectivity before configuring the editor:
```bash
source .env
cypher-shell -a "$NEO4J_URI" -u "$NEO4J_USERNAME" -p "$NEO4J_PASSWORD" \
"RETURN 'connected' AS status"NEO4J_USERNAME=neo4j
NEO4J_PASSWORD=<password>
NEO4J_DATABASE=neo4j
在配置编辑器前先验证连接性:
```bash
source .env
cypher-shell -a "$NEO4J_URI" -u "$NEO4J_USERNAME" -p "$NEO4J_PASSWORD" \
"RETURN 'connected' AS status"If cypher-shell not available: python3 -c "
如果没有cypher-shell:python3 -c "
from neo4j import GraphDatabase, version
from neo4j import GraphDatabase, version
d = GraphDatabase.driver('$NEO4J_URI', auth=('$NEO4J_USERNAME','$NEO4J_PASSWORD'))
d = GraphDatabase.driver('$NEO4J_URI', auth=('$NEO4J_USERNAME','$NEO4J_PASSWORD'))
d.verify_connectivity(); print('connected'); d.close()"
d.verify_connectivity(); print('connected'); d.close()"
undefinedundefinedStep 3 — Configure your editor
步骤3 — 配置编辑器
Pick the config block for your editor. All use STDIO transport (the MCP server runs as a subprocess of the editor).
Claude Code — add to . If the file already exists, merge the block into the existing object — do not replace the whole file.
~/.claude/settings.jsonneo4jmcpServersjson
{
"mcpServers": {
"neo4j": {
"command": "/full/path/to/neo4j-mcp",
"env": {
"NEO4J_URI": "neo4j+s://<host>",
"NEO4J_USERNAME": "neo4j",
"NEO4J_PASSWORD": "<password>",
"NEO4J_DATABASE": "neo4j",
"NEO4J_READ_ONLY": "true"
}
}
}
}CLI alternative (sets command only — you still need to add env vars to the file):
bash
claude mcp add neo4j /full/path/to/neo4j-mcpClaude Desktop
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json
json
{
"mcpServers": {
"neo4j": {
"command": "/full/path/to/neo4j-mcp",
"env": {
"NEO4J_URI": "neo4j+s://<host>",
"NEO4J_USERNAME": "neo4j",
"NEO4J_PASSWORD": "<password>",
"NEO4J_DATABASE": "neo4j",
"NEO4J_READ_ONLY": "true"
}
}
}
}VS Code — (note: uses , not — different from all other editors):
.vscode/mcp.jsonserversmcpServersjson
{
"servers": {
"neo4j": {
"type": "stdio",
"command": "/full/path/to/neo4j-mcp",
"env": {
"NEO4J_URI": "bolt://localhost:7687",
"NEO4J_USERNAME": "neo4j",
"NEO4J_PASSWORD": "password",
"NEO4J_DATABASE": "neo4j",
"NEO4J_READ_ONLY": "true"
}
}
}
}Cursor — global: / project: (same structure as Claude Code, uses ).
~/.cursor/mcp.json.cursor/mcp.jsonmcpServersWindsurf — global: / project: (same structure as Claude Code, uses ).
~/.codeium/windsurf/mcp_config.json.windsurf/mcp_config.jsonmcpServersKiro — global: / project: . Supports to pull from the shell environment exported before the editor launched:
~/.kiro/settings/mcp.json.kiro/settings/mcp.json${VARIABLE}json
{
"mcpServers": {
"neo4j": {
"command": "/full/path/to/neo4j-mcp",
"env": {
"NEO4J_URI": "${NEO4J_URI}",
"NEO4J_USERNAME": "${NEO4J_USERNAME}",
"NEO4J_PASSWORD": "${NEO4J_PASSWORD}",
"NEO4J_DATABASE": "neo4j",
"NEO4J_READ_ONLY": "true"
}
}
}
}Cline — (same structure as Claude Code, uses ). Or add via VS Code settings → Cline extension → MCP Servers panel.
~/.vscode/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.jsonmcpServersAntigravity — at project root (same structure as Claude Code, uses ).
mcp_config.jsonmcpServers选择对应编辑器的配置块。所有配置均使用STDIO传输(MCP服务器作为编辑器的子进程运行)。
Claude Code — 添加到。如果文件已存在,请将块合并到现有的对象中——不要替换整个文件。
~/.claude/settings.jsonneo4jmcpServersjson
{
"mcpServers": {
"neo4j": {
"command": "/完整路径/neo4j-mcp",
"env": {
"NEO4J_URI": "neo4j+s://<host>",
"NEO4J_USERNAME": "neo4j",
"NEO4J_PASSWORD": "<password>",
"NEO4J_DATABASE": "neo4j",
"NEO4J_READ_ONLY": "true"
}
}
}
}CLI替代方式(仅设置命令——仍需在文件中添加环境变量):
bash
claude mcp add neo4j /完整路径/neo4j-mcpClaude Desktop
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json
json
{
"mcpServers": {
"neo4j": {
"command": "/完整路径/neo4j-mcp",
"env": {
"NEO4J_URI": "neo4j+s://<host>",
"NEO4J_USERNAME": "neo4j",
"NEO4J_PASSWORD": "<password>",
"NEO4J_DATABASE": "neo4j",
"NEO4J_READ_ONLY": "true"
}
}
}
}VS Code — (注意:使用而非——与其他所有编辑器不同):
.vscode/mcp.jsonserversmcpServersjson
{
"servers": {
"neo4j": {
"type": "stdio",
"command": "/完整路径/neo4j-mcp",
"env": {
"NEO4J_URI": "bolt://localhost:7687",
"NEO4J_USERNAME": "neo4j",
"NEO4J_PASSWORD": "password",
"NEO4J_DATABASE": "neo4j",
"NEO4J_READ_ONLY": "true"
}
}
}
}Cursor — 全局配置: / 项目配置:(与Claude Code结构相同,使用)。
~/.cursor/mcp.json.cursor/mcp.jsonmcpServersWindsurf — 全局配置: / 项目配置:(与Claude Code结构相同,使用)。
~/.codeium/windsurf/mcp_config.json.windsurf/mcp_config.jsonmcpServersKiro — 全局配置: / 项目配置:。支持从编辑器启动前导出的Shell环境中读取变量:
~/.kiro/settings/mcp.json.kiro/settings/mcp.json${VARIABLE}json
{
"mcpServers": {
"neo4j": {
"command": "/完整路径/neo4j-mcp",
"env": {
"NEO4J_URI": "${NEO4J_URI}",
"NEO4J_USERNAME": "${NEO4J_USERNAME}",
"NEO4J_PASSWORD": "${NEO4J_PASSWORD}",
"NEO4J_DATABASE": "neo4j",
"NEO4J_READ_ONLY": "true"
}
}
}
}Cline — (与Claude Code结构相同,使用)。或通过VS Code设置 → Cline扩展 → MCP服务器面板添加。
~/.vscode/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.jsonmcpServersAntigravity — 项目根目录下的(与Claude Code结构相同,使用)。
mcp_config.jsonmcpServersStep 4 — Restart the editor
步骤4 — 重启编辑器
After editing the config file, restart the editor (or reload the MCP server if the editor supports hot-reload). Verify the server appears in the editor's MCP panel or tool list.
编辑配置文件后,重启编辑器(如果编辑器支持热重载,也可以重新加载MCP服务器)。验证服务器是否出现在编辑器的MCP面板或工具列表中。
Step 5 — Smoke test
步骤5 — 冒烟测试
Run via the agent or directly via MCP. Do not use "does it return labels?" as the test — an empty database returns no labels and looks identical to a broken connection.
get-schemaUse this instead — it succeeds even on an empty DB:
read-cypher: RETURN 'connected' AS statusExpected: . Any result confirms the server is alive and the credentials are valid.
{ "status": "connected" }If the database has data, also run:
get-schemaand confirm it returns the node labels and relationship types you expect.
通过Agent或直接通过MCP运行。不要用“是否返回标签?”作为测试——空数据库不会返回标签,这与连接失败的表现一致。
get-schema请改用以下测试——即使是空数据库也会成功:
read-cypher: RETURN 'connected' AS status预期结果:。任何结果都能确认服务器正常运行且凭证有效。
{ "status": "connected" }如果数据库中有数据,也可以运行:
get-schema并确认返回的节点标签和关系类型符合预期。
HTTP Transport
HTTP传输
HTTP transport runs the MCP server as a persistent network service — useful for shared servers, containers, or multiple clients.
bash
undefinedHTTP传输将MCP服务器作为持久化网络服务运行——适用于共享服务器、容器或多客户端场景。
bash
undefinedWith credentials baked in (simpler — server authenticates all clients as the same user)
内置凭证(更简单——服务器将所有客户端认证为同一用户)
neo4j-mcp
--neo4j-transport-mode http
--neo4j-http-host 127.0.0.1
--neo4j-http-port 8080
--neo4j-uri bolt://localhost:7687
--neo4j-username neo4j
--neo4j-password <password>
--neo4j-database neo4j
--neo4j-transport-mode http
--neo4j-http-host 127.0.0.1
--neo4j-http-port 8080
--neo4j-uri bolt://localhost:7687
--neo4j-username neo4j
--neo4j-password <password>
--neo4j-database neo4j
Editor config for HTTP (no credentials in config — server holds them):
```json
{
"mcpServers": {
"neo4j-http": {
"type": "http",
"url": "http://127.0.0.1:8080/mcp"
}
}
}Per-request auth (omit / from the server command): each client request must include an header. Generate the value with:
--neo4j-username--neo4j-passwordAuthorization: Basic <base64(username:password)>bash
echo -n "neo4j:<password>" | base64Then add to the editor config:
json
{
"headers": { "Authorization": "Basic bmVvNGo6cGFzc3dvcmQ=" }
}Security: bind to, not127.0.0.1. Only change to a broader interface if you need remote access and have TLS + auth in front of it.0.0.0.0
neo4j-mcp
--neo4j-transport-mode http
--neo4j-http-host 127.0.0.1
--neo4j-http-port 8080
--neo4j-uri bolt://localhost:7687
--neo4j-username neo4j
--neo4j-password <password>
--neo4j-database neo4j
--neo4j-transport-mode http
--neo4j-http-host 127.0.0.1
--neo4j-http-port 8080
--neo4j-uri bolt://localhost:7687
--neo4j-username neo4j
--neo4j-password <password>
--neo4j-database neo4j
HTTP模式的编辑器配置(配置中不含凭证——由服务器保存):
```json
{
"mcpServers": {
"neo4j-http": {
"type": "http",
"url": "http://127.0.0.1:8080/mcp"
}
}
}请求级认证(服务器命令中省略/):每个客户端请求必须包含头。使用以下命令生成该值:
--neo4j-username--neo4j-passwordAuthorization: Basic <base64(用户名:密码)>bash
echo -n "neo4j:<password>" | base64然后添加到编辑器配置中:
json
{
"headers": { "Authorization": "Basic bmVvNGo6cGFzc3dvcmQ=" }
}安全提示:绑定到,而非127.0.0.1。只有在需要远程访问且已配置TLS和认证的情况下,才切换到更广泛的接口。0.0.0.0
Environment Variables
环境变量
| Variable | Required | Default | Notes |
|---|---|---|---|
| yes | — | |
| yes | — | |
| yes | — | |
| no | server default | Specify explicitly to avoid routing to wrong DB |
| no | | Set |
When to set (or remove the variable): any use case that needs to write data — imports, MERGE, schema changes, GDS write-back. Without write access, the agent will see only three tools (, , ) and calls will fail.
NEO4J_READ_ONLY=falseget-schemaread-cypherlist-gds-procedureswrite-cypher| 变量 | 是否必填 | 默认值 | 说明 |
|---|---|---|---|
| 是 | — | Aura实例使用 |
| 是 | — | |
| 是 | — | |
| 否 | 服务器默认值 | 显式指定以避免路由到错误的数据库 |
| 否 | | 设置为 |
何时设置(或移除该变量):任何需要写入数据的场景——导入、MERGE、模式变更、GDS写回。如果没有写入权限,Agent将只能看到三个工具(、、),且调用会失败。
NEO4J_READ_ONLY=falseget-schemaread-cypherlist-gds-procedureswrite-cypherAPOC Requirement
APOC要求
The MCP server uses APOC for schema introspection (). On Aura, APOC is included automatically. On self-managed Neo4j, install the APOC plugin and whitelist it:
get-schemaundefinedMCP服务器使用APOC进行模式 introspection()。在Aura中,APOC已自动包含。在自托管Neo4j中,需要安装APOC插件并将其加入白名单:
get-schemaundefinedneo4j.conf
neo4j.conf
dbms.security.procedures.unrestricted=apoc.*
Verify: `read-cypher: RETURN apoc.version() AS v` — if this fails, `get-schema` will return incomplete results.
---dbms.security.procedures.unrestricted=apoc.*
验证:`read-cypher: RETURN apoc.version() AS v`——如果该命令失败,`get-schema`将返回不完整的结果。
---Troubleshooting
故障排查
| Symptom | Likely cause | Fix |
|---|---|---|
| Server not listed in editor | Config file path wrong, JSON malformed, or editor not restarted | Validate JSON ( |
| Editor PATH doesn't include the binary location | Use absolute path in |
| Server starts then immediately exits | Python not found (pip install) or wrong binary for OS (binary install) | Run the command manually in terminal to see the error: |
| Wrong credentials | Verify URI + credentials with |
| | Remove or set to |
| DB not reachable from editor process | Check firewall, VPN, or whether Aura instance is paused |
| GDS not installed or Aura Free | GDS requires Aura Professional/Enterprise or self-managed with plugin |
| 症状 | 可能原因 | 修复方法 |
|---|---|---|
| 服务器未在编辑器中列出 | 配置文件路径错误、JSON格式错误或未重启编辑器 | 验证JSON格式( |
| 编辑器的PATH不包含二进制文件路径 | 在 |
| 服务器启动后立即退出 | 未找到Python(pip安装方式)或二进制文件与操作系统不匹配(二进制安装方式) | 在终端手动运行命令查看错误: |
| 凭证错误 | 在编辑配置前,使用 |
| | 如果需要写入权限,移除该变量或设置为 |
| 编辑器进程无法访问数据库 | 检查防火墙、VPN或Aura实例是否已暂停 |
| 未安装GDS或使用Aura免费版 | GDS需要Aura专业版/企业版或安装了插件的自托管实例 |
Checklist
检查清单
- run and absolute path noted — this goes in
which neo4j-mcp, notcommandneo4j-mcp - Connectivity verified () before editing editor config
RETURN 'connected' - Credentials not committed to git; in
.env.gitignore - set intentionally —
NEO4J_READ_ONLYfor exploration,true/absent for write use casesfalse - specified explicitly
NEO4J_DATABASE - Correct config file used for the target editor (VS Code uses ; all others use
servers)mcpServers - Config is valid JSON (validate with before saving)
python3 -m json.tool <file> - Editor restarted after config change
- Smoke test passed: returns a result
read-cypher: RETURN 'connected' AS status - APOC available on self-managed:
read-cypher: RETURN apoc.version()
- 已运行并记录绝对路径——该路径需填入
which neo4j-mcp,而非commandneo4j-mcp - 在编辑编辑器配置前已验证连接性()
RETURN 'connected' - 凭证未提交到git;已加入
.env.gitignore - 已明确设置——探索场景设为
NEO4J_READ_ONLY,写入场景设为true或移除false - 已显式指定
NEO4J_DATABASE - 使用了目标编辑器的正确配置文件(VS Code使用;其他编辑器使用
servers)mcpServers - 配置为有效的JSON(保存前使用验证)
python3 -m json.tool <file> - 配置变更后已重启编辑器
- 冒烟测试通过:返回结果
read-cypher: RETURN 'connected' AS status - 自托管实例上已安装APOC:可正常运行
read-cypher: RETURN apoc.version()