Mysql MCP Server

Add `--scope project` after `mcp add` to keep the registration in the current workspace. See [Autohand Code](https://github.com/autohandai/code-cli/)

Remote serverstreamable-httpPython

What is the Mysql MCP server?

If you want an AI assistant working directly with Mysql, the mysql mcp server is the bridge. Add --scope project after mcp add to keep the registration in the current workspace. See Autohand Code for current CLI details.

What Mysql does

Add --scope project after mcp add to keep the registration in the current workspace. See Autohand Code for current CLI details.

Key capabilities

  • List available MySQL tables as resources
  • Read table contents
  • Execute SQL queries with proper error handling
  • Multi-database mode — (Optional MYSQL_DATABASE)
  • SSE/HTTP transport support — (MCP_TRANSPORT=sse)
  • SSH Tunneling support —
  • Comprehensive schema information —
  • Table data sampling —

Tools it exposes

Once connected, the assistant can call these 3 tools directly:

  • execute_sql — Executes any standard SQL query. - Arguments: query (string) - Features: Supports SELECT, SHOW, DESCRIBE, and DML (INSERT, UPDATE, DELETE). DML
  • get_schema_info — Provides detailed metadata about database structures. - Arguments: table_name (optional string) - Output: Column names, types, nullability, default
  • get_table_sample — Fetches a representative sample of data. - Arguments: table_name (string), limit (optional integer, max 20) - Use Case: Quickly understand data formats

Installing the mysql mcp server

The server is distributed via npm as @smithery/cli, so most clients can run it without a manual build step. Add it to your MCP client's configuration and restart the client to pick it up — the copy-paste configs for Claude Desktop, Claude Code and Cursor are on this page.

Configuration

Before the server will start you need to supply 8 environment variables: MYSQL_HOST, MYSQL_PORT, MYSQL_USER, MYSQL_PASSWORD, MYSQL_DATABASE, MCP_SSE_HOST, MYSQL_SSH_HOST, MYSQL_SSH_KEY_PATH. Keep credentials in your client's env block or a secrets manager rather than committing them.

Where it fits

Database servers turn schema archaeology and ad-hoc reporting into conversation, which is why they tend to be the second or third server people install. Mysql sits in that group, and the shape of its toolset — execute_sql, get_schema_info, get_table_sample — tells you what it is really for. Worth comparing against the other databases servers in this directory before you commit to one, since several overlap in scope but differ sharply in setup cost and permissions.

Practical notes

  • This is a hosted server — you point your client at an endpoint rather than running a local process, so there is nothing to keep updated on your machine.
  • It will not start until its required credentials are present, so set those before wondering why the tools never appear.
  • Maintained by designcomputer, written in Python.
  • MCP clients ask for confirmation before each tool call by default. Keep that on while you learn what the mysql mcp server actually does with your data.
  • Every entry in this directory is reviewed by hand before it goes live, and details are checked against the project's own documentation.

Available tools

ToolWhat it does
execute_sqlExecutes any standard SQL query. - **Arguments:** query (string) - **Features:** Supports SELECT, SHOW, DESCRIBE, and DML (INSERT, UPDATE, DELETE). DML operations are marked with a destructive hint. - **Limitation:** Sin
get_schema_infoProvides detailed metadata about database structures. - **Arguments:** table_name (optional string) - **Output:** Column names, types, nullability, default values, and comments. - **Cross-database:** Pass database.table
get_table_sampleFetches a representative sample of data. - **Arguments:** table_name (string), limit (optional integer, max 20) - **Use Case:** Quickly understand data formats and content without fetching large result sets. - **Cross-da

How to install the Mysql MCP server

{
  "mcpServers": {
    "mysql": {
      "command": "uv",
      "args": [
        "--directory",
        "path/to/mysql_mcp_server",
        "run",
        "mysql_mcp_server"
      ],
      "env": {
        "MYSQL_HOST": "localhost",
        "MYSQL_PORT": "3306",
        "MYSQL_USER": "your_username",
        "MYSQL_PASSWORD": "your_password",
        "MYSQL_DATABASE": "your_database"
      }
    }
  }
}

Configuration as documented by the project. Restart the client after saving.

Configuration

VariableDescriptionRequired
MYSQL_HOSTEndpoint or connection string the server talks to.Optional
MYSQL_PORTConfiguration value read at startup.Optional
MYSQL_USERConfiguration value read at startup.Optional
MYSQL_PASSWORDConfiguration value read at startup.Optional
MYSQL_DATABASEConfiguration value read at startup.Optional
MCP_SSE_HOSTEndpoint or connection string the server talks to.Optional
MYSQL_SSH_HOSTEndpoint or connection string the server talks to.Optional
MYSQL_SSH_KEY_PATHCredential the server authenticates with.Yes

Example prompts to try

  • Use Mysql to execute sql.
  • Use Mysql to get schema info.
  • Use Mysql to get table sample.

Frequently asked questions

It connects Mysql to MCP-compatible AI assistants such as Claude and Cursor, exposing 3 tools (execute_sql, get_schema_info, get_table_sample) that the assistant can call on your behalf. Instead of copying data back and forth by hand, the assistant works with Mysql directly.