MCP MySQL Server

by cnosuke

1 242 downloads Not rated yet
GitHub

About

MCP server that acts as a MySQL Client implemented in Go language

Explore

- MCP Compliance: Provides a JSON‐RPC based interface for tool execution according to the MCP specification.
- MySQL Operations: Supports database operations such as querying, schema inspection, and (optionally) data manipulation.
- Read-Only Mode: Optional restriction to prevent data modification operations.
- Query Plan Verification: Optional EXPLAIN analysis to verify query safety.
- URL-Style Connection Strings: Supports standard URL-style database connection strings like mysql://user:pass@host:port/dbname.
- Minimal Container: Built with Google's distroless for improved security and smaller image size.

Setting up with Highlight

This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:

  1. Download and install Highlight from highlightai.com/download
  2. Navigate to the plugins tab and select "Add Custom Plugin"
  3. Configure the plugin with the settings below
    Plugin Name MCP MySQL Server
    Command (node, npx, python, etc.)

    Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.

  4. Enable "Start Automatically" if you want the plugin to start when Highlight launches

From the repository

- Docker (recommended)

For local development:

- Go 1.24 or later
- MySQL server (local or remote)

Alternatively, you can build and run the Go binary directly:

``bash

- mysql.host: MySQL server hostname (default: 'localhost')
-
mysql.user: MySQL username (default: 'root')
-
mysql.password: MySQL password
-
mysql.port: MySQL port (default: 3306)
-
mysql.database: MySQL database name
-
mysql.dsn: MySQL DSN (Data Source Name) string. If provided, this overrides the individual connection parameters
-
mysql.read_only: Enable read-only mode. In this mode, only tools beginning with list, read_ and desc_ are available
-
mysql.explain_check: Check query plan with EXPLAIN before executing

You can override configurations using environment variables:

- LOG_PATH: Path to log file
-
DEBUG: Enable debug mode (true/false)
-
MYSQL_HOST: MySQL server hostname
-
MYSQL_PORT: MySQL server port
-
MYSQL_USER: MySQL username
-
MYSQL_PASSWORD: MySQL password
-
MYSQL_DATABASE: MySQL database name
-
MYSQL_DSN: MySQL DSN string
-
MYSQL_READ_ONLY: Enable read-only mode (true/false)
-
MYSQL_EXPLAIN_CHECK`: Enable query plan checking (true/false)

dsn

(optional): MySQL DSN string to override configuration.

query

The SQL query to create the table.

name

The name of the table to describe.

MCP clients interact with the server by sending JSON‐RPC requests to execute various tools. The following MCP tools are supported:

1. list_database

- List all databases in the MySQL server.
- Parameters:
- dsn (optional): MySQL DSN string to override configuration.
- Returns: A list of matching database names.

2. list_table

- List all tables in the MySQL server.
- Parameters:
- dsn (optional): MySQL DSN string to override configuration.
- Returns: A list of matching table names.

3. create_table (not available in read-only mode)

- Create a new table in the MySQL server.
- Parameters:
- query: The SQL query to create the table.
- dsn (optional): MySQL DSN string to override configuration.
- Returns: x rows affected.

4. alter_table (not available in read-only mode)

- 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.
- dsn (optional): MySQL DSN string to override configuration.
- Returns: x rows affected.

5. desc_table

- Describe the structure of a table.
- Parameters:
- name: The name of the table to describe.
- dsn (optional): MySQL DSN string to override configuration.
- Returns: The structure of the table.

1. read_query

- Execute a read-only SQL query.
- Parameters:
- query: The SQL query to execute.
- dsn (optional): MySQL DSN string to override configuration.
- Returns: The result of the query.

2. write_query (not available in read-only mode)

- Execute a write SQL query.
- Parameters:
- query: The SQL query to execute.
- dsn (optional): MySQL DSN string to override configuration.
- Returns: x rows affected, last insert id: <last_insert_id>.

3. update_query (not available in read-only mode)

- Execute an update SQL query.
- Parameters:
- query: The SQL query to execute.
- dsn (optional): MySQL DSN string to override configuration.
- Returns: x rows affected.

4. delete_query (not available in read-only mode)

- Execute a delete SQL query.
- Parameters:
- query: The SQL query to execute.
- dsn (optional): MySQL DSN string to override configuration.
- Returns: x rows affected.

Claude Desktop / Cursor

Paste into your MCP client config file to install this server.

{
    "mcpServers": {
        "mcp mysql server": {
            "mcp-mysql-cnosuke": {
                "command": "docker",
                "args": [
                    "pull",
                    "cnosuke/mcp-mysql:latest"
                ]
            }
        }
    }
}

McpServers

{
    "mcp-mysql-cnosuke": {
        "command": "docker",
        "args": [
            "pull",
            "cnosuke/mcp-mysql:latest"
        ]
    }
}

MCP MySQL Server is a Go-based MCP server implementation that provides MySQL database interaction functionality, allowing MCP clients (e.g., Claude Desktop) to perform database operations.

Features

- MCP Compliance: Provides a JSON‐RPC based interface for tool execution according to the MCP specification.
- MySQL Operations: Supports database operations such as querying, schema inspection, and (optionally) data manipulation.
- Read-Only Mode: Optional restriction to prevent data modification operations.
- Query Plan Verification: Optional EXPLAIN analysis to verify query safety.
- URL-Style Connection Strings: Supports standard URL-style database connection strings like mysql://user:pass@host:port/dbname.
- Minimal Container: Built with Google's distroless for improved security and smaller image size.

Requirements

- Docker (recommended)

For local development:

- Go 1.24 or later
- MySQL server (local or remote)

Using with Docker (Recommended)

```bash

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.