mcp_mysql_server
@wenb1n-dev
Model Context Protocol (MCP) server that supports secure interaction with MySQL databases and has anomaly analysis capabilities.更加牛逼!更加好用!不仅止于mysql的增删改查功能; 还包含了数据库异常分析能力;且便于开发者们进行个性化的工具扩展
Overview
What is mcp_mysql_server_pro?
mcp_mysql_server_pro is an MCP server for MySQL that goes beyond basic CRUD operations by offering database anomaly analysis, SQL optimization, and easy extensibility with custom tools. It supports all MCP transport modes (STDIO, SSE, Streamable Http), OAuth2.0 authentication, and role‑based permission control.
How to use mcp_mysql_server_pro?
Install via pip install mysql_mcp_server_pro, then configure a .env file with MySQL connection details and role. Start the server in your preferred mode: mysql_mcp_server_pro --mode sse --envfile /path/to/.env for SSE, or use uvx in client JSON for STDIO. For local development, clone the repository, run uv sync, then uv run -m mysql_mcp_server_pro.server.
Key features of mcp_mysql_server_pro
- Supports all MCP transport modes (STDIO, SSE, Streamable Http)
- Built‑in OAuth2.0 authentication
- Multiple SQL statements separated by ";" in one call
- Query table names and fields by table comments
- SQL execution plan analysis and optimization suggestions
- Convert Chinese field names to pinyin initials
- Table lock and database health status analysis
- Three permission roles: readonly, writer, admin
- Prompt templates for MySQL analysis and query assistance
- Extensible with custom tools via BaseHandler
Use cases of mcp_mysql_server_pro
- Create tables and insert data using natural language prompts
- Search for table structures and indexes using table comments
- Analyze and optimize slow-performing SQL queries
- Diagnose deadlocks and lock contention in MySQL
- Monitor overall database health, transaction status, and index usage
FAQ from mcp_mysql_server_pro
What permission roles does mcp_mysql_server_pro support?
Three roles: readonly (SELECT, SHOW, DESCRIBE, EXPLAIN), writer (adds INSERT, UPDATE, DELETE), and admin (adds CREATE, ALTER, DROP, TRUNCATE).
Which transport modes and authentication are supported?
It supports STDIO, SSE, and Streamable Http modes. OAuth2.0 authentication is available for Streamable Http via the --oauth true flag.
How can I add custom tools to mcp_mysql_server_pro?
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 are the runtime requirements?
Python with pip install mysql_mcp_server_pro, or use uvx without local installation. The server connects to a MySQL database specified in a .env file or environment variables.
Can I use it without installing the package locally?
Yes, you can run it directly using uvx in MCP client configuration, pointing to the mysql_mcp_server_pro package.