MySQL MCP Server

Query MySQL databases, list tables, and inspect schemas from your AI assistant

By benborla29 (community) community database sql

The MySQL MCP Server connects Claude and other MCP-compatible agents directly to a MySQL or MariaDB database. Ask natural-language questions, run SQL queries, explore table schemas, and iterate on results — without leaving your AI chat session. Supports both read and write operations depending on your database user's privileges.

Installation & Configuration

Add this block to your claude_desktop_config.json (or your agent framework's MCP config file):

{
  "mcpServers": {
    "mysql": {
      "command": "npx",
      "args": ["-y", "@benborla29/mcp-server-mysql"],
      "env": {
        "MYSQL_HOST": "127.0.0.1",
        "MYSQL_PORT": "3306",
        "MYSQL_USER": "your_user",
        "MYSQL_PASS": "your_password",
        "MYSQL_DB": "your_database"
      }
    }
  }
}

Config file location:

Creating a read-only MySQL user (recommended):

CREATE USER 'mcp_ro'@'localhost' IDENTIFIED BY 'strong_password';
GRANT SELECT ON your_database.* TO 'mcp_ro'@'localhost';
FLUSH PRIVILEGES;

Available Tools (4)

Use Cases

Gotchas

Security Note

Always connect with a dedicated read-only MySQL user unless you explicitly need writes. An AI assistant connected to a write-enabled production database can issue destructive queries. Never expose your root or admin credentials. Restrict the database user to only the schemas it needs with GRANT SELECT ON specific_db.*.

Source & Documentation

GitHub Repository: https://github.com/benborla/mcp-server-mysql

Protocol: Model Context Protocol (MCP) — modelcontextprotocol.io

MCP Setup Pack — $15
20 ready-to-paste server configs + installer + doctor script
Get the Pack →
← Back to MCP Server Directory