MCP MySQL Server

MCP MySQL Server

mcp-mysql-cnosuke•bycnosuke

A Go-based MCP server that lets MCP clients interact with MySQL databases for schema inspection and query execution.

License: MIT License•Runtime: Awaiting documentation review•Category: databases storage

WHAT IT DOES

  • •Offers schema tools such as list_database, list_table, create_table, alter_table, and desc_table.
  • •Provides data tools including read_query, write_query, update_query, and delete_query.
  • •Supports an optional read-only mode that restricts available tools to listing, reading, and describing.
  • •Can perform optional EXPLAIN analysis before executing queries to verify query plans.

BEST FOR

  • •Letting an MCP client inspect MySQL schemas by listing databases, tables, and describing table structures.
  • •Running database queries from an MCP client while optionally limiting operations to read-only access.
  • •Performing data modification through MCP tools when read-only mode is disabled.

ABOUT MCP-MYSQL-CNOSUKE

MCP MySQL Server is cataloged as an MCP server attributed to cnosuke. A Go-based MCP server that lets MCP clients interact with MySQL databases for schema inspection and query execution. It is categorized under databases storage. See the capability inspector for recorded interfaces and their independent review status; consult upstream documentation for the current interface.

HOW TO INSTALL

Installation configuration is not reviewed. No executable setup is offered for this entry; inspect the source repository before proceeding.

LICENSE

Catalog license label: MIT License. Check the source repository's current license and terms before using, modifying or distributing this software.

Capability inspector

Capability definitions are not reviewed. Unreviewed imports are not exposed as trusted interfaces.

Tools (0)

No reviewed records to display. This does not establish that upstream lacks this capability.

Resources (0)

No reviewed records to display. This does not establish that upstream lacks this capability.

Prompts (0)

No reviewed records to display. This does not establish that upstream lacks this capability.

NEWSLETTER - COMING LATER

Newsletter subscriptions are not open yet

Email delivery is not connected. This page does not collect email addresses or create subscriptions.

Browse the registry for current listings instead.

Community Reviews

Coming later

Reviews for MCP MySQL Server are not available yet

Review publishing and storage are not connected. This page does not collect or publish ratings or comments, including after sign-in.

FREQUENTLY ASKED QUESTIONS

Does the server support read-only mode?

Yes, read-only mode can be enabled, and in that mode only tools beginning with list, read_ and desc_ are available.

Can query plans be checked before execution?

Yes, enabling explain_check checks the query plan with EXPLAIN before executing.

Which connection string formats are supported?

It supports both native MySQL DSN format and URL-style connection strings such as mysql://.

Upstream README

View this exact version on GitHub

README.md · 99dd0e7cf98b · Fetched 2026-11-13 11:03:21 UTC

Original upstream text, without AI rewriting. Scripts, forms and unsafe links are filtered for safety.

Showing the last retrieved documentation snapshot; check the source for current changes.

MCP MySQL Server

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)
# Pull the image
docker pull cnosuke/mcp-mysql:latest

# Run with default settings
docker run -i --rm cnosuke/mcp-mysql:latest

# Run with custom MySQL connection
docker run -i --rm \
  -e MYSQL_HOST=your-mysql-host \
  -e MYSQL_PORT=3306 \
  -e MYSQL_USER=your-username \
  -e MYSQL_PASSWORD=your-password \
  -e MYSQL_DATABASE=your-database \
  cnosuke/mcp-mysql:latest

# Run in read-only mode
docker run -i --rm \
  -e MYSQL_HOST=your-mysql-host \
  -e MYSQL_USER=your-username \
  -e MYSQL_PASSWORD=your-password \
  -e MYSQL_DATABASE=your-database \
  -e MYSQL_READ_ONLY=true \
  cnosuke/mcp-mysql:latest

Using with Claude Desktop (Docker)

To integrate with Claude Desktop using Docker, add an entry to your claude_desktop_config.json file:

{
  "mcpServers": {
    "mysql": {
      "command": "docker",
      "args": ["run", "-i", "--rm", "cnosuke/mcp-mysql:latest"],
      "env": {
        "MYSQL_HOST": "your-mysql-host",
        "MYSQL_PORT": "3306",
        "MYSQL_USER": "your-username",
        "MYSQL_PASSWORD": "your-password",
        "MYSQL_DATABASE": "your-database",
        "MYSQL_READ_ONLY": "false"
      }
    }
  }
}

Building and Running (Go Binary)

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

# Build the server
make

# Run the server
./bin/mcp-mysql server --config=config.yml

