MySQL MCP Server Pro is a powerful tool that enables you to interact with MySQL databases through the Model Context Protocol, providing not only basic CRUD operations but also advanced database analysis capabilities. It supports various authentication methods and transfer modes to fit your specific needs.
To install the MySQL MCP Server Pro, use pip:
pip install mysql_mcp_server_pro
Create a .env
file with your MySQL database connection details:
# MySQL Database Configuration
MYSQL_HOST=localhost
MYSQL_PORT=3306
MYSQL_USER=your_username
MYSQL_PASSWORD=your_password
MYSQL_DATABASE=your_database
# Optional, default is 'readonly'. Available values: readonly, writer, admin
MYSQL_ROLE=readonly
The permission roles control what SQL operations are allowed:
readonly
: Can only execute SELECT, SHOW, DESCRIBE, and EXPLAIN statementswriter
: Can also execute INSERT, UPDATE, and DELETE statementsadmin
: Has full access including CREATE, ALTER, DROP, and TRUNCATE statementsYou can run the server in different modes:
mysql_mcp_server_pro --envfile /path/to/.env
mysql_mcp_server_pro --mode sse --envfile /path/to/.env
This mode is typically used when configuring the server within an MCP client.
For MCP-supported clients, add this configuration:
{
"mcpServers": {
"mysql": {
"command": "uvx",
"args": [
"--from",
"mysql_mcp_server_pro",
"mysql_mcp_server_pro",
"--mode",
"stdio"
],
"env": {
"MYSQL_HOST": "192.168.x.xxx",
"MYSQL_PORT": "3306",
"MYSQL_USER": "root",
"MYSQL_PASSWORD": "root",
"MYSQL_DATABASE": "a_llm",
"MYSQL_ROLE": "admin"
}
}
}
}
Configure your MCP client with:
{
"mcpServers": {
"mysql_mcp_server_pro": {
"name": "mysql_mcp_server_pro",
"type": "streamableHttp",
"description": "",
"isActive": true,
"url": "http://localhost:3000/mcp/"
}
}
}
Start the server:
uv run -m mysql_mcp_server_pro.server
Configure your MCP client with:
{
"mcpServers": {
"mysql_mcp_server_pro": {
"name": "mysql_mcp_server_pro",
"description": "",
"isActive": true,
"url": "http://localhost:9000/sse"
}
}
}
Start the server:
uv run -m mysql_mcp_server_pro.server --mode sse
To enable OAuth2.0 authentication:
uv run -m mysql_mcp_server_pro.server --oauth true
Visit http://localhost:3000/login to get your authentication token.
Add the token to your client configuration:
{
"mcpServers": {
"mysql_mcp_server_pro": {
"name": "mysql_mcp_server_pro",
"type": "streamableHttp",
"description": "",
"isActive": true,
"url": "http://localhost:3000/mcp/",
"headers": {
"authorization": "bearer TOKEN_VALUE"
}
}
}
}
The server provides several powerful tools:
Example prompt:
# Task
Create an organizational structure table with the following structure: department name, department number, parent department, is valid.
# Requirements
- Table name: department
- Common fields need indexes
- Each field needs comments, table needs comment
- Generate 5 real data records after creation
Example prompt:
Search for data with Department name 'Executive Office' in Department organizational structure table
Example prompt:
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 in markdown format, including table index status, execution details, and optimization recommendations
Example prompt:
Check the current health status of MySQL
To add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "mysql_mcp_server_pro" '{"command":"uvx","args":["--from","mysql_mcp_server_pro","mysql_mcp_server_pro","--mode","stdio"],"env":{"MYSQL_HOST":"localhost","MYSQL_PORT":"3306","MYSQL_USER":"your_username","MYSQL_PASSWORD":"your_password","MYSQL_DATABASE":"your_database","MYSQL_ROLE":"readonly"}}'
See the official Claude Code MCP documentation for more details.
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 > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"mysql_mcp_server_pro": {
"command": "uvx",
"args": [
"--from",
"mysql_mcp_server_pro",
"mysql_mcp_server_pro",
"--mode",
"stdio"
],
"env": {
"MYSQL_HOST": "localhost",
"MYSQL_PORT": "3306",
"MYSQL_USER": "your_username",
"MYSQL_PASSWORD": "your_password",
"MYSQL_DATABASE": "your_database",
"MYSQL_ROLE": "readonly"
}
}
}
}
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 explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
2. Add this to your configuration file:
{
"mcpServers": {
"mysql_mcp_server_pro": {
"command": "uvx",
"args": [
"--from",
"mysql_mcp_server_pro",
"mysql_mcp_server_pro",
"--mode",
"stdio"
],
"env": {
"MYSQL_HOST": "localhost",
"MYSQL_PORT": "3306",
"MYSQL_USER": "your_username",
"MYSQL_PASSWORD": "your_password",
"MYSQL_DATABASE": "your_database",
"MYSQL_ROLE": "readonly"
}
}
}
}
3. Restart Claude Desktop for the changes to take effect