Data as of

MySQL MCP Server for Claude Code: Setup & Config

Claude Code: Expose MySQL schema inspection, data samples, and SQL execution to MCP assistants.

What you can do with MySQL in Claude Code

Choose it for focused MySQL exploration with schemas, bounded samples, and explicit SQL access.

  • Explore an unfamiliar database's tables and column types.
  • Reach a MySQL instance through a configured SSH tunnel.

Before you start: MySQL in Claude Code

  • uv for the documented uvx launch
  • An accessible MySQL instance
  • MySQL credentials with the required permissions
  • An MCP-compatible client

This is the README's VS Code stdio launch. Put database values in the client's env block rather than assuming the project's .env will be discovered. Network SSE deployments require an authentication proxy outside localhost.

MySQL Claude Code configuration

  1. Choose Claude Code configuration scope

    For MySQL MCP Server, open Project scope: .mcp.json at the repository root. Project JSON: merge into mcpServers; user scope: use the CLI.

  2. Add MySQL MCP Server to Claude Code

    Use the mysql_mcp_server entry below in mcpServers. Keep MySQL MCP Server's documented stdio connection fields and your other Claude Code entries.

  3. Check MySQL MCP Server in Claude Code

    MySQL MCP Server: Inspect claude mcp list and /mcp status.

Config file · Project scope: .mcp.json at the repository root

JSON
{
  "mcpServers": {
    "mysql_mcp_server": {
      "type": "stdio",
      "command": "uvx",
      "args": [
        "--from",
        "mysql-mcp-server",
        "mysql_mcp_server"
      ],
      "env": {
        "MYSQL_HOST": "<MySQL hostname>",
        "MYSQL_PORT": "<MySQL port, default 3306>",
        "MYSQL_USER": "<dedicated least-privilege MySQL username>",
        "MYSQL_PASSWORD": "<MySQL account password>",
        "MYSQL_DATABASE": "<optional default database; omit for multi-database mode>"
      }
    }
  }
}

CLI (POSIX shell)
claude mcp add-json --scope project 'mysql_mcp_server' '{"type":"stdio","command":"uvx","args":["--from","mysql-mcp-server","mysql_mcp_server"],"env":{"MYSQL_HOST":"<MySQL hostname>","MYSQL_PORT":"<MySQL port, default 3306>","MYSQL_USER":"<dedicated least-privilege MySQL username>","MYSQL_PASSWORD":"<MySQL account password>","MYSQL_DATABASE":"<optional default database; omit for multi-database mode>"}}'

MySQL tools available to Claude Code

MySQL's stored tool list documents 3 tools; compare it with Claude Code's connected tool list, because the stored list is not a live check.

execute_sql

For MySQL's execute_sql, review the permission request and arguments in Claude Code before approval.

Run one SQL statement, including reads and permitted data-modification operations.

get_schema_info

For MySQL's get_schema_info, review the permission request and arguments in Claude Code before approval.

get_table_sample

For MySQL's get_table_sample, review the permission request and arguments in Claude Code before approval.

Read a table sample capped at 20 rows, including cross-database targets.

MySQL: full stored tool descriptions

Troubleshooting MySQL in Claude Code

  • If MySQL MCP Server fails to start, check uvx --from (from uv, for Python tools), the working directory, and Claude Code's selected scope; inspect claude mcp list and /mcp.
  • MySQL MCP Server: check MYSQL_DATABASE, MYSQL_HOST, MYSQL_PASSWORD, MYSQL_PORT, MYSQL_USER; keep credentials out of shared .mcp.json.
  • MySQL MCP Server uses stdio here: Claude Code must keep the configured process running; protocol output belongs on stdout and diagnostics on stderr.
  • Known limitation: SQL execution includes writes when database permissions allow them.
  • Known limitation: Only single-statement SQL calls are supported.
  • Known limitation: SSE mode needs external authentication when exposed beyond localhost.
  • General Claude Code troubleshooting lives in the /clients/claude-code guide.

MySQL MCP Server — details. Claude Code guide

Frequently asked questions

Register MySQL MCP Server with the displayed claude mcp add-json --scope project command, or merge the JSON into .mcp.json at the repository root.

Claude Code's mysql_mcp_server example uses stdio.

MySQL MCP Server's Claude Code configuration invokes uvx --from (from uv, for Python tools).

Claude Code's MySQL MCP Server example references MYSQL_DATABASE, MYSQL_HOST, MYSQL_PASSWORD, MYSQL_PORT, MYSQL_USER. Check these names if startup or authentication fails; the example alone does not distinguish required from optional values.

MySQL MCP Server's stored list contains 3 tools, including execute_sql, get_schema_info, get_table_sample. Compare those names with Claude Code's connected tool list; the stored list is not a live check.

No. execute_sql supports SELECT and inspection statements as well as INSERT, UPDATE, and DELETE, subject to the database user's permissions.

Clients can launch the process from a different directory. The README recommends putting MYSQL_* settings directly in the MCP environment configuration.