go-mcp-mysql is a zero-burden, out-of-the-box Model Context Protocol (MCP) server for interacting with and automating MySQL. It is written in Go and does not require a Node.js or Python environment.
Purpose
The server provides MCP clients (such as AI assistants) with tools for operating a MySQL database, supports CRUD operations on databases and tables, and can prevent accidental write operations through read-only mode.
Main capabilities
- Provides tools such as list_database, list_table, and desc_table for viewing databases and table structures.
- Provides tools such as create_table, alter_table, read_query, write_query, update_query, and delete_query for executing SQL operations.
- Supports read-only mode: after adding the --read-only flag, only tools starting with list, read_, and desc_ are available.
- Supports query plan checking: by default, CRUD queries first execute an EXPLAIN ? statement to check whether the query plan matches expectations; adding the --with-explain-check flag disables this behavior.
Usage
- Obtain the latest release version and place it in $PATH or a location that is easy to access.
- If Go is already installed, it can also be built from source.
- There are two configuration methods: Method A uses command-line arguments; Method B uses a DSN with custom options. For details, please refer to the MySQL DSN documentation.
- If the binary file is not in $PATH, replace go-mcp-mysql with the full path to the binary file.
- Add the --read-only flag to enable read-only mode; after adding it, the MCP server needs to be refreshed/restarted.
- Add the --with-explain-check flag to disable the default EXPLAIN check.
Applicable scenarios
Suitable for scenarios where AI assistants or automation tools need to safely query and operate a MySQL database through the MCP protocol, and especially suitable for environments where accidental write operations should be avoided.
Limitations
This project is still under development and may not yet be ready for production use.