go-mcp-mysql

go-mcp-mysql

Zero-burden Model Context Protocol (MCP) server for MySQL automation.

46
Stars
9
Forks
46
Watchers
1
Issues
go-mcp-mysql is a ready-to-use server that implements the Model Context Protocol (MCP) for seamless interaction and automation with MySQL databases. Written in Go, it enables users to perform CRUD operations and check query plans without requiring a Node.js or Python environment. The server supports both command-line and DSN configurations, includes a read-only mode, and features a set of tools for managing schema and data. It is designed for low-overhead deployment and flexible MySQL automation workflows.

Key Features

Zero-dependency Model Context Protocol server
Full CRUD operations on MySQL
Read-only mode for safe database access
Query plan verification via EXPLAIN statements
Support for command-line and DSN configuration
Schema management tools (list, create, alter, describe tables)
Data management tools (read, write, update, delete queries)
Easy binary installation and Go build support
Returns structured outputs for programmatic integration
Designed for automation and flexible workflow support

Use Cases

Automating MySQL database management through an MCP interface
Providing secure, read-only database access to large language models
Integrating with AI agents that require standardized context protocol for data
Batch schema migrations or modifications across MySQL databases
Developing tooling for safe SQL query execution with plan checks
Enabling remote and zero-burden MySQL database operations
Implementing automated CRUD workflows for apps or pipelines
Assisting data teams with rapid schema introspection and manipulation
Integrating database management tasks into CI/CD pipelines
Offering managed MySQL access in environments without Node.js or Python

README

go-mcp-mysql

Trust Score

Overview

Zero burden, ready-to-use Model Context Protocol (MCP) server for interacting with MySQL and automation. No Node.js or Python environment needed. This server provides tools to do CRUD operations on MySQL databases and tables, and a read-only mode to prevent surprise write operations. You can also make the MCP server check the query plan by using a EXPLAIN statement before executing the query by adding a --with-explain-check flag.

Please note that this is a work in progress and may not yet be ready for production use.

Installation

  1. Get the latest release and put it in your $PATH or somewhere you can easily access.

  2. Or if you have Go installed, you can build it from source:

sh
go install -v github.com/Zhwt/go-mcp-mysql@latest

Usage

Method A: Using Command Line Arguments

json
{
  "mcpServers": {
    "mysql": {
      "command": "go-mcp-mysql",
      "args": [
        "--host", "localhost",
        "--user", "root",
        "--pass", "password",
        "--port", "3306",
        "--db", "mydb"
      ]
    }
  }
}

Method B: Using DSN With Custom Options

json
{
  "mcpServers": {
    "mysql": {
      "command": "go-mcp-mysql",
      "args": [
        "--dsn", "username:password@tcp(localhost:3306)/mydb?parseTime=true&loc=Local"
      ]
    }
  }
}

Please refer to MySQL DSN for more details.

Note: For those who put the binary outside of your $PATH, you need to replace go-mcp-mysql with the full path to the binary: e.g.: if you put the binary in the Downloads folder, you may use the following path:

json
{
  "mcpServers": {
    "mysql": {
      "command": "C:\\Users\\<username>\\Downloads\\go-mcp-mysql.exe",
      "args": [
        ...
      ]
    }
  }
}

Optional Flags

  • Add a --read-only flag to enable read-only mode. In this mode, only tools beginning with list, read_ and desc_ are available. Make sure to refresh/restart the MCP server after adding this flag.
  • By default, CRUD queries will be first executed with a EXPLAIN ? statement to check whether the generated query plan matches the expected pattern. Add a --with-explain-check flag to disable this behavior.

Tools

Schema Tools

  1. list_database

    • List all databases in the MySQL server.
    • Parameters: None
    • Returns: A list of matching database names.
  2. list_table

    • List all tables in the MySQL server.
    • Parameters:
      • name: If provided, list tables with the specified name, same as SQL SHOW TABLES LIKE '%name%'. Otherwise, list all tables.
    • Returns: A list of matching table names.
  3. create_table

    • Create a new table in the MySQL server.
    • Parameters:
      • query: The SQL query to create the table.
    • Returns: x rows affected.
  4. alter_table

    • Alter an existing table in the MySQL server. The LLM is informed not to drop an existing table or column.
    • Parameters:
      • query: The SQL query to alter the table.
    • Returns: x rows affected.
  5. desc_table

    • Describe the structure of a table.
    • Parameters:
      • name: The name of the table to describe.
    • Returns: The structure of the table.

