Skip to content

Commit 44a01eb

Browse files
committed
Merge branch 'main' into cypher-improve-tool-annotations
2 parents b3c7d62 + 13b4d1d commit 44a01eb

File tree

10 files changed

+323
-340
lines changed

10 files changed

+323
-340
lines changed

servers/mcp-neo4j-cypher/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* Add HTTP transport option
1414
* Migrate to FastMCP v2.x
1515
* Add tool annotations
16+
* Update Dockerfile for http configuration
1617

1718
## v0.2.4
1819

servers/mcp-neo4j-cypher/Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ RUN pip install --no-cache-dir hatchling
99
COPY pyproject.toml /app/
1010

1111
# Install dependencies
12-
RUN pip install --no-cache-dir neo4j>=5.26.0 mcp>=1.6.0
12+
RUN pip install --no-cache-dir neo4j>=5.26.0 fastmcp>=2.0.0
1313

1414

1515
# Copy the source code
@@ -23,9 +23,10 @@ ENV NEO4J_URI="bolt://host.docker.internal:7687"
2323
ENV NEO4J_USERNAME="neo4j"
2424
ENV NEO4J_PASSWORD="password"
2525
ENV NEO4J_DATABASE="neo4j"
26-
ENV NEO4J_TRANSPORT="sse"
26+
ENV NEO4J_TRANSPORT="http"
2727
ENV NEO4J_MCP_SERVER_HOST="0.0.0.0"
2828
ENV NEO4J_MCP_SERVER_PORT="8000"
29+
ENV NEO4J_MCP_SERVER_PATH="/api/mcp/"
2930

3031
EXPOSE 8000
3132

servers/mcp-neo4j-cypher/README.md

Lines changed: 95 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -11,32 +11,65 @@ A Model Context Protocol (MCP) server implementation that provides database inte
1111
The server offers these core tools:
1212

1313
#### 📊 Query Tools
14-
- `read-neo4j-cypher`
14+
- `read_neo4j_cypher`
1515
- Execute Cypher read queries to read data from the database
1616
- Input:
1717
- `query` (string): The Cypher query to execute
1818
- `params` (dictionary, optional): Parameters to pass to the Cypher query
1919
- Returns: Query results as JSON serialized array of objects
2020

21-
- `write-neo4j-cypher`
21+
- `write_neo4j_cypher`
2222
- Execute updating Cypher queries
2323
- Input:
2424
- `query` (string): The Cypher update query
2525
- `params` (dictionary, optional): Parameters to pass to the Cypher query
2626
- Returns: A JSON serialized result summary counter with `{ nodes_updated: number, relationships_created: number, ... }`
2727

2828
#### 🕸️ Schema Tools
29-
- `get-neo4j-schema`
29+
- `get_neo4j_schema`
3030
- Get a list of all nodes types in the graph database, their attributes with name, type and relationships to other node types
3131
- No input required
3232
- Returns: JSON serialized list of node labels with two dictionaries: one for attributes and one for relationships
3333

3434
### 🏷️ Namespacing
3535

36-
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`).
36+
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`).
3737

3838
This is useful when you need to connect to multiple Neo4j databases or instances from the same session.
3939

40+
## 🏗️ Local Development & Deployment
41+
42+
### 🐳 Local Docker Development
43+
44+
Build and run locally for testing or remote deployment:
45+
46+
```bash
47+
# Build the Docker image with a custom name
48+
docker build -t mcp-neo4j-cypher:latest .
49+
50+
# Run locally (uses http transport by default for Docker)
51+
docker run -p 8000:8000 \
52+
-e NEO4J_URI="bolt://host.docker.internal:7687" \
53+
-e NEO4J_USERNAME="neo4j" \
54+
-e NEO4J_PASSWORD="your-password" \
55+
mcp-neo4j-cypher:latest
56+
57+
# Access the server at http://localhost:8000/api/mcp/
58+
```
59+
60+
### 🚀 Transport Modes
61+
62+
The server supports different transport protocols depending on your deployment:
63+
64+
- **STDIO** (default for local development): Standard input/output for Claude Desktop and local tools
65+
- **HTTP** (default for Docker): RESTful HTTP for web deployments and microservices
66+
- **SSE**: Server-Sent Events for legacy web-based deployments
67+
68+
Choose your transport based on use case:
69+
- **Local development/Claude Desktop**: Use `stdio`
70+
- **Docker/Remote deployment**: Use `http`
71+
- **Legacy web clients**: Use `sse`
72+
4073
## 🔧 Usage with Claude Desktop
4174

