================== /// MCP /// /// MYS /// ================== [server:online] [protocol:ready]
mysql_mcp_server_pro
by wenb1n-dev
Python-based Model Context Protocol (MCP) server for secure, role-based interaction with MySQL. Adds SQL execution, health / lock / index analysis tooling and is easily extensible.
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
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)
Installation
git clone https://github.com/wenb1n-dev/mysql_mcp_server_pro.git
cd mysql_mcp_server_pro
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -U pip
pip install -r requirements.txt
mysql:
host: <MYSQL_HOST>
port: 3306
user: <MYSQL_USER>
password: <MYSQL_PASSWORD>
database: <DB_NAME>
auth:
oauth2_client_id: <CLIENT_ID>
oauth2_client_secret: <CLIENT_SECRET>
allowed_origins: ["*"]
python manage.py migrate # or alembic upgrade head depending on framework
python -m mcp_server # or uvicorn mcp_server.app:app --reload
GET http://localhost:8080/health returns {"status":"ok"}