Skip to content

MySQL Shell

Chris edited this page Jul 18, 2026 · 110 revisions

MySQL Shell

Tools Resources Prompts
OAuth Code Mode Rate Limiting

Value Proposition Enable AI agents to perform parallel imports and full instance dumps. Establish clear administrative boundaries and securely orchestrate complex database scripts. Read the full value proposition


Orchestrate Prerequisites

  • MySQL Shell binary accessible (in PATH or via environment variable)
  • Version Compatibility: MySQL Shell version should match your MySQL Server version.

Leverage Advanced Shell Management Capabilities

The server provides tools for MySQL Shell management. Direct users to the native MCP discovery mechanism or the mysql_tool_index prompt to explore the complete list of available tools. Ecosystem tools (Router, Shell) are conditionally loaded only when their respective binaries and credentials are detected.

Prominent Examples:

  • mysqlsh_version: Get MySQL Shell version and installation status.
  • mysqlsh_dump_instance: Dump entire MySQL instance.
  • mysqlsh_load_dump: Load MySQL Shell dump.

Streamline Tool Requirements

Tool Requirements
mysqlsh_import_json Requires X Protocol (typically port 33060) for collection imports. NDJSON format only
mysqlsh_import_table Requires target tables to have a PRIMARY KEY when importing to InnoDB Cluster
mysqlsh_load_dump / mysqlsh_import_table Requires local_infile=ON in MySQL Server config. Use SET GLOBAL local_infile = 1; or configure it in my.cnf.
mysqlsh_check_upgrade User needs RELOAD, PROCESS, SELECT privileges
mysqlsh_dump_* / mysqlsh_load_dump Shell version should match server version
mysqlsh_* Operates under standard execution boundaries. When OAuth is enabled, the shell tools require the admin scope.

Establish Enterprise Operational Baselines

Ensure execution of database migrations by verifying your environment against these operational baselines:

1. Verify Installation

mysqlsh --version
# Expected: mysqlsh   Ver <version> for ...

2. Enable local_infile (for mysqlsh_load_dump)

SET GLOBAL local_infile = 1;

Or add to my.cnf:

[mysqld]
local_infile=ON

3. Verify X Protocol (for mysqlsh_import_json)

mysqlsh --uri root@localhost:33060 --sql -e "SELECT 1"

Optimize Your Enterprise Environment

Variable Default Description
MYSQLSH_PATH mysqlsh Path to MySQL Shell binary
MYSQLSH_WORK_DIR Current directory Working directory for dump/load operations
MYSQLSH_TIMEOUT 300000 Command timeout in milliseconds (5 min)
MYSQL_XPORT 33060 X Protocol port (for mysqlsh_import_json). Intentionally used instead of the standard MYSQLX_PORT.

Warning

Shell operations may exceed default HTTP timeouts. Increase MCP_REQUEST_TIMEOUT to prevent dropped connections. This applies specifically to HTTP/SSE clients, not standard stdio. When running heavy HTTP migrations, explicitly align MCP_REQUEST_TIMEOUT with MYSQLSH_TIMEOUT.

Warning

MySQL Shell commands execute as subprocesses. Ensure proper file permissions. Configure --allowed-io-roots to permit sandbox access.


Seamless Server Integration

{
  "mcpServers": {
    "mysql-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@neverinfamous/mysql-mcp",
        "--transport",
        "stdio",
        "--mysql",
        "mysql://user:password@localhost:3306/database",
        "--allowed-io-roots",
        "C:/temp,/tmp"
      ],
      "env": {
        "MYSQLSH_PATH": "mysqlsh"
      }
    }
  }
}

Note

Global install users can substitute npx -y @neverinfamous/mysql-mcp with mysql-mcp.


Architect Workload Isolation

For environments requiring workload isolation:

{
  "mcpServers": {
    "mysql-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@neverinfamous/mysql-mcp",
        "--transport",
        "stdio",
        "--mysql",
        "mysql://user:password@localhost:3306/database",
        "--allowed-io-roots",
        "C:/temp,/tmp",
        "--tool-filter",
        "shell"
      ]
    }
  }
}

This exposes only the MySQL Shell management tools.

Note

OAuth requires the http transport. Desktop clients (such as Claude Desktop and Cursor) using mcp.json and stdio cannot natively use OAuth. See OAuth Configuration for details.


Ensure Enterprise Validation & Safeguards

The MCP server automatically validates all tool parameters before execution using Zod for Standard Schema validation and safe parsing best practices. This ensures reliable operations and prevents invalid arguments from reaching MySQL Shell by gracefully rejecting hallucinated payloads.


Explore Related Topics

MySQL MCP Documentation

Value Proposition Enforce strict execution boundaries and maximize LLM context efficiency for secure, autonomous database interactions. Read the full value proposition

🏠 Home


Launch Your Setup


Connect Ecosystem Tools


Security & Compliance


Scale Your Operations


Explore External Links

Clone this wiki locally