MCP MySQL Server
@JamesSmith888
A Spring AI-based MCP capable of executing any SQL query. 一个基于 Spring AI 的MCP服务,可执行任意 SQL。
Overview
What is MCP MySQL Server?
MCP MySQL Server is a Spring AI based MCP (Model Context Protocol) server that can execute arbitrary SQL queries on MySQL databases. It supports multiple datasources, dynamic switching, Groovy script extensions, and SQL security controls. It is intended for developers integrating AI models with MySQL databases.
How to use MCP MySQL Server?
Configure the MCP server in JSON by either using Maven Wrapper (mvnw spring-boot:run) or running a packaged JAR (java -jar ...). Supply the -Dloader.path argument to enable extended Groovy features. Then set up datasources in datasource.yml, marking one as default with default: true.
Key features of MCP MySQL Server
- Multi-datasource support (configure multiple MySQL databases)
- Dynamic datasource switching at runtime
- Groovy script based extension functionality
- SQL security control (prevents dangerous operations)
- Built on Spring AI framework
Use cases of MCP MySQL Server
- Allow an AI assistant to query a MySQL database on demand.
- Manage multiple database connections and switch between them dynamically.
- Extend query capabilities with custom Groovy scripts for specific business logic.
- Safely expose SQL operations to AI models while preventing harmful statements.
FAQ from MCP MySQL Server
What does MCP MySQL Server do?
It is a Spring AI based MCP server that enables AI models to execute arbitrary SQL on configured MySQL databases.
How do I configure datasources?
Edit mcp-mysql-server/src/main/resources/datasource.yml and specify the JDBC URL, username, password, and optionally set one datasource as default: true.
What are the runtime requirements?
JDK 21+ and Maven 3.6+ are required.
Can MCP MySQL Server work with other databases?
No, it is MySQL specific. For other databases, please see the related mcp-db-server project.
How do I enable advanced extensions?
Use the -Dloader.path argument when starting via JAR to point to a directory containing Groovy scripts.