mcpField
M
MCP MySQL Server

MCP MySQL Server

Local
github.com/JamesSmith888Databases26Updated 59w ago

About MCP MySQL Server

An MCP server built on Spring AI that can execute arbitrary SQL queries against MySQL. It suits developers who want AI models to work with MySQL databases and includes SQL safety controls to block dangerous operations.

Key features

  1. 01Executes arbitrary SQL statements
  2. 02Configures multiple data sources
  3. 03Switches data sources at runtime
  4. 04Extends functionality through Groovy scripts
  5. 05SQL safety controls block dangerous operations

Use cases

  1. 01Letting AI models query MySQL databases
  2. 02Switching between several databases during queries
  3. 03Adding custom database operations through Groovy scripts

MCP support

This project is an MCP server that exposes SQL execution to MCP clients.

Configuration

Local server config is the same for every client. Copy it into your client’s MCP config file.

No install method listed yet

We haven’t collected a package or remote endpoint for this server. Follow the instructions in the project README.

Repository

Tools

No tool list yet

Local servers expose tools only once running on your machine, and the maintainer has not provided a tool list.

Details

From the project README

MCP MySQL Server

一个基于 Spring AI 的MCP,可执行任意 SQL。

关于其他数据库支持,请查看 mcp-db-server

中文文档 | English Documentation

快速上手

1. MCP JSON 配置
方式一:Maven Wrapper 启动
{
  "mcpServers": {
    "mcp-mysql-server": {
      "command": "/Users/xin.y/IdeaProjects/mcp-mysql-server/mvnw",
      "args": [
        "-q",
        "-f",
        "/Users/xin.y/IdeaProjects/mcp-mysql-server/pom.xml",
        "spring-boot:run"
      ]
    }
  }
}
方式二:JAR 包启动

构建jar

./mvnw clean package

配置MCP服务器

{
  "mcpServers": {
    "mcp-mysql-server": {
      "command": "java",
      "args": [
        "-Dloader.path=/Users/xin.y/IdeaProjects/mcp-mysql-server/src/main/resources/groovy",
        "-jar",
        "/Users/xin.y/IdeaProjects/mcp-mysql-server/target/mcp-mysql-server-0.0.1-SNAPSHOT.jar"
      ]
    }
  }
}

注意: -Dloader.path 参数为可选,仅在需要运行扩展功能时才需要指定。

2. 数据源配置

修改 mcp-mysql-server/src/main/resources/datasource.yml 文件:

datasource:
  datasources:
    your_db1_name:
      url: jdbc:mysql://localhost:3306/db1
      username: root
      password: password
      default: true  # 标记为默认数据源

功能特点

  • 多数据源支持 - 配置和管理多个数据库数据源
  • 动态数据源切换 - 运行时动态切换不同的数据源
  • 扩展功能 - 通过 Groovy 脚本扩展功能
  • SQL 安全控制 - 防止 AI 模型执行危险 SQL 操作

详细文档

文档描述
扩展功能文档Groovy 脚本扩展的详细配置和开发指南
数据源配置文档数据源的详细配置、多环境管理和最佳实践
SQL 安全控制文档SQL 安全策略的配置和管理

环境要求

  • JDK 21+
  • Maven 3.6+

Comments

Markdown supported

New to MCP?

From what the protocol is to installing your first server, these answers cover most first questions.

An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.