mcp_mysql_server_pro
Introduction
mcp_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.
- 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 table comments
- Supports SQL execution plan analysis
- Supports Chinese field to pinyin conversion
- Supports table lock analysis
- Supports database health status analysis
- Supports permission control with three roles: readonly, writer, and admin
- Supports prompt template invocation
Tool List
Tool Name | Description |
---|---|
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) |
Prompt List
Prompt Name | Description |
---|---|
analyzing-mysql-prompt | This is a prompt for analyzing MySQL-related issues |
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 |
Usage Instructions
Installation and Configuration
- Install Package
- Configure Environment Variables
Create a
.env
file with the following content:
- Run Service
- mcp client
go to see see "Use uv to start the service" ^_^
Note:
- The
.env
file should be placed in the directory where you run the command or use --envfile parameter to specify the path - You can also set these variables directly in your environment
- Make sure the database configuration is correct and can connect
Run with uvx, Client Configuration
- 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.
Local Development with Streamable Http mode
- Use uv to start the service
Add the following content to your mcp client tools, such as cursor, cline, etc.
mcp json as follows:
Modify the .env file content to update the database connection information with your database details:
Start commands:
Local Development with SSE Mode
- Use uv to start the service
Add the following content to your mcp client tools, such as cursor, cline, etc.
mcp json as follows:
Modify the .env file content to update the database connection information with your database details:
Start commands:
Local Development with STDIO Mode
Add the following content to your mcp client tools, such as cursor, cline, etc.
mcp json as follows:
Custom Tool Extensions
- Add a new tool class in the handles package, inherit from BaseHandler, and implement get_tool_description and run_tool methods
- Import the new tool in init.py to make it available in the server
OAuth2.0 Authentication
- 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.
- Visit the authentication service at http://localhost:3000/login. Default username and password are configured in the env file.
- Copy the token and add it to the request headers, for example:
Examples
- Create a new table and insert data, prompt format as follows:
- Query data based on table comments, prompt as follows:
- Analyze slow SQL, prompt as follows:
- Analyze SQL deadlock issues, prompt as follows:
- Analyze the health status prompt as follows
hybrid server
The server is able to function both locally and remotely, depending on the configuration or use case.
STDIOモードとSSEモードのサポートを追加 「;」で区切られた複数のSQL実行のサポートを追加 テーブルコメントに基づいてデータベーステーブル名とフィールドをクエリする機能を追加 SQL実行プラン分析を追加 ピンイン変換に中国語フィールドを追加
Related MCP Servers
- AsecurityAlicenseAqualityAllows AI assistants to list tables, read data, and execute SQL queries through a controlled interface, making database exploration and analysis safer and more structured.Last updated -1768PythonMIT License
- -securityAlicense-qualityFacilitates interaction with Microsoft SQL Server Express, supporting database operations such as querying, table management, and schema inspection via natural language MCP commands.Last updated -4PythonMIT License
- -securityFlicense-qualityProvides Claude Desktop with secure access to multiple database connections, allowing users to query MySQL, PostgreSQL, SQLite, and SQL Server databases directly through natural language.Last updated -
- -securityAlicense-qualityProvides Claude with direct access to databases including SQLite, SQL Server, PostgreSQL, and MySQL, enabling execution of SQL queries and table management through natural language.Last updated -4701TypeScriptMIT License
Appeared in Searches
- Developing and redeveloping web frontend and Python backend projects, including frontend-backend integration and debugging
- Using Laravel Helper Functions and Resolving MySQL Table Query Errors
- A platform for managing code repositories and DevOps workflows
- Frontend Development Tool for Detecting Errors
- Searching for Reddit discussions about server-sent events (SSE)