MySQL MCP Server

v1.1.1Databasesstable

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

aimcpmodel-context-protocolmysqldockerfile
Share:
1,255
Stars
0
Downloads
0
Weekly
0/5

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

Secure MySQL database interaction
Schema discovery and CRUD operations for AI
designcomputer

Maintainer

LicenseMIT License
Languagepython
Versionv1.1.1
UpdatedMay 21, 2026
Statushealthy
Maintenanceactive

Works with

ClaudeOpenAIwindowsmacoslinux

Installation

NPM

npx -y @imrieul/mysql-mcp-server

Manual Installation

npx -y @imrieul/mysql-mcp-server

Configuration

Configuration Details

Config File

claude_desktop_config.json

Performance

Response Metrics

Response Time< 200ms
ThroughputMedium

Resource Usage

Memory UsageLow
CPU UsageLow

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
1

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-server
2

Verify 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_database
3

Configure 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"
      }
    }
  }
}
4

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"
5

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"
6

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.

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.

Quick Config Preview

{ "mcpServers": { "mysql-mcp-server": { "command": "npx", "args": ["-y", "@imrieul/mysql-mcp-server"] } } }

Add this to your claude_desktop_config.json or .cursor/mcp.json

Read the full setup guide →

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.

33,000+ ServersFree & Open SourceStep-by-Step Guides