Get the FREE Ultimate OpenClaw Setup Guide →

mysql_mcp_server_pro

Model Context Protocol (MCP) server that supports secure interaction with MySQL databases and has anomaly analysis capabilities.更加牛逼!更加好用!不仅止于mysql的增删改查功能; 还包含了数据库异常分析能力;且便于开发者们进行个性化的工具扩展

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio wenb1n-dev-mysql_mcp_server_pro python -m mysql_mcp_server_pro.server \
  --env MYSQL_HOST="localhost" \
  --env MYSQL_PORT="3306" \
  --env MYSQL_ROLE="readonly" \
  --env MYSQL_USER="your_username" \
  --env MYSQL_DATABASE="your_database" \
  --env MYSQL_PASSWORD="your_password"

How to use

This MCP server provides a MySQL-focused toolkit that exposes a set of tools for performing SQL operations, health checks, schema discovery, and advanced analysis. It supports multiple MCP transfer modes and can be accessed via standard MCP clients. The included tools let you execute SQL commands with permission-based filtering, convert Chinese field names to pinyin initials, analyze database health and index usage, inspect table structures and locks, and optimize queries based on execution plans. You can also invoke prompt-based workflows and chain tool calls through the built-in prompts. To begin, configure your environment with your MySQL connection details, select the desired MCP transfer mode (stdio, SSE, or Streamable Http), and start the server. Then connect with an MCP client or integrate via UV-based or Python-based execution paths as demonstrated in the configuration examples.

How to install

Prerequisites:

  • Python 3.8+ installed on your system
  • MySQL database accessible from the host
  • pip available to install the package

Installation steps:

  1. Install the MCP server package

    • Command: pip install mysql_mcp_server_pro
  2. Prepare environment configuration (optional but recommended)

    • Create a .env file or set environment variables directly. Example .env content:

      MySQL Database Configuration

      MYSQL_HOST=localhost MYSQL_PORT=3306 MYSQL_USER=your_username MYSQL_PASSWORD=your_password MYSQL_DATABASE=your_database

      Optional, default is 'readonly'. Available values: readonly, writer, admin

      MYSQL_ROLE=readonly
  3. Run the server (example using Python module invocation)

    • Command: python -m mysql_mcp_server_pro.server
  4. (Optional) Run in specific MCP transfer modes or with OAuth as needed. See README for mode flags and OAuth options.

Note: Ensure network access between the MCP server and your MySQL instance. If you use a custom environment file, start the server with the appropriate envfile flag if supported by your run method.

Additional notes

Tips and common considerations:

  • The toolset includes execute_sql (SQL execution with permission filtering), get_table_desc, get_table_lock, get_db_health_running, get_db_health_index_usage, and more. Use the role configuration to limit destructive operations to admin or writer roles.
  • If you enable OAuth, ensure your client can obtain and refresh tokens as required by your deployment.
  • The server supports multiple SQL statements separated by semicolons in a single execution call.
  • For client integrations, you can run the server via uvx (for MCP clients) or via direct Python module invocation as shown in the mcp_config example. Ensure your chosen method aligns with your deployment and security requirements.
  • Use the provided prompts (analyzing-mysql-prompt, query-table-data-prompt) to guide the model through complex tasks like schema analysis and data querying workflows.
  • If you encounter connection issues, verify MYSQL_HOST, MYSQL_PORT, and network accessibility from the server host to the MySQL instance. Also confirm user privileges match the selected MYSQL_ROLE.

Related MCP Servers

Sponsor this space

Reach thousands of developers