mysql
A Model Context Protocol (MCP) server that enables AI assistants to interact with MySQL databases. Query execution, schema inspection, and seamless integration with Claude, Cursor, and VSCode.
claude mcp add --transport stdio koh-yoshimoto-mysql-mcp-server mysql-mcp-server \ --env MYSQL_HOST="MySQL server host (default: localhost)" \ --env MYSQL_PORT="MySQL server port (default: 3306)" \ --env MYSQL_USER="MySQL username" \ --env MYSQL_DATABASE="Database name to connect to" \ --env MYSQL_PASSWORD="MySQL password"
How to use
This MCP server exposes a MySQL database through standardized MCP tools. It supports operations to query data, inspect schemas, list tables, and analyze query plans. Use the available tools to interact with your MySQL instance safely and programmatically: the query tool executes SELECT statements (read-only by design for safety), while the execute tool handles data-modifying statements (with a two-step dry-run and confirmation flow). You can also fetch table schemas, enumerate tables in the database, and run EXPLAIN or EXPLAIN ANALYZE to understand performance characteristics. Configure the server with your MySQL connection details via environment variables, then invoke the tools to manage data or perform analysis from your own applications or editor integrations.
How to install
Prerequisites:
- Go installed (required for building from source, optional if using pre-built binaries)
- MySQL 5.7+ or 8.0+ server running and accessible
- Make (for building from source)
Option 1: Download Pre-built Binary (Recommended)
- Download the latest release for your platform and place the binary in your PATH
- Linux (amd64): curl -L https://github.com/koh/mysql-mcp-server/releases/latest/download/mysql-mcp-server-linux-amd64.tar.gz | tar xz chmod +x mysql-mcp-server sudo mv mysql-mcp-server /usr/local/bin/
- macOS (Apple Silicon): curl -L https://github.com/koh/mysql-mcp-server/releases/latest/download/mysql-mcp-server-darwin-arm64.tar.gz | tar xz chmod +x mysql-mcp-server mv mysql-mcp-server /usr/local/bin/
- macOS (Intel): curl -L https://github.com/koh/mysql-mcp-server/releases/latest/download/mysql-mcp-server-darwin-amd64.tar.gz | tar xz chmod +x mysql-mcp-server mv mysql-mcp-server /usr/local/bin/
- Windows: follow the Windows download instructions on the release page and ensure the executable is in your PATH
Option 2: Build from Source
- Clone the repository: git clone https://github.com/koh/mysql-mcp-server.git cd mysql-mcp-server
- Install dependencies and build:
make build
Or use make setup for full development setup
Verify Installation
- After installation, verify the server is accessible: mysql-mcp-server --version
Additional notes
Environment and configuration tips:
- Set MYSQL_HOST, MYSQL_PORT, MYSQL_USER, MYSQL_PASSWORD, and MYSQL_DATABASE to connect to your MySQL instance.
- You can copy .env.example to .env and edit it, or export variables in the shell before starting the server.
- The tools include: query (SELECTs only), execute (INSERT/UPDATE/DELETE with a two-step dry-run and confirm-token), schema (table structure), tables (list tables), and explain (EXPLAIN or EXPLAIN ANALYZE).
- EXPLAIN ANALYZE runs the query, so use it with care on long-running or write operations.
- In editor integrations, set up the server entry with the proper command path and environment variables to enable MCP-based tooling workflows.
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