Skip to content

Commit 6760480

Browse files
a-s-g93jexp
andauthored
Refactor mcp neo4j cypher (#13)
* refactor cypher mcp * broken neo4j driver impl. going to try Server class * add env config for driver * fix healthcheck * add env support with cli, add changelog, test with claude desktop and inspector * implement json responses for tools * add default serializer to write results * Update CHANGELOG.txt --------- Co-authored-by: Michael Hunger <[email protected]>
1 parent 05567fa commit 6760480

File tree

8 files changed

+310
-168
lines changed

8 files changed

+310
-168
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# test mcp-neo4j-cypher with a local database and Inspector
2+
npx @modelcontextprotocol/inspector uv --directory src/mcp_neo4j_cypher run mcp-neo4j-cypher --db-url bolt://localhost:7687 --username neo4j --password password --database neo4j

servers/mcp-neo4j-cypher/pyproject.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ version = "0.1.2"
44
description = "A simple Neo4j MCP server"
55
readme = "README.md"
66
requires-python = ">=3.10"
7-
dependencies = ["mcp>=1.6.0", "neo4j>=5.26.0"]
7+
dependencies = [
8+
"mcp[cli]>=1.6.0",
9+
"neo4j>=5.26.0",
10+
"pydantic>=2.10.1",
11+
]
812

913
[build-system]
1014
requires = ["hatchling"]
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"venvPath": ".",
3+
"venv": ".venv"
4+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
## Next
2+
3+
### Fixed
4+
5+
### Changed
6+
7+
* Refactor mcp-neo4j-cypher to use the FastMCP class
8+
* Implement Neo4j async driver
9+
* Tool responses now return JSON serialized results
10+
11+
### Added
12+
13+
* Add support for environment variables
14+
15+
16+
## v0.1.1
17+
18+
...

servers/mcp-neo4j-cypher/src/mcp_neo4j_cypher/__init__.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,23 @@
66

77
def main():
88
"""Main entry point for the package."""
9-
parser = argparse.ArgumentParser(description='Neo4j Cypher MCP Server')
10-
parser.add_argument('--db-url',
11-
default="bolt://localhost:7687",
12-
help='Neo4j connection URL')
13-
parser.add_argument('--username',
14-
default="neo4j",
15-
help='Neo4j username')
16-
parser.add_argument('--password',
17-
default="password",
18-
help='Neo4j password')
19-
9+
parser = argparse.ArgumentParser(description="Neo4j Cypher MCP Server")
10+
parser.add_argument("--db-url", default=None, help="Neo4j connection URL")
11+
parser.add_argument("--username", default=None, help="Neo4j username")
12+
parser.add_argument("--password", default=None, help="Neo4j password")
13+
parser.add_argument("--database", default=None, help="Neo4j database name")
14+
2015
args = parser.parse_args()
21-
asyncio.run(server.main(args.db_url, args.username, args.password))
16+
asyncio.run(
17+
server.main(
18+
args.db_url or os.getenv("NEO4J_URI", "bolt://localhost:7687"),
19+
args.username or os.getenv("NEO4J_USERNAME", "neo4j"),
20+
args.password or os.getenv("NEO4J_PASSWORD", "password"),
21+
args.database or os.getenv("NEO4J_DATABASE", "neo4j"),
22+
)
23+
)
24+
25+
# asyncio.run(server.main())
2226

2327

2428
# Optionally expose other important items at package level

0 commit comments

Comments
 (0)