MySQL

mcp server accessing MySQL database
  • javascript

6

GitHub Stars

javascript

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": {
    "xiangma9712-mysql-mcp-server": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "--add-host=host.docker.internal:host-gateway",
        "--env-file",
        "/Users/username/.mcp/.env",
        "ghcr.io/xiangma9712/mcp/mysql"
      ],
      "env": {
        "MYSQL_HOST": "host.docker.internal",
        "MYSQL_PORT": "3306",
        "MYSQL_USER": "root",
        "MYSQL_PASSWORD": "your_password"
      }
    }
  }
}

You can use this MCP server to interact with a MySQL database by executing read-only queries and test-run write queries that are rolled back. It provides safe, isolated access to your MySQL data from an MCP client, making it ideal for exploration, reporting, and validating queries without altering production data.

How to use

You will connect to the MCP server from an MCP client and send commands that specify the operation you want to perform. Use the available capabilities to list tables, describe a table, run read-only queries, or test write queries to verify behavior without persisting changes. The server runs inside Docker and connects to a MySQL instance using the credentials and host details you supply in an environment file. Ensure your MySQL instance is reachable from the container and that network settings allow the container to access it.

Typical workflows include listing the tables to understand the schema, describing a particular table to inspect columns, and running a select query to retrieve data. For testing scenarios, you can execute a data-modifying statement in a test mode; the operation will be rolled back to avoid real changes.

How to install

Prerequisites you need on your machine:

  • Install Docker from the official site and start the daemon.
  • Verify by running docker --version and docker info.

Create an environment file with your MySQL connection details and place it at the path shown in the example, or adjust the path accordingly.

Next, configure the MCP server entry to reference the Docker-based MySQL MCP image.

mcp.json

{ "mcpServers": { "mysql": { "command": "docker", "args": [ "run", "-i", "--rm", "--add-host=host.docker.internal:host-gateway", "--env-file", "/Users/username/.mcp/.env", "ghcr.io/xiangma9712/mcp/mysql" ] } } }

## Additional setup steps

Prepare your environment file with the MySQL connection details you want to use from the container. The file should define the following variables:

MYSQL_HOST=host.docker.internal # Hostname to access host services from Docker container MYSQL_PORT=3306 MYSQL_USER=root MYSQL_PASSWORD=your_password

Note: host.docker.internal is used to access host machine services from Docker containers. Use this setting when connecting to a MySQL server running on your host machine. If you are connecting to a different MySQL server, adjust the hostname accordingly.

Starting the server

Start the MCP server using Docker with the environment file you prepared. The recommended approach adds a host alias for host.docker.internal to ensure reliable access from the container.

docker run -i --rm --add-host=host.docker.internal:host-gateway --env-file ~/.mcp/.env ghcr.io/xiangma9712/mcp/mysql

Usage commands supported by the server

The server supports the following operations. Use your MCP client to issue requests of these types and provide the required payload.

  • List tables with a specific query to fetch data.

  • Describe outcomes with a data array.

  • Test updates, inserts, or deletes without persisting changes.

Available tools

query

Execute a read-only SQL statement and return the resulting data.

test_execute

Run a write SQL statement in test mode where changes are rolled back.

list_tables

Retrieve the list of tables in the connected database.

describe_table

Return the schema details for a specified table.

Built by
VeilStrat
AI signals for GTM teams
© 2026 VeilStrat. All rights reserved.All systems operational
MySQL MCP Server - xiangma9712/mysql-mcp-server | VeilStrat