Get the FREE Ultimate OpenClaw Setup Guide →

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.

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
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)

Option 2: Build from Source

  1. Clone the repository: git clone https://github.com/koh/mysql-mcp-server.git cd mysql-mcp-server
  2. 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

Sponsor this space

Reach thousands of developers