Go MCP MySQL Server

Provides CRUD-style access and read-only querying to MySQL via MCP with optional query plan checks.
  • go

47

GitHub Stars

go

Language

6 months ago

First Indexed

2 months ago

Catalog Refreshed

Documentation & install

Readme and setup notes from the catalogue, plus a client-ready config you can copy for your MCP host.

Installation

Add the following to your MCP client configuration file.

Configuration

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

You can run a lightweight MCP server in Go to interact with MySQL databases via CRUD operations and read-only access. It supports optional query analysis with EXPLAIN and can be used without a Node.js or Python environment. This guide shows practical steps to install, configure, and use the server with an MCP client, including both standard command-line argument usage and DSN-based configuration.

How to use

Set up the MCP client to connect to the Go MCP MySQL server and perform common actions like listing databases, creating tables, reading data, or updating records. You can enable read-only mode to restrict available operations and use the explain-check feature to validate query plans before execution.

Two standard MCP connection configurations are available. You can choose either a direct command-line style configuration or a DSN-based configuration. Both configurations assume the MCP server is installed and accessible on your system.

Example: connect via command-line style arguments and enable a typical set of CRUD tools. Use the configuration below in your MCP client to register the server under the name mysql.

Config examples you can use with your MCP client

{
  "mcpServers": {
    "mysql_args": {
      "command": "go-mcp-mysql",
      "args": [
        "--host", "localhost",
        "--user", "root",
        "--pass", "password",
        "--port", "3306",
        "--db", "mydb"
      ]
    },
    "mysql_dsn": {
      "command": "go-mcp-mysql",
      "args": [
        "--dsn", "username:password@tcp(localhost:3306)/mydb?parseTime=true&loc=Local"
      ]
    }
  }
}

Enable read-only mode and explain checks

To prevent write operations, start the server with the read-only option. In read-only mode, only list, read, and describe tools are available. After enabling this flag, restart the MCP server for the change to take effect.

By default, CRUD queries are first attempted with an EXPLAIN check to verify the query plan. If you want to bypass this safety check, use the specific flag to disable explain checking when starting the server.

Available tools

list_database

List all databases on the MySQL server. Returns a list of matching database names.

list_table

List all tables in the MySQL server. If a name is provided, list tables matching that name, otherwise list all tables.

create_table

Create a new table in the MySQL server. Provide the SQL query to define the table. Returns the number of rows affected.

alter_table

Alter an existing table. The MCP is instructed not to drop existing tables or columns. Returns the number of rows affected.

desc_table

Describe the structure of a specified table and return its schema.

read_query

Execute a read-only SQL query and return the result.

write_query

Execute a write SQL query. Returns the number of rows affected and the last insert id if applicable.

update_query

Execute an update SQL query. Returns the number of rows affected.

delete_query

Execute a delete SQL query. Returns the number of rows affected.

Built by
VeilStrat
AI signals for GTM teams
© 2026 VeilStrat. All rights reserved.All systems operational