Skip to content
MySQL MCP Server

MySQL MCP Server

Released
v0.4.5
MIT

Summary

Open-source Python MCP server for MySQL: lets an AI assistant list tables, read schemas, sample rows and run SQL against your database, with multi-database mode, SSH tunnelling and stdio or SSE transport.

Features

  • execute_sql runs single SQL statements, with DML flagged as destructive
  • get_schema_info returns columns, types, nullability, defaults and comments
  • get_table_sample fetches up to 20 rows to show a table's shape
  • Tables exposed as MCP resources; explore_database and analyze_table prompts
  • Multi-database mode with database.table addressing
  • SSH tunnelling, SSL modes and an SSE/HTTP transport for self-hosting

Installation

Set up this MCP server in your favorite AI agent — copy a ready-made configuration below.

Any MCP-compatible agent

Most agents (Claude, Cursor, Windsurf, VS Code, and more) read a standard mcpServers configuration.

  1. Open your agent's MCP configuration file.
  2. Merge the snippet below into it, filling in the environment variables with your own values.
  3. Restart the agent — the "MySQL MCP Server" tools will be available.
{
  "mcpServers": {
    "mysql-mcp-server": {
      "command": "uvx",
      "args": [
        "--from",
        "mysql-mcp-server",
        "mysql_mcp_server"
      ],
      "env": {
        "MYSQL_HOST": "localhost",
        "MYSQL_PORT": "3306",
        "MYSQL_USER": "your_username",
        "MYSQL_PASSWORD": "your_password",
        "MYSQL_DATABASE": "your_database"
      }
    }
  }
}

Description

MySQL MCP Server is a widely used open-source Model Context Protocol server, published by Design Computer, that connects an AI assistant to a MySQL database through a small, controlled interface. Credentials stay in environment variables, and the assistant works through a handful of tools rather than an open shell.

It exposes tables as MCP resources so a client can list and read them, and three tools: execute_sql runs a single SQL statement (SELECT, SHOW, DESCRIBE, and INSERT, UPDATE or DELETE, which are flagged as destructive), get_schema_info returns column names, types, nullability, defaults and comments, and get_table_sample fetches up to 20 rows to show the data's shape. Two prompts, explore_database and analyze_table, chain those tools into guided walk-throughs. Leaving MYSQL_DATABASE unset switches on multi-database mode, where every user database is listed and tables are addressed as database.table. Multi-statement queries are not supported.

The server is the MIT-licensed PyPI package mysql-mcp-server, usually launched with uvx --from mysql-mcp-server mysql_mcp_server and configured with MYSQL_HOST, MYSQL_PORT, MYSQL_USER, MYSQL_PASSWORD and optionally MYSQL_DATABASE. Further settings cover SSL mode, timeouts, charset and auth plugin for older MySQL versions, an SSH jump host for databases that are not directly reachable, and an SSE/HTTP transport (MCP_TRANSPORT=sse) for self-hosted shared deployments. Using a database user with only the privileges the assistant should have is the main safety control.

MCP: DBHub

by Bytebase

Featured

A universal database MCP server — one integration for PostgreSQL, MySQL, SQL Server, SQLite, and MariaDB.

MCP: PlanetScale

by PlanetScale

PlanetScale's official hosted MCP server — browse organizations, databases and branches, read schema, run guarded SQL, and pull Insights and schema recommendations.

A single ~7 MB binary that gives your AI assistant schema discovery, SQL queries and EXPLAIN plans for MySQL, MariaDB, PostgreSQL and SQLite, with a read-only mode.

MCP: CockroachDB MCP Server

by Cockroach Labs

Cockroach Labs' official MCP server exposes a CockroachDB cluster to agents as typed tools — schema inspection, cluster metadata, EXPLAIN and SELECT — with writes and DDL locked off unless you explicitly turn them on.

Browse all MCP servers →