
Mcp Neo4j Cypher
io.github.neo4j-contrib由 GitHub 账号 neo4j-contrib 发布v1.0.0更新于 Oct 24, 2026
A simple Neo4j MCP server that allows you to run Cypher queries against a Neo4j database.
概览
让助手对 Neo4j 图数据库执行 Cypher 读写查询并查看其模式结构。
- 可以做什么
- 提供针对 Neo4j 实例执行 Cypher 查询的工具:read_neo4j_cypher 以 JSON 返回查询结果,write_neo4j_cypher 执行更新查询并返回节点与关系变更的摘要,get_neo4j_schema 列出节点标签、属性及关系。读查询有可配置的超时和响应 token 上限;模式检查按标签抽样节点。命名空间功能可让多个 Neo4j 服务器同时运行。
- 适用场景
- 适合助手需要探索或查询 Neo4j 图数据库的场景,包括把自然语言问题转成 Cypher 查询的 Text2Cypher 工作流。也适合通过命名空间在同一会话中连接多个 Neo4j 数据库。
- 运行要求
- 以本地 Python 包(例如通过 uvx)或 Docker 方式运行。需要一个正在运行的 Neo4j 实例(Aura 或自建),并安装并启用 APOC 插件以支持模式检查。连接信息来自 NEO4J_URI、NEO4J_USERNAME 和 NEO4J_PASSWORD,另有可选的 NEO4J_DATABASE、NEO4J_NAMESPACE、NEO4J_READ_ONLY、NEO4J_READ_TIMEOUT、NEO4J_RESPONSE_TOKEN_LIMIT 和 NEO4J_SCHEMA_SAMPLE_SIZE。
安装
在 SourceWeft 中
- 打开 控制台中的 Mcp Neo4j Cypher,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
README
🔍⁉️ Neo4j MCP Server
mcp-name: io.github.neo4j-contrib/mcp-neo4j-cypher
🌟 Overview
A Model Context Protocol (MCP) server implementation that provides database interaction and allows graph exploration capabilities through Neo4j. This server enables running Cypher graph queries, analyzing complex domain data, and automatically generating business insights that can be enhanced further with an application's analysis tools.
This MCP server facilitates Text2Cypher workflows like the one detailed below.
- Blue steps are handled by the agent
- Purple by the Cypher or another MCP server
- Green by the user
A user question is input to the process and the output is an answer generated by the agent.
📋 Prerequisites
- Neo4j Database: A running Neo4j instance (Aura or Self-Managed)
- APOC Plugin: The APOC plugin must be installed and enabled on your Neo4j instance. This is required for the
get_neo4j_schematool to function correctly.
🧩 Components
🛠️ Tools
The server offers these core tools:
📊 Query Tools
-
read_neo4j_cypher- Execute Cypher read queries to read data from the database
- Input:
query(string): The Cypher query to executeparams(dictionary, optional): Parameters to pass to the Cypher query
- Returns: Query results as JSON serialized array of objects
- Timeout: Read queries are subject to a configurable timeout (default: 30 seconds) to prevent long-running queries from disrupting conversational flow
-
write_neo4j_cypher- Execute updating Cypher queries
- Input:
query(string): The Cypher update queryparams(dictionary, optional): Parameters to pass to the Cypher query
- Returns: A JSON serialized result summary counter with
{ nodes_updated: number, relationships_created: number, ... } - Availability: May be disabled by supplying --read-only as cli flag or
NEO4J_READ_ONLY=trueenvironment variable
🕸️ Schema Tools
get_neo4j_schema- Get a list of all nodes types in the graph database, their attributes with name, type and relationships to other node types
- Requirement: Requires the APOC plugin to be installed and enabled.
- Input:
sample_param(integer, optional): Number of nodes to sample for schema analysis. Overrides server default if provided.
- Returns: JSON serialized list of node labels with two dictionaries: one for attributes and one for relationships
- Performance: Uses sampling by default (1000 nodes per label). Reduce number for faster analysis on large databases. To stop sampling, set to -1.
🏷️ Namespacing
The server supports namespacing to allow multiple Neo4j MCP servers to be used simultaneously. When a namespace is provided, all tool names are prefixed with the namespace followed by a hyphen (e.g., mydb-read_neo4j_cypher).
This is useful when you need to connect to multiple Neo4j databases or instances from the same session.
⚙️ Query Configuration
The server provides configuration options to optimize query performance and manage response sizes:
⏱️ Query Timeouts
Configure timeouts for read queries to prevent long-running queries from disrupting conversational flow:
Command Line:
Environment Variable:
Docker:
Default: 30 seconds. Read queries that exceed this timeout will be automatically cancelled to maintain responsive interactions with AI models.
📏 Token Limits
Control the maximum size of query responses to prevent overwhelming the AI model:
Command Line:
Environment Variable:
Docker:
When a response exceeds the token limit, it will be automatically truncated to fit within the specified limit using tiktoken. This ensures:
- Consistent Performance: Responses stay within model context limits
- Cost Control: Prevents excessive token usage in AI interactions
- Reliability: Large datasets don't break the conversation flow
Note: Token limits only apply to read_neo4j_cypher responses. Schema queries and write operations return summary information and are not affected.
🔍 Schema Sampling
Control the performance and scope of schema inspection with the sample parameter for the get_neo4j_schema tool:
Command Line:
Environment Variable:
Docker:
The sample parameter controls how many nodes are examined when generating the database schema:
- Default:
1000nodes per label are sampled for schema analysis - Performance: Lower values (
100,500) provide faster schema inspection on large databases - Accuracy: Higher values (
5000,10000) provide more comprehensive schema coverage - Full Scan: Set to
-1to examine all nodes (can be very slow on large databases) - Per-Call Override: The
get_neo4j_schematool accepts asample_paramparameter to override the server default
How Sampling Works (via APOC's apoc.meta.schema):
- For each node label, a skip count is calculated:
totalNodesForLabel / sample ± 10% - Every Nth node is examined based on the skip count
- Higher sample numbers result in more nodes being examined
- Results may vary between runs due to random sampling
Example Scenarios:
Performance Considerations:
- Large Databases: Use lower sample values (
100-500) to prevent timeouts - Development: Higher sample values (
1000-5000) for thorough schema understanding - Production: Balance between performance and schema completeness based on your use case
🏗️ Local Development & Deployment
🐳 Local Docker Development
Build and run locally for testing or remote deployment:
🚀 Transport Modes
The server supports different transport protocols depending on your deployment:
- STDIO (for local development): Standard input/output for Claude Desktop and local tools
- HTTP (for remote deployments): RESTful HTTP for web deployments and microservices
- SSE: Server-Sent Events for legacy web-based deployments
Choose your transport based on use case:
- Local development/Claude Desktop: Use
stdio - Remote deployment: Use
http - Legacy web clients: Use
sse
🔒 Security Protection
The server includes comprehensive security protection with secure defaults that protect against common web-based attacks while preserving full MCP functionality when using HTTP transport.
🛡️ DNS Rebinding Protection
TrustedHost Middleware validates Host headers to prevent DNS rebinding attacks:
Secure by Default:
- Only
localhostand127.0.0.1hosts are allowed by default - Malicious websites cannot trick browsers into accessing your local server
Environment Variable:
🌐 CORS Protection
Cross-Origin Resource Sharing (CORS) protection blocks browser-based requests by default:
Environment Variable:
🔧 Complete Security Configuration
Development Setup:
Production Setup:
🚨 Security Best Practices
For allow_origins:
- Be specific:
["https://example.com", "https://example.com"] - Never use
"*"in production with credentials - Use HTTPS origins in production
For allowed_hosts:
- Include your actual domain:
["example.com", "www.example.com"] - Include localhost only for development
- Never use
"*"unless you understand the risks
🔧 Usage with Claude Desktop
Using DXT
Download the latest .dxt file from the releases page and install it with your MCP client.
💾 Released Package
Can be found on PyPi https://pypi.org/project/mcp-neo4j-cypher/
Add the server to your claude_desktop_config.json with the database connection configuration through environment variables. You may also specify the transport method, namespace and other config variables with cli arguments or environment variables.
🌐 HTTP Transport Configuration
For custom HTTP configurations with security middleware:
Multiple Database Example
Here's an example of connecting to multiple Neo4j databases using namespaces:
In this setup:
- The movies database tools will be prefixed with
movies-(e.g.,movies-read_neo4j_cypher) - The local database tools will be prefixed with
local-(e.g.,local-get_neo4j_schema)
Syntax with --db-url, --username, --password, --read-timeout and other command line arguments is still supported but environment variables are preferred:
Legacy Syntax
🐳 Using with Docker
Here we use the Docker Hub hosted Cypher MCP server image with stdio transport for use with Claude Desktop.
Config details:
-i: Interactive mode - keeps STDIN open for stdio transport communication--rm: Automatically remove container when it exits (cleanup)-p 8000:8000: Port mapping - maps host port 8000 to container port 8000NEO4J_TRANSPORT=stdio: Uses stdio transport for Claude Desktop compatibilityNEO4J_NAMESPACE=neo4j: Prefixes tools with "neo4j-" (e.g.,neo4j-read_neo4j_cypher)NEO4J_URI=bolt://host.docker.internal:7687: Allows Docker container to connect to Neo4j running on host machine
🐳 Docker Deployment
The Neo4j MCP server can be deployed using Docker for remote deployments. Docker deployment should use HTTP transport for web accessibility. In order to integrate this deployment with applications like Claude Desktop, you will have to use a proxy in your MCP configuration such as mcp-remote.
📦 Using Your Built Image
After building locally with docker build -t mcp-neo4j-cypher:latest .:
🔧 Environment Variables
🌐 SSE Transport for Legacy Web Access
When using SSE transport (for legacy web clients), the server exposes an HTTP endpoint:
🐳 Docker Compose
For more complex deployments, you may use Docker Compose:
Run with: docker-compose up -d
🔗 Claude Desktop Integration with Docker
For Claude Desktop integration with a Dockerized server using http transport:
Note: First start your Docker container with HTTP transport, then Claude Desktop can connect to it via the HTTP endpoint and proxy server like mcp-remote.
🚀 Development
📦 Prerequisites
- Install
uv:
- Clone the repository and set up development environment:
- Run Integration Tests
🔧 Development Configuration
For development with Claude Desktop using the local source:
Replace /path/to/mcp-neo4j-cypher with your actual project directory path.
📄 License
This MCP server is licensed under the MIT License. This means you are free to use, modify, and distribute the software, subject to the terms and conditions of the MIT License. For more details, please see the LICENSE file in the project repository.
来源:servers/mcp-neo4j-cypher/README.md,提交 1c7ad07
工具
0版本历史
1- v1.0.0最新Sep 16, 2026
评分
已满足适用检查项的 50%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分