MCP Hub
Back to servers

MySQL MCP Server

A lightweight MySQL MCP server that enables LLMs to interact with databases through tools for schema inspection and query execution. It features LLM-friendly formatting, SSL support, and a secure read-only mode with query timeout protections.

Updated
Feb 3, 2026

@imrieul/mysql-mcp-server

한국어 | 日本語 | 中文 | Español | Português | Français | Русский

A simple MySQL MCP server.

Features

  • LLM-friendly — compact column/row format, auto LIMIT, error hints with next-action suggestions
  • Bulk schemadescribe_all_tables returns entire DB schema in one call
  • Read-only mode — app-level prefix check + DB-level SET SESSION TRANSACTION READ ONLY
  • Query timeoutPromise.race() based timeout with guaranteed connection cleanup
  • SSL support — one env var to enable encrypted connections
  • Minimal — 3 dependencies, zero config required

Quick Start

Add to your MCP config (.mcp.json or claude_desktop_config.json):

{
  "mcpServers": {
    "mysql": {
      "command": "npx",
      "args": ["-y", "@imrieul/mysql-mcp-server"],
      "env": {
        "MYSQL_HOST": "localhost",
        "MYSQL_PORT": "3306",
        "MYSQL_USER": "root",
        "MYSQL_PASSWORD": "your-password",
        "MYSQL_DATABASE": "your-database"
      }
    }
  }
}

Or with a connection string:

{
  "mcpServers": {
    "mysql": {
      "command": "npx",
      "args": ["-y", "@imrieul/mysql-mcp-server", "mysql://root:password@localhost:3306/mydb"]
    }
  }
}

Read-only mode with SSL

{
  "mcpServers": {
    "mysql": {
      "command": "npx",
      "args": ["-y", "@imrieul/mysql-mcp-server", "--readonly"],
      "env": {
        "MYSQL_HOST": "db.example.com",
        "MYSQL_USER": "readonly_user",
        "MYSQL_PASSWORD": "password",
        "MYSQL_DATABASE": "production",
        "MYSQL_SSL": "true",
        "MYSQL_QUERY_TIMEOUT": "10000"
      }
    }
  }
}

Tools

ToolDescriptionRead-only mode
queryExecute SELECT, SHOW, DESCRIBE, EXPLAINAllowed
executeExecute INSERT, UPDATE, DELETE, DDLBlocked
list_databasesList all databasesAllowed
list_tablesList tables in a databaseAllowed
describe_tableShow table schemaAllowed
describe_all_tablesShow all table schemas at onceAllowed

Configuration

Environment variables

VariableRequiredDefaultDescription
MYSQL_HOSTYesMySQL host
MYSQL_USERYesMySQL user
MYSQL_PASSWORDYesMySQL password
MYSQL_PORTNo3306MySQL port
MYSQL_DATABASENoDefault database
MYSQL_READONLYNofalseRead-only mode
MYSQL_MAX_ROWSNo100Auto LIMIT for SELECT queries
MYSQL_QUERY_TIMEOUTNo30000Query timeout in ms (0 to disable)
MYSQL_SSLNofalseEnable SSL connection

Connection string

mysql://user:password@host:port/database

Passed as the first CLI argument. Takes priority over environment variables.

License

MIT

Reviews

No reviews yet

Sign in to write a review