mcpmysqlserverpro is not just about MySQL CRUD operations, but also includes database anomaly analysis capabilities and makes it easy for developers to extend with custom tools. - Supports all Model Context Protocol (MCP) transfer modes (STDIO, SSE, Streamable Http) - Supports OAuth2.0 - Supports multiple SQL execution, separated by ";" - Supports querying database table names and fields based on
Add this skill
npx mdskills install wenb1n-dev/mysql-mcp-server-proProfessional MySQL MCP server with comprehensive database operations, health monitoring, and role-based permissions.
1[](README-zh.md)2[](README.md)3[](https://mseep.ai/app/wenb1n-dev-mysql-mcp-server-pro)4[](https://mcphub.com/mcp-servers/wenb1n-dev/mysql_mcp_server_pro)567# mcp_mysql_server_pro89## Introduction10mcp_mysql_server_pro is not just about MySQL CRUD operations, but also includes database anomaly analysis capabilities and makes it easy for developers to extend with custom tools.1112- Supports all Model Context Protocol (MCP) transfer modes (STDIO, SSE, Streamable Http)13- Supports OAuth2.014- Supports multiple SQL execution, separated by ";"15- Supports querying database table names and fields based on table comments16- Supports SQL execution plan analysis17- Supports Chinese field to pinyin conversion18- Supports table lock analysis19- Supports database health status analysis20- Supports permission control with three roles: readonly, writer, and admin21 ```22 "readonly": ["SELECT", "SHOW", "DESCRIBE", "EXPLAIN"], # Read-only permissions23 "writer": ["SELECT", "SHOW", "DESCRIBE", "EXPLAIN", "INSERT", "UPDATE", "DELETE"], # Read-write permissions24 "admin": ["SELECT", "SHOW", "DESCRIBE", "EXPLAIN", "INSERT", "UPDATE", "DELETE",25 "CREATE", "ALTER", "DROP", "TRUNCATE"] # Administrator permissions26 ```27- Supports prompt template invocation282930## Tool List31| Tool Name | Description |32|----------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|33| execute_sql | SQL execution tool that can execute ["SELECT", "SHOW", "DESCRIBE", "EXPLAIN", "INSERT", "UPDATE", "DELETE", "CREATE", "ALTER", "DROP", "TRUNCATE"] commands based on permission configuration |34| get_chinese_initials | Convert Chinese field names to pinyin initials |35| get_db_health_running | Analyze MySQL health status (connection status, transaction status, running status, lock status detection) |36| get_table_desc | Search for table structures in the database based on table names, supporting multi-table queries |37| get_table_index | Search for table indexes in the database based on table names, supporting multi-table queries |38| get_table_lock | Check if there are row-level locks or table-level locks in the current MySQL server |39| get_table_name | Search for table names in the database based on table comments and descriptions |40| 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 |41| 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. |42| 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) |4344## Prompt List45| Prompt Name | Description |46|---------------------------|---------------------------------------------------------------------------------------------------------------------------------------|47| analyzing-mysql-prompt | This is a prompt for analyzing MySQL-related issues |48| query-table-data-prompt | This is a prompt for querying table data using tools. If description is empty, it will be initialized as a MySQL database query assistant |4950## Usage Instructions5152### Installation and Configuration531. Install Package54```bash55pip install mysql_mcp_server_pro56```57582. Configure Environment Variables59Create a `.env` file with the following content:60```bash61# MySQL Database Configuration62MYSQL_HOST=localhost63MYSQL_PORT=330664MYSQL_USER=your_username65MYSQL_PASSWORD=your_password66MYSQL_DATABASE=your_database67# Optional, default is 'readonly'. Available values: readonly, writer, admin68MYSQL_ROLE=readonly69```70713. Run Service72```bash73# SSE mode74mysql_mcp_server_pro --mode sse --envfile /path/to/.env7576## Streamable Http mode (default)77mysql_mcp_server_pro --envfile /path/to/.env7879# Streamable Http oauth Authentication80mysql_mcp_server_pro --oauth true8182```83844. mcp client8586go to see see "Use uv to start the service"87^_^888990Note:91- The `.env` file should be placed in the directory where you run the command or use --envfile parameter to specify the path92- You can also set these variables directly in your environment93- Make sure the database configuration is correct and can connect9495### Run with uvx, Client Configuration96- This method can be used directly in MCP-supported clients, no need to download the source code. For example, Tongyi Qianwen plugin, trae editor, etc.97```json98{99 "mcpServers": {100 "mysql": {101 "command": "uvx",102 "args": [103 "--from",104 "mysql_mcp_server_pro",105 "mysql_mcp_server_pro",106 "--mode",107 "stdio"108 ],109 "env": {110 "MYSQL_HOST": "192.168.x.xxx",111 "MYSQL_PORT": "3306",112 "MYSQL_USER": "root",113 "MYSQL_PASSWORD": "root",114 "MYSQL_DATABASE": "a_llm",115 "MYSQL_ROLE": "admin"116 }117 }118 }119}120```121122### Local Development with Streamable Http mode123124- Use uv to start the service125126Add the following content to your mcp client tools, such as cursor, cline, etc.127128mcp json as follows:129```130{131 "mcpServers": {132 "mysql_mcp_server_pro": {133 "name": "mysql_mcp_server_pro",134 "type": "streamableHttp",135 "description": "",136 "isActive": true,137 "url": "http://localhost:3000/mcp/"138 }139 }140}141```142143Modify the .env file content to update the database connection information with your database details:144```145# MySQL Database Configuration146MYSQL_HOST=192.168.xxx.xxx147MYSQL_PORT=3306148MYSQL_USER=root149MYSQL_PASSWORD=root150MYSQL_DATABASE=a_llm151MYSQL_ROLE=admin152```153154Start commands:155```156# Download dependencies157uv sync158159# Start160uv run -m mysql_mcp_server_pro.server161162# Custom env file location163uv run -m mysql_mcp_server_pro.server --envfile /path/to/.env164165# oauth Authentication166uv run -m mysql_mcp_server_pro.server --oauth true167```168169### Local Development with SSE Mode170171- Use uv to start the service172173Add the following content to your mcp client tools, such as cursor, cline, etc.174175mcp json as follows:176```177{178 "mcpServers": {179 "mysql_mcp_server_pro": {180 "name": "mysql_mcp_server_pro",181 "description": "",182 "isActive": true,183 "url": "http://localhost:9000/sse"184 }185 }186}187```188189Modify the .env file content to update the database connection information with your database details:190```191# MySQL Database Configuration192MYSQL_HOST=192.168.xxx.xxx193MYSQL_PORT=3306194MYSQL_USER=root195MYSQL_PASSWORD=root196MYSQL_DATABASE=a_llm197MYSQL_ROLE=admin198```199200Start commands:201```202# Download dependencies203uv sync204205# Start206uv run -m mysql_mcp_server_pro.server --mode sse207208# Custom env file location209uv run -m mysql_mcp_server_pro.server --mode sse --envfile /path/to/.env210```211212### Local Development with STDIO Mode213214Add the following content to your mcp client tools, such as cursor, cline, etc.215216mcp json as follows:217```218{219 "mcpServers": {220 "operateMysql": {221 "isActive": true,222 "name": "operateMysql",223 "command": "uv",224 "args": [225 "--directory",226 "/Volumes/mysql_mcp_server_pro/src/mysql_mcp_server_pro", # Replace this with your project path227 "run",228 "-m",229 "mysql_mcp_server_pro.server",230 "--mode",231 "stdio"232 ],233 "env": {234 "MYSQL_HOST": "localhost",235 "MYSQL_PORT": "3306",236 "MYSQL_USER": "root",237 "MYSQL_PASSWORD": "123456",238 "MYSQL_DATABASE": "a_llm",239 "MYSQL_ROLE": "admin"240 }241 }242 }243}244```245246## Custom Tool Extensions2471. Add a new tool class in the handles package, inherit from BaseHandler, and implement get_tool_description and run_tool methods2482492. Import the new tool in __init__.py to make it available in the server250251## OAuth2.0 Authentication2521. Start the authentication service. By default, it uses the built-in OAuth 2.0 password mode authentication. You can modify your own authentication service address in the env file.253```aiignore254uv run -m mysql_mcp_server_pro.server --oauth true255```2562572. Visit the authentication service at http://localhost:3000/login. Default username and password are configured in the env file.258 2592602613. Copy the token and add it to the request headers, for example:262 263264```json265{266 "mcpServers": {267 "mysql_mcp_server_pro": {268 "name": "mysql_mcp_server_pro",269 "type": "streamableHttp",270 "description": "",271 "isActive": true,272 "url": "http://localhost:3000/mcp/",273 "headers": {274 "authorization": "bearer TOKEN_VALUE"275 }276 }277 }278}279```280281## Examples2821. Create a new table and insert data, prompt format as follows:283```284# Task285 Create an organizational structure table with the following structure: department name, department number, parent department, is valid.286# Requirements287 - Table name: department288 - Common fields need indexes289 - Each field needs comments, table needs comment290 - Generate 5 real data records after creation291```2922932942952962. Query data based on table comments, prompt as follows:297```298Search for data with Department name 'Executive Office' in Department organizational structure table299```3003013023033. Analyze slow SQL, prompt as follows:304```305select * from t_jcsjzx_hjkq_cd_xsz_sk xsz306left join t_jcsjzx_hjkq_jcd jcd on jcd.cddm = xsz.cddm307Based on current index situation, review execution plan and provide optimization suggestions in markdown format, including table index status, execution details, and optimization recommendations308```3093104. Analyze SQL deadlock issues, prompt as follows:311```312update t_admin_rms_zzjg set sfyx = '0' where xh = '1' is stuck, please analyze the cause313```3143153163175. Analyze the health status prompt as follows318```319Check the current health status of MySQL320```321322
Full transparency — inspect the skill content before installing.