All queries are executed within a READ ONLY transaction to ensure database safety.
Installation
Configuration
Environment Variables
The MySQL server uses environment variables or themysql-connect tool for secure credential management:
MYSQL_USER: MySQL username (optional if usingmysql-connect)MYSQL_PASSWORD: MySQL password (optional if usingmysql-connect)
Connection String
The connection string should contain only the host, port, and database information (without embedded credentials). Providing it as a command-line argument is optional. If omitted at startup, you must use themysql-connect tool to establish a connection before using other functionality.
Supported connection string formats:
mysql://host:port/dbnamehost:port/dbname
Usage
Claude Desktop
Locate your Claude Desktop config file
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json
Add the MySQL MCP server configuration
When running Docker on macOS and connecting to MySQL on your host machine, use
host.docker.internal instead of localhost.VS Code
Add this configuration to your VS Code User Settings (JSON) or.vscode/mcp.json:
The
mcp key is not needed in the .vscode/mcp.json file.When using Docker and connecting to MySQL on your host machine, use
host.docker.internal instead of localhost in the connection URL.Antigravity Code Editor
Add this configuration to~/.gemini/antigravity/mcp_config.json:
Features
Tools
mysql-query
Execute read-only SQL queries against the connected MySQL database. Input:sql(string): The SQL query to execute
All queries are executed within a READ ONLY transaction.
mysql-explain
Explain plan SQL queries against the connected MySQL database. Input:sql(string): The SQL query to explain
mysql-stats
Get statistics for a given table in the current connected database. Input:name(string): The table name
mysql-connect
Reconnect using new credentials. Inputs:connectionString(string): MySQL connect string (e.g.,host.docker.internal:3306/mydb)user(string): Username (e.g.,root)password(string): Password
mysql-awr
Generate a MySQL performance report similar to Oracle AWR. Includes:- Database statistics
- InnoDB metrics
- Top queries (requires
performance_schema) - Table/index statistics
- Connection info
- Optimization recommendations
Resources
The server provides schema information for each table in the MySQL database: Table Schemas (mysql://<database>/<table>/schema)
- JSON schema information for each table
- Includes column names and data types
- Automatically discovered from MySQL database metadata
Example Prompts
- “Connect to host.docker.internal:3306/mydb using root as user and password123 as password using mysql mcp server”
- “Query all tables in the current database”
- “Get stats for the
userstable” - “Explain the execution plan for: SELECT * FROM users WHERE email = ‘[email protected]’”
- “Generate a performance report using mysql-awr”
- “Based on the AWR report, what optimizations would you recommend?”
Additional Resources
- Change Log
- Demos - Usage examples with Claude Desktop, Docker AI, Gemini CLI, and Antigravity Code Editor
- MySQL AWR in Action - Example performance report with optimization opportunities
- GitHub Repository