4275
### Using DXT
@@ -66,37 +99,23 @@ Add the server to your `claude_desktop_config.json` with the database connection
6699
}
67100
```
68101

69-
### 🌐 HTTP Transport Mode
102+
### 🌐 HTTP Transport Configuration
70103

71-
The server supports HTTP transport for web-based deployments and microservices:
104+
For custom HTTP configurations beyond the defaults:
72105

73106
```bash
74-
# Basic HTTP mode (defaults: host=127.0.0.1, port=8000, path=/mcp/)
75-
mcp-neo4j-cypher --transport http
76-
77107
# Custom HTTP configuration
78108
mcp-neo4j-cypher --transport http --host 0.0.0.0 --port 8080 --path /api/mcp/
79-
```
80-
81-
Environment variables for HTTP configuration:
82109

83-
```bash
110+
# Or using environment variables
84111
export NEO4J_TRANSPORT=http
85112
export NEO4J_MCP_SERVER_HOST=0.0.0.0
86113
export NEO4J_MCP_SERVER_PORT=8080
87114
export NEO4J_MCP_SERVER_PATH=/api/mcp/
88115
mcp-neo4j-cypher
89116
```
90117

91-
### 🔄 Transport Modes
92-
93-
The server supports three transport modes:
94-
95-
- **STDIO** (default): Standard input/output for local tools and Claude Desktop
96-
- **SSE**: Server-Sent Events for web-based deployments
97-
- **HTTP**: Streamable HTTP for modern web deployments and microservices
98-
99-
#### Multiple Database Example
118+
### Multiple Database Example
100119

101120
Here's an example of connecting to multiple Neo4j databases using namespaces:
102121

@@ -129,27 +148,9 @@ Here's an example of connecting to multiple Neo4j databases using namespaces:
129148
```
130149

131150
In this setup:
132-
- The movies database tools will be prefixed with `movies-` (e.g., `movies-read-neo4j-cypher`)
133-
- The local database tools will be prefixed with `local-` (e.g., `local-get-neo4j-schema`)
134-
135-
Here is an example connection for the movie database with Movie, Person (Actor, Director), Genre, User and ratings:
151+
- The movies database tools will be prefixed with `movies-` (e.g., `movies-read_neo4j_cypher`)
152+
- The local database tools will be prefixed with `local-` (e.g., `local-get_neo4j_schema`)
136153

137-
```json
138-
{
139-
"mcpServers": {
140-
"movies-neo4j": {
141-
"command": "uvx",
142-
"args": [ "[email protected]" ],
143-
"env": {
144-
"NEO4J_URI": "neo4j+s://demo.neo4jlabs.com",
145-
"NEO4J_USERNAME": "recommendations",
146-
"NEO4J_PASSWORD": "recommendations",
147-
"NEO4J_DATABASE": "recommendations"
148-
}
149-
}
150-
}
151-
}
152-
```
153154

154155
Syntax with `--db-url`, `--username`, `--password` and other command line arguments is still supported but environment variables are preferred:
155156

@@ -176,27 +177,13 @@ Syntax with `--db-url`, `--username`, `--password` and other command line argume
176177
"0.0.0.0",
177178
"--server-port",
178179
"8000"
180+
"--server-path",
181+
"/api/mcp/"
179182
]
180183
}
181184
}
182185
```
183186

184-
Here is an example connection for the movie database with Movie, Person (Actor, Director), Genre, User and ratings:
185-
186-
```json
187-
{
188-
"mcpServers": {
189-
"movies-neo4j": {
190-
"command": "uvx",
191-
"args": ["[email protected]",
192-
"--db-url", "neo4j+s://demo.neo4jlabs.com",
193-
"--user", "recommendations",
194-
"--password", "recommendations",
195-
"--database", "recommendations"]
196-
}
197-
}
198-
}
199-
```
200187
</details>
201188

202189
### 🐳 Using with Docker
@@ -212,30 +199,37 @@ Here is an example connection for the movie database with Movie, Person (Actor,
212199
"-e", "NEO4J_USERNAME=neo4j",
213200
"-e", "NEO4J_PASSWORD=<your-password>",
214201
"-e", "NEO4J_NAMESPACE=mydb",
202+
"-e", "NEO4J_TRANSPORT=http",
203+
"-e", "NEO4J_MCP_SERVER_HOST=0.0.0.0",
204+
"-e", "NEO4J_MCP_SERVER_PORT=8000",
205+
"-e", "NEO4J_MCP_SERVER_PATH=/api/mcp/",
215206
"mcp/neo4j-cypher:latest"
216207
]
217208
}
218209
}
219210
```
220211

