MCP Directory

MySQL MCP Server Pro

MySQL CRUD plus anomaly analysis: SQL optimization, health checks, lock and index diagnostics, with role-based permissions.

Unverified
stdio (local)
OAuth
Stale
Python

Add to your client

Copy the config for your MCP client and paste it into its config file.

Install / run
pip install mysql_mcp_server_pro

Paste into ~/Library/Application Support/Claude/claude_desktop_config.json

{
  "mcpServers": {
    "mysql-mcp-server-pro": {
      "command": "uvx",
      "args": [
        "--from",
        "mysql_mcp_server_pro",
        "mysql_mcp_server_pro",
        "--mode",
        "stdio"
      ],
      "env": {
        "MYSQL_HOST": "192.168.x.xxx",
        "MYSQL_PORT": "3306",
        "MYSQL_USER": "root",
        "MYSQL_PASSWORD": "root",
        "MYSQL_DATABASE": "a_llm",
        "MYSQL_ROLE": "admin"
      }
    }
  }
}

Requires `uv` (the Python package runner). Install it from https://docs.astral.sh/uv/ if `uvx` is not found.

Before you start

  • A reachable MySQL database with valid credentials
  • Python with uv/uvx, or pip to install the mysql_mcp_server_pro package
  • Environment variables for the DB connection (MYSQL_HOST, MYSQL_PORT, MYSQL_USER, MYSQL_PASSWORD, MYSQL_DATABASE) and optionally MYSQL_ROLE

About MySQL MCP Server Pro

An MCP server for secure interaction with MySQL databases that goes beyond CRUD to include database anomaly analysis: SQL execution-plan optimization, table and row lock detection, index-usage diagnostics, and overall health checks. It supports STDIO, SSE, and Streamable HTTP transports, OAuth 2.0 authentication, and role-based permission control (readonly/writer/admin). Developers can extend it with custom tools by subclassing BaseHandler.

Tools & capabilities (10)

execute_sql

SQL execution tool that can run SELECT, SHOW, DESCRIBE, EXPLAIN, INSERT, UPDATE, DELETE, CREATE, ALTER, DROP, and TRUNCATE commands based on the configured permission role.

get_chinese_initials

Convert Chinese field names to pinyin initials.

get_db_health_running

Analyze MySQL health status, including connection status, transaction status, running status, and lock status detection.

get_table_desc

Search for table structures in the database based on table names, supporting multi-table queries.

get_table_index

Search for table indexes in the database based on table names, supporting multi-table queries.

get_table_lock

Check whether there are row-level or table-level locks on the current MySQL server.

get_table_name

Search for table names in the database based on table comments and descriptions.

get_db_health_index_usage

Get index usage for the connected MySQL database, including redundant indexes, poorly performing indexes, and the top 5 unused indexes with query times greater than 30 seconds.

optimize_sql

Professional SQL performance optimization tool that provides expert suggestions based on MySQL execution plans, table structure, table data volume, and table indexes.

use_prompt_queryTableData

Uses built-in prompts to let the model construct a chain call of MCP tools. Not enabled by default; requires modifying the code to activate.

What this server can do

MySQL MCP Server Pro provides tools for these capabilities — tap one to see every MCP server that does the same:

When to use it

  • Create tables and insert data from natural-language task descriptions, with indexes and comments
  • Query data by table comments without knowing exact table or column names
  • Analyze slow SQL and get markdown optimization recommendations based on the execution plan
  • Diagnose SQL deadlocks and stuck statements by analyzing lock status
  • Check overall MySQL health (connections, transactions, locks, index usage)

Security notes

Connects to a MySQL database using credentials supplied via environment variables (MYSQL_HOST, MYSQL_PORT, MYSQL_USER, MYSQL_PASSWORD, MYSQL_DATABASE). Use MYSQL_ROLE to scope permissions: 'readonly' (SELECT/SHOW/DESCRIBE/EXPLAIN), 'writer' (adds INSERT/UPDATE/DELETE), or 'admin' (adds CREATE/ALTER/DROP/TRUNCATE). Prefer the least-privileged role; the README examples use 'admin', which grants destructive DDL. For HTTP/SSE deployments, enable OAuth 2.0 (--oauth true) to protect the endpoint.

MySQL MCP Server Pro FAQ

Which MCP transports are supported?

All of them: STDIO, SSE, and Streamable HTTP. Streamable HTTP is the default mode; use --mode sse for SSE or --mode stdio for STDIO.

How do I restrict what SQL the server can run?

Set the MYSQL_ROLE environment variable. 'readonly' allows SELECT/SHOW/DESCRIBE/EXPLAIN; 'writer' adds INSERT/UPDATE/DELETE; 'admin' adds CREATE/ALTER/DROP/TRUNCATE. Choose the least-privileged role for your use case.

Does it support authentication for HTTP deployments?

Yes. It supports OAuth 2.0 (built-in password mode by default). Start with --oauth true, log in at the auth service, then pass the token in the request headers as 'authorization: bearer TOKEN_VALUE'.

Can I add my own tools?

Yes. Add a new tool class in the handles package that inherits from BaseHandler and implements get_tool_description and run_tool, then import it in __init__.py to register it with the server.

Alternatives to MySQL MCP Server Pro

Google's official MCP server with prebuilt BigQuery tools, querying datasets via Application Default Credentials.

Verified
stdio (local)
OAuth
Go
10 tools
Updated 2 months agoRepo

Create, manage, and query your InstantDB apps, schemas, permissions, and data from your AI editor.

Unverified
HTTP (remote)
OAuth
TypeScript
7 tools
Updated 1 month agoRepo

Zero-dependency, token-efficient database MCP server for Postgres, MySQL, SQL Server, MariaDB, and SQLite.

Unverified
stdio (local)
No auth
TypeScript
3 tools
Updated 1 month agoRepo