mcp-server-sql
这是一个基于Spring Boot的SQL服务应用,用于执行SQL查询并将结果写入文件。该服务作为Spring AI MCP(Model, Chat, Prompt)框架的一部分,提供了SQL查询和更新操作的功能。
Documentation
mcp-server-Sql
项目介绍
这是一个基于Spring Boot的SQL服务应用,用于执行SQL查询并将结果写入文件。该服务作为Spring AI MCP(Model, Chat, Prompt)框架的一部分,提供了SQL查询和更新操作的功能。
功能特性
- 执行SQL查询并将结果写入CSV文件
- 执行SQL更新操作(INSERT, UPDATE, DELETE)并返回影响的行数
- 支持自定义数据库连接配置
- 集成Spring AI MCP框架,可作为AI工具使用
技术栈
- Java 17
- Spring Boot 3.4.3
- Spring AI 1.0.0-M6
- MySQL 8.0
- HikariCP 连接池
- Lombok
快速开始
配置数据库
在`application.yml`文件中配置您的数据库连接信息:
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/your_database?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai
username: your_username
password: your_password构建项目
mvn clean package运行应用
java -jar target/mcp-server-Sql-1.0-SNAPSHOT.jar使用示例
执行SQL查询
{
"sql": "SELECT * FROM users",
"outputPath": "./output/users.csv"
}执行SQL更新操作
{
"sql": "UPDATE users SET name='John' WHERE id=1",
"outputPath": "./output/update_result.txt"
}注意事项
- 确保输出目录存在或有权限创建
- SQL查询结果将以CSV格式保存
- 更新操作结果将包含影响的行数和执行时间
Frequently asked questions
What is mcp-server-sql?
mcp-server-sql is 这是一个基于Spring Boot的SQL服务应用,用于执行SQL查询并将结果写入文件。该服务作为Spring AI MCP(Model, Chat, Prompt)框架的一部分,提供了SQL查询和更新操作的功能。
How do I install mcp-server-sql?
Open the GitHub repository and follow its README. Most MCP servers are added to your client's MCP config, then called by your agent.
Is mcp-server-sql open source?
Yes — it is hosted on GitHub at https://github.com/cherry-SC/mcp-server-sql and has 2 stars.
Related MCP tools
The official Java SDK for Model Context Protocol servers and clients. Maintained in collaboration with Spring AI Trusted by 2800+ developers.
Plugin for JADX to integrate MCP server Java-based implementation. Trusted by 600+ developers. Trusted by 600+ developers.
🤖 The Semantic Engine for Model Context Protocol(MCP) Clients and AI Agents 🔥 Java-based implementation.
MCP Server for Ghidra Java-based implementation. Trusted by 6400+ developers. Trusted by 6400+ developers. Trusted by 6400+ developers.
A library for communication with a Minecraft client/server. Built for the Model Context Protocol to enhance AI capabilities. Java-based implementation.
🙌 OpenHands: Code Less, Make More for the Model Context Protocol. Enhance AI assistants with powerful integrations. Python-based implementation.
Run your own MCP server? See who uses it and what to fix.
Measure it with TrackMCP