Data Tools

  1. read_query

    • Execute a read-only SQL query.
    • Parameters:
      • query: The SQL query to execute.
    • Returns: The result of the query.
  2. write_query

    • Execute a write SQL query.
    • Parameters:
      • query: The SQL query to execute.
    • Returns: x rows affected, last insert id: <last_insert_id>.
  3. update_query

    • Execute an update SQL query.
    • Parameters:
      • query: The SQL query to execute.
    • Returns: x rows affected.
  4. delete_query

    • Execute a delete SQL query.
    • Parameters:
      • query: The SQL query to execute.
    • Returns: x rows affected.

License

MIT

Star History

Star History Chart

Repository Owner

Zhwt
Zhwt

User

Repository Details

Language Go
Default Branch master
Size 17 KB
Contributors 3
License MIT License
MCP Verified Nov 12, 2025

Programming Languages

Go
100%

Tags

Topics

mcp mcp-server model-context-protocol mysql

Join Our Newsletter

Stay updated with the latest AI tools, news, and offers by subscribing to our weekly newsletter.

We respect your privacy. Unsubscribe at any time.

Related MCPs

Discover similar Model Context Protocol servers

  • MCP 数据库工具 (MCP Database Utilities)

    MCP 数据库工具 (MCP Database Utilities)

    A secure bridge enabling AI systems safe, read-only access to multiple databases via unified configuration.

    MCP Database Utilities provides a secure, standardized service for AI systems to access and analyze databases like SQLite, MySQL, and PostgreSQL using a unified YAML-based configuration. It enforces strict read-only operations, local processing, and credential protection to ensure data privacy and integrity. The tool is suitable for entities focused on data privacy and minimizes risks by isolating database connections and masking sensitive data. Designed for easy integration, it supports multiple installation options and advanced capabilities such as schema analysis and table browsing.

    • 85
    • MCP
    • donghao1393/mcp-dbutils
  • VictoriaMetrics MCP Server

    VictoriaMetrics MCP Server

    Model Context Protocol server enabling advanced monitoring and observability for VictoriaMetrics.

    VictoriaMetrics MCP Server implements the Model Context Protocol (MCP) to provide seamless integration with VictoriaMetrics, allowing advanced monitoring, data exploration, and observability. It offers access to almost all read-only APIs, as well as embedded documentation for offline usage. The server facilitates comprehensive metric querying, cardinality analysis, alert and rule testing, and automation capabilities for engineers and tools.

    • 87
    • MCP
    • VictoriaMetrics-Community/mcp-victoriametrics
  • mcp-difyworkflow-server

    mcp-difyworkflow-server

    MCP server for managing and executing multiple Dify workflows on demand.

    mcp-difyworkflow-server is an MCP-compliant server tool that facilitates the querying and invocation of custom Dify workflows. It supports dynamic execution of multiple workflows by interfacing with the Dify platform, enabling users to manage workflow credentials and operations efficiently. Configuration allows mapping of workflows to API keys, and commands to list or execute available workflows are provided.

    • 58
    • MCP
    • gotoolkits/mcp-difyworkflow-server
  • mcp-gopls

    mcp-gopls

    MCP server bridging Go's LSP and AI assistants for advanced code analysis.

    Implements a Model Context Protocol (MCP) server enabling AI assistants to interact with the Go Language Server Protocol (LSP) for analyzing and understanding Go code. Provides tools for navigation, diagnostics, references, hover info, completion suggestions, and code coverage. Integrates with 'gopls' to deliver precise code intelligence tailored for AI-driven workflows. Designed for seamless integration with platforms that support MCP, including AI development assistants.

    • 48
    • MCP
    • hloiseaufcms/mcp-gopls
  • godoc-mcp-server

    godoc-mcp-server

    Provides Go package documentation from pkg.go.dev to LLMs as an MCP server.

    godoc-mcp-server enables searching Golang packages and obtains their documentation from pkg.go.dev, serving the information to language models via the Model Context Protocol. Communication occurs over standard input/output, supporting efficient retrieval of package information, including support for subpackages and usage instructions. The tool includes local caching and features tailored to LLM integration scenarios.

    • 32
    • MCP
    • yikakia/godoc-mcp-server
  • domain-lookup-mcp

    domain-lookup-mcp

    MCP server for domain name lookup using RDAP and WHOIS.

    Provides an MCP-compliant server that allows clients to perform domain name lookups via RDAP and WHOIS protocols. The tool is built in Go and can be directly integrated with any MCP client configuration. It automates the retrieval of domain registration details, streamlining the process of accessing authoritative domain information.

    • 5
    • MCP
    • dotemacs/domain-lookup-mcp
  • Didn't find tool you were looking for?

    Be as detailed as possible for better results