Get the FREE Ultimate OpenClaw Setup Guide →

mysql

MySQL Server implementation for Model Context Protocol (MCP) written in Go.

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio askdba-mysql-mcp-server ./bin/mysql-mcp-server \
  --env MYSQL_DSN="Required: DSN or multi-DSN configuration. See README for details." \
  --env MYSQL_MAX_ROWS="optional: maximum rows returned (default 200)" \
  --env MYSQL_MCP_HTTP="optional: enable REST API mode (1 to enable)" \
  --env MYSQL_HTTP_PORT="optional: port for REST API mode (default 9306)" \
  --env MYSQL_MCP_VECTOR="optional: enable vector tools (1 to enable)" \
  --env MYSQL_MCP_EXTENDED="optional: enable extended tools (1 to enable)" \
  --env MYSQL_MCP_AUDIT_LOG="optional: path to audit log file" \
  --env MYSQL_MCP_JSON_LOGS="optional: enable JSON structured logs (1 to enable)" \
  --env MYSQL_MCP_TOKEN_MODEL="optional: tokenizer encoding (e.g., cl100k_base)" \
  --env MYSQL_MCP_TOKEN_TRACKING="optional: enable token usage tracking (1 to enable)" \
  --env MYSQL_QUERY_TIMEOUT_SECONDS="optional: query timeout in seconds (default 30)"

How to use

This MCP server provides a read-only interface to one or more MySQL or MariaDB instances via the Model Context Protocol (MCP). It exposes tools that Claude Desktop can use to inspect databases, describe schemas, and run safe, limited queries. Available MCP tools include list_databases, list_tables, describe_table, run_query (with safeguards like row limits), ping, server_info, list_connections, and use_connection for multi-DSN workstreams. For newer MySQL versions (9.0+), vector_search and vector_info are also supported. The server accepts multiple connections (via single binary) and can operate in REST mode if enabled, allowing HTTP-based MCP interactions. Typical usage involves starting the binary, providing a DSN or a configuration of connections, and then invoking the MCP tools through Claude Desktop or any MCP client.

How to install

Prerequisites:

  • Go toolchain or prebuilt binary (see installation options below)
  • Access to the repository or release artifacts

Installation options:

  1. Install via Homebrew (macOS/Linux):

    • brew install askdba/tap/mysql-mcp-server
    • Optional: brew update && brew upgrade mysql-mcp-server
  2. Download a prebuilt binary:

  3. Build from source (recommended if you want latest code):

  4. Docker (optional):

    • docker pull ghcr.io/askdba/mysql-mcp-server:latest
    • Run with your DSN/environment variables as described in the README

Configuration prerequisites after install:

  • Set up DSN(s) for your MySQL/MariaDB instances (via MYSQL_DSN or config file)
  • Optionally configure environment variables for TLS, HTTP REST mode, timeouts, and vector tools
  • Create any necessary audit logs or enable JSON logging if desired

Additional notes

Tips and common notes:

  • The server is fully read-only by default and blocks non-SELECT/SHOW/DESCRIBE/EXPLAIN queries to ensure safe MCP interactions.
  • If you enable REST API mode (MYSQL_MCP_HTTP=1), ensure proper network exposure and security controls since HTTP endpoints may be reachable by MCP clients.
  • For multi-DSN setups, you can provide multiple DSNs via environment variables (MYSQL_DSN, MYSQL_DSN_1, MYSQL_DSN_2, etc.) or via a JSON configuration.
  • Vector tools require MySQL 9.0+ or compatible vector features; ensure your MySQL/MariaDB backend supports vector operations before enabling MYSQL_MCP_VECTOR.
  • Use the quickstart script (scripts/quickstart.sh) in a cloned repo to validate connectivity and generate Claude Desktop configuration automatically.
  • Review the environment variable mappings in the README for TLS/SSL (MYSQL_SSL), SSH tunneling (if needed), and per-connection overrides.

Related MCP Servers

Sponsor this space

Reach thousands of developers