# MySQL

> Run read-only MySQL queries and inspect schemas from an AI agent.

[Canonical HTML page](https://top-mcps.com/mcp/mysql) · [server.json](https://top-mcps.com/mcp/mysql.json) · [methodology](https://top-mcps.com/about/methodology)

## Install

### Claude Desktop — `claude_desktop_config.json`

Paste under mcpServers. Fully quit and reopen Claude after editing.

```json
{
  "mcpServers": {
    "mysql": {
      "command": "npx",
      "args": [
        "-y",
        "@benborla29/mcp-server-mysql"
      ],
      "env": {
        "MYSQL_HOST": "${MYSQL_HOST}",
        "MYSQL_PORT": "${MYSQL_PORT}",
        "MYSQL_USER": "${MYSQL_USER}",
        "MYSQL_PASS": "${MYSQL_PASS}",
        "MYSQL_DB": "${MYSQL_DB}"
      }
    }
  }
}
```

### Claude Code — `CLI or .mcp.json`

Run from your repo. Commit .mcp.json to share with your team.

```shell
# export MYSQL_HOST=localhost
# export MYSQL_PORT=3306
# export MYSQL_USER=reader
# export MYSQL_PASS=changeme
# export MYSQL_DB=app
claude mcp add mysql -- npx -y @benborla29/mcp-server-mysql
```

### Cursor — `.cursor/mcp.json`

Global path: ~/.cursor/mcp.json. Reload window after editing.

```json
{
  "mcpServers": {
    "mysql": {
      "command": "npx",
      "args": [
        "-y",
        "@benborla29/mcp-server-mysql"
      ],
      "env": {
        "MYSQL_HOST": "${MYSQL_HOST}",
        "MYSQL_PORT": "${MYSQL_PORT}",
        "MYSQL_USER": "${MYSQL_USER}",
        "MYSQL_PASS": "${MYSQL_PASS}",
        "MYSQL_DB": "${MYSQL_DB}"
      }
    }
  }
}
```

### VS Code — `.vscode/mcp.json`

VS Code uses the "servers" key (not "mcpServers").

```jsonc
{
  "servers": {
    "mysql": {
      "command": "npx",
      "args": [
        "-y",
        "@benborla29/mcp-server-mysql"
      ],
      "env": {
        "MYSQL_HOST": "${MYSQL_HOST}",
        "MYSQL_PORT": "${MYSQL_PORT}",
        "MYSQL_USER": "${MYSQL_USER}",
        "MYSQL_PASS": "${MYSQL_PASS}",
        "MYSQL_DB": "${MYSQL_DB}"
      }
    }
  }
}
```

### Windsurf — `~/.codeium/windsurf/mcp_config.json`

Open via Cascade → hammer icon → Configure.

```json
{
  "mcpServers": {
    "mysql": {
      "command": "npx",
      "args": [
        "-y",
        "@benborla29/mcp-server-mysql"
      ],
      "env": {
        "MYSQL_HOST": "${MYSQL_HOST}",
        "MYSQL_PORT": "${MYSQL_PORT}",
        "MYSQL_USER": "${MYSQL_USER}",
        "MYSQL_PASS": "${MYSQL_PASS}",
        "MYSQL_DB": "${MYSQL_DB}"
      }
    }
  }
}
```

### Cline — `cline_mcp_settings.json`

Open via the Cline sidebar → MCP Servers → Edit.

```json
{
  "mcpServers": {
    "mysql": {
      "command": "npx",
      "args": [
        "-y",
        "@benborla29/mcp-server-mysql"
      ],
      "env": {
        "MYSQL_HOST": "${MYSQL_HOST}",
        "MYSQL_PORT": "${MYSQL_PORT}",
        "MYSQL_USER": "${MYSQL_USER}",
        "MYSQL_PASS": "${MYSQL_PASS}",
        "MYSQL_DB": "${MYSQL_DB}"
      }
    }
  }
}
```

### Continue — `~/.continue/config.json`

Continue uses modelContextProtocolServers with a transport block.

```json
{
  "experimental": {
    "modelContextProtocolServers": [
      {
        "transport": {
          "type": "stdio",
          "command": "npx",
          "args": [
            "-y",
            "@benborla29/mcp-server-mysql"
          ],
          "env": {
            "MYSQL_HOST": "${MYSQL_HOST}",
            "MYSQL_PORT": "${MYSQL_PORT}",
            "MYSQL_USER": "${MYSQL_USER}",
            "MYSQL_PASS": "${MYSQL_PASS}",
            "MYSQL_DB": "${MYSQL_DB}"
          }
        }
      }
    ]
  }
}
```

### Codex CLI — `~/.codex/config.toml`

Codex uses TOML. Each server is a [mcp_servers.<name>] subtable.

```shell
# ~/.codex/config.toml
[mcp_servers.mysql]
command = "npx"
args = [
  "-y",
  "@benborla29/mcp-server-mysql",
]
env = { MYSQL_HOST = "${MYSQL_HOST}", MYSQL_PORT = "${MYSQL_PORT}", MYSQL_USER = "${MYSQL_USER}", MYSQL_PASS = "${MYSQL_PASS}", MYSQL_DB = "${MYSQL_DB}" }
```

### Zed — `~/.config/zed/settings.json`

Zed calls them "context_servers". Settings live-reload on save.

```jsonc
{
  "context_servers": {
    "mysql": {
      "command": {
        "path": "npx",
        "args": [
          "-y",
          "@benborla29/mcp-server-mysql"
        ]
      },
      "env": {
        "MYSQL_HOST": "${MYSQL_HOST}",
        "MYSQL_PORT": "${MYSQL_PORT}",
        "MYSQL_USER": "${MYSQL_USER}",
        "MYSQL_PASS": "${MYSQL_PASS}",
        "MYSQL_DB": "${MYSQL_DB}"
      }
    }
  }
}
```

### ChatGPT — `ChatGPT → Apps directory`

MySQL doesn't ship a hosted HTTPS endpoint today. ChatGPT supports remote MCP servers only — to use this server in ChatGPT you'll need to deploy it to a public HTTPS URL first (e.g. via Cloudflare Workers or Vercel) or wait for an official remote build.

```none

```

## At a glance

- **Maintainer:** Community
- **Transport:** stdio
- **Auth model:** API key
- **Required secrets:** MYSQL_HOST, MYSQL_PORT, MYSQL_USER, MYSQL_PASS, MYSQL_DB
- **Supported clients:** Claude, Cursor, VS Code, Windsurf, Any MCP-compatible client, MySQL 5.7+, MariaDB 10+
- **License:** MIT
- **Language:** TypeScript
- **Latest version:** latest
- **Last verified:** 2026-05-27
- **GitHub stars:** 1,724 (fetched 2026-06-02T11:55:52.271Z)
- **Score:** 79/100 (rubric 2026-04 — see https://top-mcps.com/about/methodology)
- **Source:** https://github.com/benborla/mcp-server-mysql

## Tools & permissions

| Tool | Description | Args | Side effects |
|------|-------------|------|--------------|
| `list_tables` | List tables in a database. | `—` | read |
| `describe_table` | Return columns, types, indexes, and constraints for a table. | `table: string` | read |
| `query` | Run a SELECT and return rows. SELECT-only. | `sql: string` | read |

## Security & scope

- **Access scope:** read-only
- **Sandbox:** Connects to a MySQL/MariaDB server using credentials in env vars. No write tools exposed. Combine with a read-only database user and a tight statement timeout.
- **Gotchas:**
  - Read-only is tool-level, not role-level — always pair with a read-only DB user.
  - Connection strings end up in client config; store credentials in the OS keychain where the client supports it.
  - Without a statement timeout, an LLM can wedge the server with a bad join.

## Quick answer

**What it does.** Connects to a MySQL/MariaDB server and exposes schema inspection, table listing, and SELECT execution to AI models. Read-only by default.

**Best for:**
- Schema exploration
- SELECT query drafting
- Index review
- Ad-hoc reporting
- Migrating queries from one engine to another

**Not for:**
- Write or mutation operations
- Heavy analytical workloads
- Stored-procedure development

## Description

A community-maintained MCP that connects an AI agent to a MySQL or MariaDB database. Exposes schema inspection, table listing, and SELECT execution behind a read-only safety flag. Designed to be the safe default for any agent-driven MySQL conversation — when you want to draft queries, debug schemas, or pull rows for analysis without giving the model write power.

## Why it matters

MySQL is the workhorse of legacy and mid-market stacks. A read-only MCP lets agents help with the long tail of MySQL workflows without the production-write risk.

## Key features

- MySQL + MariaDB support
- Connection-string auth with SSL
- Read-only mode default
- Schema and index introspection
- Statement timeout to prevent runaway queries

## FAQ

### Does it support writes?

No write tools are exposed by default. The author keeps the surface read-only on purpose; pair with a dedicated read-only MySQL user as defence in depth.

### SSL / TLS support?

Yes. Pass MYSQL_SSL=true and the standard CA settings to connect to managed providers (PlanetScale, Aurora, Cloud SQL) that require TLS.

### Statement timeout?

Configurable via MYSQL_TIMEOUT (seconds). Keep it tight — the LLM can issue runaway SELECTs against multi-billion-row tables otherwise.

### Why not the official MySQL MCP?

There is no first-party server today. This community implementation is the best-maintained option; expect this to change if Oracle ships an official one.

## Changelog

- **2026-05-27** — Refreshed install snippets and fact sheet; verified for 2026.
- **2025-02-15** — Initial directory listing.
