mcp-mysql
A Spring AI-based MCP capable of executing any SQL query. 一个基于 Spring AI 的MCP服务,可执行任意 SQL。
claude mcp add --transport stdio jamessmith888-mcp-mysql-server /Users/xin.y/IdeaProjects/mcp-mysql-server/mvnw -q -f /Users/xin.y/IdeaProjects/mcp-mysql-server/pom.xml spring-boot:run
How to use
This MCP server implements a Spring-based MCP that can execute arbitrary SQL against configured MySQL data sources. It supports multiple data sources, dynamic runtime switching between them, and optional Groovy script extensions for custom functionality. It also includes SQL safety controls to prevent potentially dangerous operations by automated models. To use it, configure one or more data sources, then deploy the server and interact with its SQL execution endpoints through the MCP framework. The server exposes configuration and extension points via the standard MCP data model, allowing you to reference different databases by name and apply environment-specific settings as needed.
Key capabilities include:
- Multiple data sources: define and manage several MySQL databases and designate a default source.
- Dynamic data source switching: switch between data sources at runtime for different queries or environments.
- Groovy extensions: extend or customize behaviors using Groovy scripts loaded from the configured loader path.
- SQL safety: built-in policies to constrain dangerous SQL, helping to reduce risk when running AI-generated queries.
How to install
Prerequisites:
- JDK 21+ installed on your machine
- Maven (or use the Maven wrapper that ships with the project)
- Access to a MySQL instance (or multiple) for the configured data sources
Installation steps (two common approaches):
- Using Maven Wrapper (recommended for Maven-based builds):
- Clone the repository: git clone <repository-url>
- Navigate to the project directory: cd mcp-mysql
- Run the server via Maven Wrapper (as shown in the MCP JSON example): ./mvnw -q -f pom.xml spring-boot:run
- Build a standalone JAR and run with Java:
- Build the jar: ./mvnw clean package
- Run the built jar (example using the jar produced at the target path): java -Dloader.path=/path/to/config/groovy -jar target/mcp-mysql-server-0.0.1-SNAPSHOT.jar
Notes:
- If you need to load Groovy extensions, set -Dloader.path to the directory containing your Groovy scripts as shown above. This is optional and only required if you use the extension features.
Additional notes
Tips and common considerations:
- Ensure the MySQL data sources are correctly defined in datasource.yml (or the equivalent configuration) and that the database URLs, usernames, and passwords are accurate.
- The -Dloader.path parameter is optional and only necessary when using Groovy script extensions.
- Check the documentation links in the README for detailed guidance on extensions, datasource configurations, and SQL security policies.
- Ensure Java 21+ and Maven are available in your environment when building from source.
- If you encounter port or connection issues, verify firewall rules and MySQL user permissions for the configured hosts.
- When using the MCP JSON, you can swap between the Maven wrapper start and the jar start depending on your deployment preference.
Related MCP Servers
langchain4j-aideepin
基于AI的工作效率提升工具(聊天、绘画、知识库、工作流、 MCP服务市场、语音输入输出、长期记忆) | Ai-based productivity tools (Chat,Draw,RAG,Workflow,MCP marketplace, ASR,TTS, Long-term memory etc)
mysql_mcp_server
A Model Context Protocol (MCP) server that enables secure interaction with MySQL databases
spring-ai-summary
SpringAI,LLM,MCP,Embedding
mcp-mianshiya
基于 Spring AI 的面试鸭搜索题目的 MCP Server 服务,快速让 AI 搜索企业面试真题和答案
AgentNexus
Multi-Agent,MCP,RAG,SpringAI1.0.0,RE-ACT
WigAI
Bitwig Controller Extension that provides an MCP Server for AI Agent control