go -mysql
用于MySQL数据库操作的轻量级、生产就绪的模型上下文协议(MCP)服务器。使用Go构建,实现高性能和零运行时依赖性。支持完整的CRUD操作、只读模式和带有解释检查的查询优化。
claude mcp add --transport stdio pengcunfu-go-mcp-mysql go-mcp-mysql --host localhost --user root --pass password --port 3306 --db mydb
How to use
go-mcp-mysql is a single, zero-dependency executable that exposes a MySQL MCP (Model Context Protocol) server. It supports both command-line parameter configuration and DSN-based configuration, allowing you to manage databases, tables, and perform read/write CRUD operations through a set of built-in tools. The server can run in read-only mode to prevent modifications, and you can enable an optional EXPLAIN check to analyze query plans before executing CRUD operations. Tools are organized into database/schema management (e.g., list_database, list_table, create_table, alter_table, desc_table, use_database) and data operations (read_query, write_query, update_query, delete_query). Each tool takes specific arguments (for example, read_query accepts a SELECT statement, create_table accepts a CREATE TABLE statement), and responses reflect the results or affected rows. To run using the command-line configuration shown, ensure the binary is accessible in your PATH and start the server with the specified host, user, password, port, and database, or adjust these parameters to your environment. You can also switch to a DSN string using the --dsn option to connect to your MySQL instance.
How to install
Prerequisites:
- A MySQL server you want to manage
- Optional: a pre-built binary for your OS from the releases page, or a Go 1.21+ environment to build from source
Installation steps (Option 1: download binary):
- Download the appropriate binary from the Releases page: https://github.com/pengcunfu/go-mcp-mysql/releases
- Place the binary in a directory on your PATH, e.g. /usr/local/bin
- Run the server, for example: go-mcp-mysql --host localhost --user root --pass password --port 3306 --db mydb
Installation steps (Option 2: build from source):
- Ensure Go 1.21+ is installed
- Build and install the binary: go install -v github.com/pengcunfu/go-mcp-mysql@latest
- Ensure $GOPATH/bin or your Go binaries directory is in your PATH
- Run the server as above
Configuration options can be provided either via command-line arguments or via a DSN string as described in the README. If you prefer the DSN approach, use --dsn with a DSN formatted string instead of individual --host/--db/etc values.
Additional notes
Tips and notes:
- You can enable read-only mode with --read-only to restrict operations to listing and reading data, preventing modifications.
- If you change configuration flags, you typically need to restart the MCP server for changes to take effect.
- The toolset includes both database/schema management and data operation commands; use list_database/list_table to explore your schema, then use read_query/write_query/update_query/delete_query for CRUD operations.
- For DSN usage, refer to the official MySQL DSN format and ensure parseTime and loc parameters are appropriate for your needs.
- If the binary is not in your PATH, you can provide the absolute path to the binary in the command configuration.
- Security: avoid exposing credentials in logs or publicly accessible configurations.
Related MCP Servers
go
deprecated: use the official MCP sdk! (https://github.com/modelcontextprotocol/go-sdk) / ⚡ A type-safe, intuitive Go SDK for building MCP servers with ease and confidence
sandbox
A Model Context Protocol (MCP) server that enables LLMs to run ANY code safely in isolated Docker containers.
go -mysql
Zero burden, ready-to-use Model Context Protocol (MCP) server for interacting with MySQL and automation. No Node.js or Python environment needed.
mcp-catalog -example
Go MCP server example for AI-agent workflows with tools, resources, and prompts.
miro
MCP server for controlling Miro whiteboards with AI assistants
mcp4go
A comprehensive Go SDK for the Model Context Protocol (MCP) - simplifying AI application development by abstracting away protocol complexities.