MySQL MCP Server
Enables AI assistants to securely interact with MySQL databases for schema discovery, data querying, and record management with configurable access controls. It provides specialized tools for listing tables, describing structures, and performing CRUD
What is MySQL MCP Server?
MySQL MCP Server is a Model Context Protocol (MCP) server that allows AI assistants like Claude, Cursor, and VS Code to enables ai assistants to securely interact with mysql databases for schema discovery, data querying, and record management with configurable access controls. it provides specialized tools for listing ...
Enables AI assistants to securely interact with MySQL databases for schema discovery, data querying, and record management with configurable access controls. It provides specialized tools for listing tables, describing structures, and performing CRUD
This server falls under the Databases category on MCPgee, the world's largest MCP server directory with 33,000+ servers.
Features
- Enables AI assistants to securely interact with MySQL databa
Use Cases
Maintainer
Works with
Installation
NPM
npx -y @imrieul/mysql-mcp-serverManual Installation
npx -y @imrieul/mysql-mcp-serverConfiguration
Configuration Details
claude_desktop_config.json
Performance
Response Metrics
Resource Usage
How to Set Up and Use MySQL MCP Server
The MySQL MCP Server lets AI assistants like Claude securely interact with MySQL databases through a well-defined set of tools — listing tables, describing schemas, sampling data, and executing SQL — without ever giving the AI unrestricted database access. It supports SSL/TLS connections, SSH tunneling for remote databases, and multi-database mode, making it suitable for both local development databases and production environments where controlled, audited access is required.
Prerequisites
- Python 3.10 or higher, or uvx available on your system
- A running MySQL database (local or remote) with a user that has appropriate read/write permissions
- The database hostname, port (default 3306), username, password, and target database name
- An MCP client such as Claude Desktop or Claude Code
Install the MySQL MCP server
Install the server via pip or use uvx to run it without a permanent install. The pip package is named mysql-mcp-server.
pip install mysql-mcp-serverVerify your MySQL credentials
Before wiring up the MCP server, confirm you can connect to your database with the credentials you plan to use. The server needs at least SELECT permission; for write operations it needs INSERT, UPDATE, and DELETE as well.
mysql -h localhost -u your_username -p your_databaseConfigure the MCP server in Claude Desktop
Add the MySQL MCP server to your claude_desktop_config.json. The five core environment variables are MYSQL_HOST, MYSQL_PORT, MYSQL_USER, MYSQL_PASSWORD, and MYSQL_DATABASE.
{
"mcpServers": {
"mysql": {
"command": "uvx",
"args": ["mysql_mcp_server"],
"env": {
"MYSQL_HOST": "localhost",
"MYSQL_PORT": "3306",
"MYSQL_USER": "your_username",
"MYSQL_PASSWORD": "your_password",
"MYSQL_DATABASE": "your_database"
}
}
}
}Enable SSL for production databases (optional)
For production databases, add MYSQL_SSL_MODE to enforce encrypted connections. REQUIRED enforces TLS without certificate verification; VERIFY_IDENTITY adds full hostname verification.
"MYSQL_SSL_MODE": "REQUIRED"Configure SSH tunneling for remote databases (optional)
If your MySQL server is only accessible via a bastion/jump host, enable SSH tunneling with these additional environment variables in your MCP config.
"MYSQL_SSH_ENABLE": "true",
"MYSQL_SSH_HOST": "bastion.example.com",
"MYSQL_SSH_PORT": "22",
"MYSQL_SSH_USER": "ubuntu",
"MYSQL_SSH_KEY_PATH": "/Users/you/.ssh/id_rsa"Restart Claude Desktop and test
Restart Claude Desktop. You should now be able to ask Claude to list tables, describe schemas, or query data in your MySQL database using the three available tools: execute_sql, get_schema_info, and get_table_sample.
MySQL MCP Server Examples
Client configuration
Full Claude Desktop configuration for MySQL MCP server connecting to a local database.
{
"mcpServers": {
"mysql": {
"command": "uvx",
"args": ["mysql_mcp_server"],
"env": {
"MYSQL_HOST": "localhost",
"MYSQL_PORT": "3306",
"MYSQL_USER": "app_user",
"MYSQL_PASSWORD": "s3cur3p@ss",
"MYSQL_DATABASE": "ecommerce",
"MYSQL_SSL_MODE": "DISABLED"
}
}
}
}Prompts to try
Example prompts to send to Claude once the MySQL MCP server is connected.
- "List all tables in the database and describe their purpose"
- "Show me the schema for the orders table including column types and constraints"
- "What are the top 10 customers by total order value in the last 30 days?"
- "Find any tables that have more than 1 million rows"
- "Write and run a query to count the number of orders per status"Troubleshooting MySQL MCP Server
Connection refused or 'Can't connect to MySQL server' error
Verify MYSQL_HOST and MYSQL_PORT are correct. If connecting to a remote host, check firewall rules allow the connection on port 3306. For Docker-based MySQL, confirm the container is running and the port is exposed.
Access denied for user error
Confirm MYSQL_USER and MYSQL_PASSWORD are correct. Connect manually with 'mysql -h HOST -u USER -p DATABASE' to verify. Grant the required permissions: GRANT SELECT, INSERT, UPDATE, DELETE ON database.* TO 'user'@'host';
Only SELECT queries work, DML statements fail
The database user may only have read privileges. Grant write permissions for INSERT, UPDATE, DELETE on the target database, or use a different user account with the required privileges.
Frequently Asked Questions about MySQL MCP Server
What is MySQL MCP Server?
MySQL MCP Server is a Model Context Protocol (MCP) server that enables ai assistants to securely interact with mysql databases for schema discovery, data querying, and record management with configurable access controls. it provides specialized tools for listing tables, describing structures, and performing crud It connects AI assistants to external tools and data sources through a standardized interface.
How do I install MySQL MCP Server?
Install via npm with the command: npx -y @imrieul/mysql-mcp-server. Then add the server configuration to your AI client's JSON config file (e.g., claude_desktop_config.json or .cursor/mcp.json).
Which AI clients work with MySQL MCP Server?
MySQL MCP Server works with all major MCP-compatible AI clients including Claude Desktop, Claude Code, Cursor, VS Code (GitHub Copilot), Windsurf, and Cline.
Is MySQL MCP Server free to use?
Yes, MySQL MCP Server is open source and available under the MIT License license. You can use it freely in both personal and commercial projects.
MySQL MCP Server Alternatives — Similar Databases Servers
Looking for alternatives to MySQL MCP Server? Here are other popular databases servers you can use with Claude, Cursor, and VS Code.
Excelize
★ 20.6kGo language library for reading and writing Microsoft Excel™ (XLAM / XLSM / XLSX / XLTM / XLTX) spreadsheets
MCP Toolbox for Databases
★ 15.3kOpen source MCP server specializing in easy, fast, and secure tools for Databases.
DBHub
★ 2.8kA universal database gateway MCP server that enables AI assistants to connect to and query multiple databases (PostgreSQL, MySQL, MariaDB, SQL Server, SQLite) with support for schema exploration, SQL execution, and secure connections via SSH tunnels.
Tabularis
★ 2.1kA lightweight, cross-platform database client for developers. Supports MySQL, PostgreSQL and SQLite. Hackable with plugins. Built for speed, security, and aesthetics.
Postgres AI Guide
★ 1.7kMCP server and Claude plugin for Postgres skills and documentation. Helps AI coding tools generate better PostgreSQL code.
Anyquery
★ 1.7k🏎️ 🏠 ☁️ - Query more than 40 apps with one binary using SQL. It can also connect to your PostgreSQL, MySQL, or SQLite compatible database. Local-first and private by design.
Browse More Databases MCP Servers
Explore all databases servers available in the MCPgee directory. Each server includes setup guides for Claude, Cursor, and VS Code.
Set Up MySQL MCP Server in Your Editor
Choose your AI client for step-by-step setup instructions.
Quick Config Preview
Add this to your claude_desktop_config.json or .cursor/mcp.json
Ready to use MySQL MCP Server?
Browse our complete directory of 33,000+ MCP servers, read setup guides for your editor, and start building with the Model Context Protocol.