Skip to content

Commit

Permalink
moved mcp-server-neo4j from neo4j-contrib/modelcontextprotocol-server…
Browse files Browse the repository at this point in the history
…s to here
  • Loading branch information
akollegger committed Dec 4, 2024
1 parent 4bd52cf commit 166a814
Show file tree
Hide file tree
Showing 14 changed files with 713 additions and 0 deletions.
2 changes: 2 additions & 0 deletions DEVELOP.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

[Learn more about this workspace setup and its capabilities](https://nx.dev/nx-api/node?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects) or run `npx nx graph` to visually explore what was created. Now, let's get you up to speed!

Include python support via [@nxlv/python plugin](https://github.com/lucasvieirasilva/nx-plugins/tree/main/packages/nx-python)

## Finish your CI setup

[Click here to finish setting up your workspace!](https://cloud.nx.app/connect/Wx1erwy80w)
Expand Down
3 changes: 3 additions & 0 deletions nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
"servers/mcp-neo4j-memory-e2e/**/*",
"servers/mcp-json-memory-e2e/**/*"
]
},
{
"plugin":"@nxlv/python"
}
],
"release": {
Expand Down
98 changes: 98 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"@nx/js": "20.1.4",
"@nx/node": "20.1.4",
"@nx/workspace": "20.1.4",
"@nxlv/python": "^20.0.1",
"@swc-node/register": "~1.9.1",
"@swc/core": "~1.5.7",
"@swc/helpers": "~0.5.11",
Expand Down
1 change: 1 addition & 0 deletions servers/mcp-json-memory/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"files": [],
"include": [],
"references": [
// @ts-ignore -> https://github.com/nrwl/nx/issues/27292
{
"path": "./tsconfig.app.json"
},
Expand Down
11 changes: 11 additions & 0 deletions servers/mcp-neo4j-cypher/.flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[flake8]
exclude =
.git,
__pycache__,
build,
dist,
.tox,
venv,
.venv,
.pytest_cache
max-line-length = 120
1 change: 1 addition & 0 deletions servers/mcp-neo4j-cypher/.python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12.7
62 changes: 62 additions & 0 deletions servers/mcp-neo4j-cypher/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Neo4j MCP Server

## 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 with Claude's analysis when an Anthropic API key is provided.

## Components

### Resources

### Prompts
The server provides a demonstration prompt:
- `mcp-demo`: Interactive prompt that guides users through database operations
- Generates appropriate database schemas and sample data

### Tools
The server offers six core tools:

#### Query Tools
- `read-neo4j-cypher`
- Execute Cypher read queries to read data from the database
- Input:
- `query` (string): The Cypher query to execute
- Returns: Query results as array of objects

- `write-neo4j-cypher`
- Execute updating Cypher queries
- Input:
- `query` (string): The Cypher update query
- Returns: a result summary counter with `{ nodes_updated: number, relationships_created: number, ... }`

#### 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
- No input required
- Returns: List of node label with two dictionaries one for attributes and one for relationships

## Usage with Claude Desktop

```bash
# Add the server to your claude_desktop_config.json
"mcpServers": {
"neo4j": {
"command": "uv",
"args": [
"--directory",
"parent_of_servers_repo/servers/src/neo4j",
"run",
"mcp-server-neo4j",
"--db-url",
"bolt://localhost",
"--username",
"neo4j",
"--password",
"<your-password>"
]
}
}
```

## 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.
17 changes: 17 additions & 0 deletions servers/mcp-neo4j-cypher/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[project]
name = "mcp-server-neo4j"
version = "0.5.1"
description = "A simple neo4j MCP server"
readme = "README.md"
requires-python = ">=3.10"
dependencies = ["mcp>=0.9.1", "neo4j>=5.26.0"]

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.uv]
dev-dependencies = ["pyright>=1.1.389"]

[project.scripts]
mcp-server-neo4j = "mcp_server_neo4j:main"
25 changes: 25 additions & 0 deletions servers/mcp-neo4j-cypher/src/mcp_server_neo4j/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from . import server
import asyncio
import argparse
import os


def main():
"""Main entry point for the package."""
parser = argparse.ArgumentParser(description='Neo4j MCP Server')
parser.add_argument('--db-url',
default="bolt://localhost:7687",
help='Neo4j connection URL')
parser.add_argument('--username',
default="neo4j",
help='Neo4j username')
parser.add_argument('--password',
default="password",
help='Neo4j password')

args = parser.parse_args()
asyncio.run(server.main(args.db_url, args.username, args.password))


# Optionally expose other important items at package level
__all__ = ["main", "server"]
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit 166a814

Please sign in to comment.