Overview
What is mcp_mysql_server?
mcp_mysql_server is a MySQL database MCP server that supports CRUD operations, database anomaly analysis, and custom tool extensions. It is intended for developers who need to interact with MySQL databases through an MCP client with role‑based permissions and built-in diagnostics.
How to use mcp_mysql_server?
Install the package with pip install mysql_mcp_server_pro, create a .env file with MySQL connection details and the desired role (readonly, writer, or admin), then start the server via mysql_mcp_server_sse for SSE mode or using uvx/uv for STDIO mode. Configure your MCP client with the appropriate JSON settings.
Key features of mcp_mysql_server
- Execute multiple SQL statements separated by ";"
- Query table names and fields using table comments
- Analyze SQL execution plans
- Convert Chinese field names to pinyin initials
- Detect row-level and table-level locks
- Assess MySQL health status (connections, transactions, locks)
- Permission control with three roles (readonly, writer, admin)
- Supports both STDIO and SSE transport modes
Use cases of mcp_mysql_server
- Perform database CRUD operations with configurable permissions
- Diagnose slow SQL queries and deadlock issues
- Monitor overall MySQL health and index usage
- Automate table creation and data insertion via natural-language prompts
- Extend with custom tools for additional database analysis
FAQ from mcp_mysql_server
What permission roles are available?
Three roles: readonly (SELECT, SHOW, DESCRIBE, EXPLAIN), writer (adds INSERT, UPDATE, DELETE), and admin (adds CREATE, ALTER, DROP, TRUNCATE). Role is set via the MYSQL_ROLE environment variable.
How do I install and configure mcp_mysql_server?
Install with pip install mysql_mcp_server_pro, then set the environment variables MYSQL_HOST, MYSQL_PORT, MYSQL_USER, MYSQL_PASSWORD, MYSQL_DATABASE, and optionally MYSQL_ROLE in a .env file or in your shell.
What tools does mcp_mysql_server provide?
It provides eight tools: execute_sql, get_chinese_initials, get_db_health_running, get_table_desc, get_table_index, get_table_lock, get_table_name, and get_db_health_index_usage.
Can I add custom tools to mcp_mysql_server?
Yes. Create a new tool class in the handles package that inherits from BaseHandler, implement get_tool_description and run_tool, then import it in __init__.py.
What transport modes are supported?
Both STDIO and SSE modes are supported. Use mysql_mcp_server_sse for SSE or configure a uv command with --stdio for STDIO.