This server provides a MySQL interface for executing SQL queries and performing database analysis. It offers a range of features beyond basic CRUD operations, including database health monitoring, anomaly analysis, and custom tool extensions.
uv
package managerCreate or modify your .env
file with your MySQL connection details:
# MySQL Database Configuration
MYSQL_HOST=192.168.xxx.xxx
MYSQL_PORT=3306
MYSQL_USER=root
MYSQL_PASSWORD=root
MYSQL_DATABASE=a_llm
MYSQL_ROLE=readonly # Optional values: readonly, writer, admin
Install dependencies and start the server:
# Download dependencies
uv sync
# Start the server
uv run server.py
Then configure your MCP client (like Cursor or Cline) with the following JSON:
{
"mcpServers": {
"operateMysql": {
"name": "operateMysql",
"description": "",
"isActive": true,
"baseUrl": "http://localhost:9000/sse"
}
}
}
Configure your MCP client with the following JSON, adjusting the directory path to match your setup:
{
"mcpServers": {
"operateMysql": {
"isActive": true,
"name": "operateMysql",
"command": "uv",
"args": [
"--directory",
"G:\\python\\mysql_mcp\\src", # Replace with your project path
"run",
"server.py",
"--stdio"
],
"env": {
"MYSQL_HOST": "192.168.xxx.xxx",
"MYSQL_PORT": "3306",
"MYSQL_USER": "root",
"MYSQL_PASSWORD": "root",
"MYSQL_DATABASE": "a_llm",
"MYSQL_ROLE": "readonly"
}
}
}
}
The server provides several tools that can be invoked via your MCP client:
The server supports three permission roles:
# Task
Create an organizational structure table with the following structure: department name, department number, parent department, is valid.
# Requirements
- Table name: t_admin_rms_zzjg
- Field requirements: string type uses 'varchar(255)', integer type uses 'int'
- Table header needs to include primary key field, serial number XH varchar(255)
- Table must include these fixed fields at the end: creator-CJR varchar(50), creation time-CJSJ datetime
- Generate 5 real data records after creation
Query Zhang San's data from the user information table
select * from t_jcsjzx_hjkq_cd_xsz_sk xsz
left join t_jcsjzx_hjkq_jcd jcd on jcd.cddm = xsz.cddm
Based on current index situation, review execution plan and provide optimization suggestions
Check the current health status of MySQL
update t_admin_rms_zzjg set sfyx = '0' where xh = '1' is stuck, please analyze the cause
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"cursor-rules-mcp": {
"command": "npx",
"args": [
"-y",
"cursor-rules-mcp"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.