Using with Claude Desktop (Go Binary)

To integrate with Claude Desktop using the Go binary, add an entry to your claude_desktop_config.json file:

{
  "mcpServers": {
    "mysql": {
      "command": "./bin/mcp-mysql",
      "args": ["server"],
      "env": {
        "LOG_PATH": "mcp-mysql.log",
        "DEBUG": "false",
        "MYSQL_HOST": "your-mysql-host",
        "MYSQL_PORT": "3306",
        "MYSQL_USER": "your-username",
        "MYSQL_PASSWORD": "your-password",
        "MYSQL_DATABASE": "your-database",
        "MYSQL_READ_ONLY": "false"
      }
    }
  }
}

Docker Image Details

This project uses Google's distroless container images for the final Docker image. The gcr.io/distroless/static base image provides:

  • Minimal attack surface - only the necessary components are included
  • Smaller image size - no shell, package manager, or other unnecessary binaries
  • Improved security - reduced number of potential vulnerabilities

The Docker image is built using a multi-stage build process:

  1. First stage uses Go Alpine to build the application
  2. Second stage uses distroless/static with just the compiled binary

Configuration

The server is configured via a YAML file (default: config.yml) or environment variables:

log: 'path/to/mcp-mysql.log' # Log file path, if empty no log will be produced
debug: false # Enable debug mode for verbose logging

mysql:
  host: 'localhost'
  user: 'root'
  password: ''
  port: 3306
  database: ''
  dsn: ''
  read_only: false
  explain_check: false

Connection Options

You can specify MySQL connection details in three ways (in order of precedence):

  1. Tool Parameter: Pass a dsn parameter directly to any tool when invoking it
  2. DSN in Config: Set the mysql.dsn value in the configuration file
  3. Individual Parameters: Set individual connection parameters in the configuration file

If no connection information is provided in any of these ways, the server will return an error message prompting you to provide connection details.

Configuration Options

  • 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)

Logging

Logging behavior is controlled through configuration:

  • If log is set in the config file, logs will be written to the specified file
  • If log is empty, no logs will be produced
  • Set debug: true for more verbose logging

MCP Server Tools

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

Schema Tools

  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.

Data Tools

  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.

MySQL DSN Format

The dsn parameter or mysql.dsn configuration option can be specified in two formats:

1. Native MySQL DSN Format

[username[:password]@][protocol[(address)]]/dbname[?param1=value1&...&paramN=valueN]

Example: username:password@tcp(localhost:3306)/mydb?parseTime=true&loc=Local

Please refer to MySQL DSN for more details on this format.

2. URL-Style Connection Format

mysql://username:password@hostname:port/dbname?param1=value1&param2=value2

Example: mysql://root:pass@localhost:3306/mydb?parseTime=true&loc=Local

This URL-style format is automatically converted to the native MySQL DSN format. Supported URL schemes include: mysql://, mariadb://.

Command-Line Parameters

When starting the server, you can specify various settings:

./bin/mcp-mysql server [options]

Options:

  • --config, -c: Path to the configuration file (default: "config.yml").

Contributing

Contributions are welcome! Please fork the repository and submit pull requests for improvements or bug fixes. For major changes, open an issue first to discuss your ideas.

License

This project is licensed under the MIT License.

Author: cnosuke ( x.com/cnosuke )

Install configuration

Are you the maintainer?

Claim this server with your GitHub account to request manual ownership verification.

README Embed Badge
Markdown

Link to the catalog listing for MCP MySQL Server from your README. This badge does not certify ownership, compatibility or security.

[![MCP catalog listing](https://img.shields.io/badge/MCP-awesome--mcp-orange?style=flat-square)](https://awesome-mcp.com/servers/mcp-mysql-cnosuke)

REPOSITORY STATS

GitHub StarsUnavailable
ForksUnavailable

Public repository statistics could not be verified. Check the configured source address; unavailable counts are not zero.

Downloads and pulls

Separate sources, scopes and periods. Never combined or treated as installations, active users or security reviews.

No reviewed package or image identity; download statistics are not listed yet.

Related databases storage MCP Servers

Alternative and complementary servers in the same category

View all in databases storage →
AIStor MCP server
mcp-server-aistor•minio

This is a Model Context Protocol (MCP) server for interacting with AIStor object stores.

Repository stats unavailable
Databases & Storage
InfluxDB v2 MCP Server
influxdb-mcp-server•idoru

A Model Context Protocol (MCP) server that exposes access to an InfluxDB v2 instance using the InfluxDB OSS API v2.

Repository stats unavailable
Databases & Storage