mcp-neo4j-服务器-sse-java
mcp-neo4j-servers-se-java是一个使用java实现的mcp服务器 SSE (服务器发送事件)服务器传输或 STDIO 传输作为传输协议。
概述
一种模型上下文协议(MCP)服务器实现,提供数据库交互,并允许通过Neo4j进行图形探索。此服务器支持执行Cypher图查询、分析复杂的域数据,并支持选择远程可访问的数据库。灵感来自 neo4j控件/mcpneo4j.
该项目展示了:
- 与集成
spring-ai-mcp-server-webflux-spring-boot-starter - 支持SSE(服务器发送事件)和STDIO传输
- 使用Spring AI的自动工具注册
@Tool注释
提示
服务器提供演示提示:
mcp-demo:交互式提示,引导用户完成数据库操作
- 生成适当的数据库模式和示例数据
工具
服务器提供六个核心工具:
查询工具
read-neo4j-cypher
- 执行Cypher读取查询以从数据库读取数据 - 输入: - query (string):要执行的Cypher查询 - 返回:查询结果为对象数组
write-neo4j-cypher
- 执行更新Cypher查询 - 输入: - query (string):Cypher更新查询 - 返回:一个结果摘要计数器 { nodes_updated: number, relationships_created: number, ... }
架构工具
get-neo4j-schema
- 获取图形数据库中所有节点类型的列表,以及它们的名称、类型和与其他节点类型的关系 - 无需输入 - 返回:包含两个字典的节点标签列表,一个用于属性,另一个用于关系
使用Cline客户端
1.克隆存储库
git clone https://github.com/dsimile/mcp-neo4j-server-sse-java.git2.建设项目
- Java 17+
cd mcp-neo4j-server-sse-java
mvn clean install -DskipTests3.运行服务器
- WebFlux SSE模式(默认)
- spring.ai.mcp.server.stadio(默认):false - 服务器ip(默认):0.0.0.0 - 服务器端口(默认):8543 - Neo 4 J URI(默认):Neo 4 J://localhost:7687 - Neo4j用户名(默认):Neo4j - Neo4j密码(默认):Neo4j - Neo4j数据库(默认):Neo4j
java -jar target/mcp-neo4j-server-sse-java-1.0-SNAPSHOT.jar- STDIO模式
要启用STDIO传输,请设置相应的属性:
java -Dspring.ai.mcp.server.stdio=true \
-Dspring.main.web-application-type=none \
-Dneo4j.uri=neo4j://localhost:7687 \
-Dneo4j.username=neo4j \
-Dneo4j.password= \
-Dneo4j.database= \
-Dlog.path=/absolute/path/to/ \
-jar target/mcp-neo4j-server-sse-java-1.0-SNAPSHOT.jar注意:请确保Neo4j正在运行并且可用于远程连接。
已发布包
将服务器添加到您的 cline_mcp_settings.json.
- WebFlux SSE模式(默认)
{
"mcpServers": {
"neo4j-remote": {
"url": "http://0.0.0.0:8543/sse",
"disabled": false,
"autoApprove": []
}
}
}- STDIO模式
{
"mcpServers": {
"neo4j-local": {
"disabled": false,
"command": "java",
"args": [
"-Dspring.ai.mcp.server.stdio=true",
"-Dspring.main.web-application-type=none",
"-Dneo4j.uri=neo4j://localhost:7687",
"-Dneo4j.username=neo4j",
"-Dneo4j.password=",
"-Dneo4j.database=",
"-Dlog.path=/absolute/path/to/",
"-jar",
"/absolute/path/to/mcp-neo4j-server-sse-java-1.0-SNAPSHOT.jar"
],
"transportType": "stdio"
}
}
}替换 /absolute/path/to/ 使用构建的jar文件或日志文件的实际路径。
许可证
此MCP服务器根据MIT许可证获得许可。这意味着您可以根据MIT许可证的条款和条件自由使用、修改和分发软件。有关更多详细信息,请参阅项目存储库中的LICENSE文件。
