mysql
MySQL Server implementation for Model Context Protocol (MCP) written in Go.
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:
-
Install via Homebrew (macOS/Linux):
- brew install askdba/tap/mysql-mcp-server
- Optional: brew update && brew upgrade mysql-mcp-server
-
Download a prebuilt binary:
- Obtain the latest release from GitHub Releases: https://github.com/askdba/mysql-mcp-server/releases
- Extract and place the binary (e.g., bin/mysql-mcp-server) in your PATH
-
Build from source (recommended if you want latest code):
- git clone https://github.com/askdba/mysql-mcp-server.git
- cd mysql-mcp-server
- make build
- The binary will be available at bin/mysql-mcp-server
-
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
trpc-agent-go
trpc-agent-go is a powerful Go framework for building intelligent agent systems using large language models (LLMs) and tools.
station
Station is our open-source runtime that lets teams deploy agents on their own infrastructure with full control.
tiger-cli
Tiger CLI is the command-line interface for Tiger Cloud. It includes an MCP server for helping coding agents write production-level Postgres code.
gopls
MCP server for golang projects development: Expand AI Code Agent ability boundary to have a semantic understanding and determinisic information for golang projects.
kubernetes
A Model Context Protocol (MCP) server for the Kubernetes API.
gcp-cost
💰 An MCP server that enables AI assistants to estimate Google Cloud costs, powered by Cloud Billing Catalog API and built with Genkit for Go