212+
**Note**: This assumes you've built the image locally with `docker build -t mcp-neo4j-cypher:latest .`. Docker transport defaults to HTTP mode.
213+
221214
## 🐳 Docker Deployment
222215

223-
The Neo4j MCP server can be deployed using Docker for both local development and production use. Docker deployment supports both stdio and SSE transports.
216+
The Neo4j MCP server can be deployed using Docker for remote deployments. Docker deployment uses HTTP transport by default for web accessibility.
224217

225-
### 📦 Pre-built Image
218+
### 📦 Using Your Built Image
226219

227-
Use the pre-built Docker image for quick deployment:
220+
After building locally with `docker build -t mcp-neo4j-cypher:latest .`:
228221

229222
```bash
230-
# Run with SSE transport
223+
# Run with http transport (default for Docker)
231224
docker run --rm -p 8000:8000 \
232225
-e NEO4J_URI="bolt://host.docker.internal:7687" \
233226
-e NEO4J_USERNAME="neo4j" \
234227
-e NEO4J_PASSWORD="password" \
235228
-e NEO4J_DATABASE="neo4j" \
236-
-e NEO4J_TRANSPORT="sse" \
229+
-e NEO4J_TRANSPORT="http" \
237230
-e NEO4J_MCP_SERVER_HOST="0.0.0.0" \
238231
-e NEO4J_MCP_SERVER_PORT="8000" \
232+
-e NEO4J_MCP_SERVER_PATH="/api/mcp/" \
239233
mcp/neo4j-cypher:latest
240234
```
241235

@@ -247,14 +241,15 @@ docker run --rm -p 8000:8000 \
247241
| `NEO4J_USERNAME` | `neo4j` | Neo4j username |
248242
| `NEO4J_PASSWORD` | `password` | Neo4j password |
249243
| `NEO4J_DATABASE` | `neo4j` | Neo4j database name |
250-
| `NEO4J_TRANSPORT` | `stdio` | Transport protocol (`stdio` or `sse`) |
244+
| `NEO4J_TRANSPORT` | `stdio` (local), `http` (Docker) | Transport protocol (`stdio`, `http`, or `sse`) |
251245
| `NEO4J_NAMESPACE` | _(empty)_ | Tool namespace prefix |
252-
| `NEO4J_MCP_SERVER_HOST` | `127.0.0.1` | Host to bind to (use `0.0.0.0` for Docker) |
253-
| `NEO4J_MCP_SERVER_PORT` | `8000` | Port for SSE transport |
246+
| `NEO4J_MCP_SERVER_HOST` | `127.0.0.1` (local), `0.0.0.0` (Docker) | Host to bind to |
247+
| `NEO4J_MCP_SERVER_PORT` | `8000` | Port for HTTP/SSE transport |
248+
| `NEO4J_MCP_SERVER_PATH` | `/api/mcp/` | Path for accessing MCP server |
254249

255-
### 🌐 SSE Transport for Web Access
250+
### 🌐 SSE Transport for Legacy Web Access
256251

257-
When using SSE transport, the server exposes an HTTP endpoint that can be accessed from web browsers or HTTP clients:
252+
When using SSE transport (for legacy web clients), the server exposes an HTTP endpoint:
258253

