# wenb1n-dev/mysql_mcp_server_pro [Health: Active]

**Category:** 🗄️ Databases  
**Repository:** https://github.com/wenb1n-dev/mysql_mcp_server_pro  
**GitHub Stars:** 249  
**Views:** 11  
**Installs:** 0  
**Upvotes:** 0  
**Directory Page:** https://allmcps.com/mcp/wenb1n-dev-mysql-mcp-server-pro

## Description
Supports SSE, STDIO; not only limited to MySQL's CRUD functionality; also includes database exception analysis capabilities; controls database permissions based on roles; and makes it easy for developers to extend tools with customization

## Tools
Capabilities this server exposes over MCP:

- **execute_sql** — SQL execution tool that can execute ["SELECT", "SHOW", "DESCRIBE", "EXPLAIN", "INSERT", "UPDATE", "DELETE", "CREATE", "ALTER", "DROP", "TRUNCATE"] commands based on permission configuration
- **get_chinese_initials** — Convert Chinese field names to pinyin initials
- **get_db_health_running** — Analyze MySQL health status (connection status, transaction status, running status, 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 if there are row-level locks or table-level locks in 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 the index usage of the currently connected mysql database, including redundant index situations, poorly performing index situations, and the top 5 unused index situations with query times greater than 30 seconds
- **optimize_sql** — Professional SQL performance optimization tool, providing expert optimization suggestions based on MySQL execution plans, table structure information, table data volume, and table indexes.
- **use_prompt_queryTableData** — Use built-in prompts to let the model construct a chain call of tools in mcp (not a commonly used fixed tool, you need to modify the code to enable it, see this class for details)

## Claude Desktop Quick Installation
Install path detected from listing signals. Uses `uvx` (confidence: high):

```json
"mcpServers": {
  "mysql-mcp-server-pro": {
    "command": "uvx",
    "args": ["mysql_mcp_server_pro","mysql_mcp_server_pro","stdio"],
    "env": {
      "MYSQL_HOST": "",
      "MYSQL_PORT": "",
      "MYSQL_USER": "",
      "MYSQL_PASSWORD": "",
      "MYSQL_DATABASE": "",
      "MYSQL_ROLE": ""
    }
  }
}
```

**Requires environment variables:** `MYSQL_HOST`, `MYSQL_PORT`, `MYSQL_USER`, `MYSQL_PASSWORD`, `MYSQL_DATABASE`, `MYSQL_ROLE` — the values above are empty placeholders; fill in real credentials before running (see the repository for what each one is for).

## Documentation

## What wenb1n-dev/mysql_mcp_server_pro MCP server does

wenb1n-dev/mysql_mcp_server_pro MCP server connects an MCP client to a configured MySQL database and exposes both SQL execution and database investigation tools. It supports three transport modes: STDIO for local client processes, SSE, and Streamable HTTP. The HTTP service can also be started with OAuth2 authentication enabled.

SQL execution is governed by a configured role. The available roles are readonly, writer, and admin. Readonly permits SELECT, SHOW, DESCRIBE, and EXPLAIN statements. Writer adds INSERT, UPDATE, and DELETE, while admin also permits CREATE, ALTER, DROP, and TRUNCATE. The server supports multiple SQL statements separated by semicolons.

## How it works

Set the MySQL host, port, username, password, and database through environment variables or a `.env` file. The server reads those settings when it starts and uses the selected role to determine which SQL statements the `execute_sql` tool may run.

The remaining tools query the connected database or process supplied metadata. Schema tools can find table names from comments, retrieve table definitions, and inspect indexes across multiple tables. Diagnostic tools report connection, transaction, running, and lock status; inspect row-level and table-level locks; and review index usage, including redundant, poorly performing, and unused indexes. The SQL optimizer uses execution plans, table structure, row counts, and index information to produce recommendations.

The `analyzing-mysql-prompt` and `query-table-data-prompt` prompt templates support guided MySQL analysis and table-data queries. The query-table-data tool is not enabled as a typical fixed tool by default and requires code changes described by the project.

## Setup and configuration

Install the package with:

```bash
pip install mysql_mcp_server_pro
```

Provide these environment variables in a `.env` file or directly in the process environment:

```text
MYSQL_HOST=localhost
MYSQL_PORT=3306
MYSQL_USER=your_username
MYSQL_PASSWORD=your_password
MYSQL_DATABASE=your_database
MYSQL_ROLE=readonly
```

`MYSQL_ROLE` defaults to `readonly`; the documented alternatives are `writer` and `admin`. An environment file can be selected with `--envfile`. The default service command starts Streamable HTTP, while `--mode sse` selects SSE and `--oauth true` enables OAuth2 authentication for the HTTP service.

For local MCP clients, the package can be launched through `uvx` in STDIO mode.

## Tools and capabilities

wenb1n-dev/mysql_mcp_server_pro MCP server includes:

- `execute_sql` for permitted SQL statements.
- `get_table_name` for finding tables from comments or descriptions.
- `get_table_desc` and `get_table_index` for multi-table schema and index inspection.
- `get_db_health_running` for connection, transaction, running-state, and lock checks.
- `get_table_lock` for row-level and table-level lock detection.
- `get_db_health_index_usage` for index-use analysis and unused-index reporting.
- `optimize_sql` for execution-plan-based performance suggestions.
- `get_chinese_initials` for converting Chinese field names to pinyin initials.

## Limitations and notes

The server requires a reachable MySQL database and valid connection settings. SQL permissions are controlled by the selected application role, so an agent cannot use statements outside that role's configured list. OAuth2 is documented for the HTTP service, while the database still requires its MySQL credentials. The prompt-based table-query workflow requires modification to enable it as a commonly used fixed tool.

_Full upstream README: https://allmcps.com/mcp/wenb1n-dev-mysql-mcp-server-pro/readme_