259254
```bash
260255
# Start the server with SSE transport
@@ -267,7 +262,7 @@ docker run -d -p 8000:8000 \
267262
-e NEO4J_MCP_SERVER_HOST="0.0.0.0" \
268263
-e NEO4J_MCP_SERVER_PORT="8000" \
269264
--name neo4j-mcp-server \
270-
mcp/neo4j-cypher:latest
265+
mcp-neo4j-cypher:latest
271266

272267
# Test the SSE endpoint
273268
curl http://localhost:8000/sse
@@ -306,9 +301,10 @@ services:
306301
- NEO4J_USERNAME=neo4j
307302
- NEO4J_PASSWORD=password
308303
- NEO4J_DATABASE=neo4j
309-
- NEO4J_TRANSPORT=sse
310-
- NEO4J_MCP_SERVER_HOST=0.0.0.0 # must be 0.0.0.0 for sse transport in Docker
304+
- NEO4J_TRANSPORT=http
305+
- NEO4J_MCP_SERVER_HOST=0.0.0.0 # must be 0.0.0.0 for sse or http transport in Docker
311306
- NEO4J_MCP_SERVER_PORT=8000
307+
- NEO4J_MCP_SERVER_PATH=/api/mcp/
312308
- NEO4J_NAMESPACE=local
313309
depends_on:
314310
- neo4j
@@ -321,35 +317,20 @@ Run with: `docker-compose up -d`
321317

322318
### 🔗 Claude Desktop Integration with Docker
323319

324-
For Claude Desktop integration with a Dockerized server using SSE transport:
320+
For Claude Desktop integration with a Dockerized server using http transport:
325321

326322
```json
327323
{
328324
"mcpServers": {
329325
"neo4j-docker": {
330326
"command": "npx",
331-
"args": ["-y", "mcp-remote@latest", "http://localhost:8000/sse"]
327+
"args": ["-y", "mcp-remote@latest", "http://localhost:8000/api/mcp/"]
332328
}
333329
}
334330
}
335331
```
336332

337-
### Local Build
338-
339-
Build and run the Docker container:
340-
341-
```bash
342-
# Build the image
343-
docker build -t mcp/neo4j-cypher:latest .
344-
345-
# Run the container
346-
docker run -e NEO4J_URI="bolt://host.docker.internal:7687" \
347-
-e NEO4J_USERNAME="neo4j" \
348-
-e NEO4J_PASSWORD="your-password" \
349-
-e NEO4J_NAMESPACE="mydb" \
350-
-e NEO4J_TRANSPORT="stdio" \
351-
mcp/neo4j-cypher:latest
352-
```
333+
**Note**: First start your Docker container with HTTP transport, then Claude Desktop can connect to it via the HTTP endpoint.
353334

354335
## 🚀 Development
355336

@@ -370,7 +351,7 @@ cargo install uv
370351
2. Clone the repository and set up development environment:
371352
```bash
372353
# Clone the repository
373-
git clone https://github.com/yourusername/mcp-neo4j-cypher.git
354+
git clone https://github.com/neo4j-contrib/mcp-neo4j.git
374355
cd mcp-neo4j-cypher
375356
376357
# Create and activate virtual environment using uv
@@ -390,31 +371,36 @@ uv pip install -e ".[dev]"
390371

391372
### 🔧 Development Configuration
392373

374+
For development with Claude Desktop using the local source:
375+
393376
```json
394-
# Add the server to your claude_desktop_config.json
395-
"mcpServers": {
396-
"neo4j": {
397-
"command": "uv",
398-
"args": [
399-
"--directory",
400-
"parent_of_servers_repo/servers/mcp-neo4j-cypher/src",
401-
"run",
402-
"mcp-neo4j-cypher",
403-
"--transport",
404-
"stdio",
405-
"--namespace",
406-
"dev",
407-
],
408-
"env": {
409-
"NEO4J_URI": "bolt://localhost",
410-
"NEO4J_USERNAME": "neo4j",
411-
"NEO4J_PASSWORD": "<your-password>",
412-
"NEO4J_DATABASE": "neo4j"
377+
{
378+
"mcpServers": {
379+
"neo4j-dev": {
380+
"command": "uv",
381+
"args": [
382+
"--directory",
383+
"/path/to/mcp-neo4j-cypher",
384+
"run",
385+
"mcp-neo4j-cypher",
386+
"--transport",
387+
"stdio",
388+
"--namespace",
389+
"dev"
390+
],
391+
"env": {
392+
"NEO4J_URI": "bolt://localhost:7687",
393+
"NEO4J_USERNAME": "neo4j",
394+
"NEO4J_PASSWORD": "<your-password>",
395+
"NEO4J_DATABASE": "neo4j"
396+
}
413397
}
414398
}
415399
}
416400
```
417401

402+
Replace `/path/to/mcp-neo4j-cypher` with your actual project directory path.
403+
418404

419405

420406
## 📄 License

0 commit comments

Comments
 (0)