# MySQL MCP

> MySQL MCP is an open-source MCP server for databases. Bind an AI client to one MySQL or MariaDB database, read-only unless you allow writes. It runs locally on your machine and is started by your AI client.

- **Kind:** MCP server
- **Pricing:** Open source
- **Platforms:** CLI, Self-hosted
- **Repository:** https://github.com/gistrec/mcp-mysql-client
- **MCP Registry name:** io.github.gistrec/mcp-mysql-client
- **Categories:** [databases](https://ai-powered.com/categories/databases)
- **Listing updated:** 2026-11-23

## About

The server is tied to a single database named in its configuration, and no tool can switch to another. Reads run inside a read-only transaction and are parsed before the connection is used, so a DELETE sent through the query tool is rejected even when writes are enabled.

Writing is opt-in per operation: ALLOW_INSERT_OPERATION, ALLOW_UPDATE_OPERATION and ALLOW_DELETE_OPERATION are environment variables that require a restart, so a chat cannot turn them on. DDL such as CREATE, ALTER, DROP and TRUNCATE is never allowed, and UPDATE or DELETE without WHERE needs an explicit allow_full_table flag. Only one statement runs per call.

Results stream and stop at MYSQL_MAX_ROWS (1000 by default) with a truncated marker, and statements time out after 30 seconds by default. The README (written in Russian) also covers migrating from @benborla29/mcp-server-mysql, TLS options and a troubleshooting table keyed by MySQL error number.

## Features

- **Single-database binding:** MYSQL_DB is required and no tool can leave it.
- **Read-only transactions:** Reads run in START TRANSACTION READ ONLY.
- **Per-operation write flags:** INSERT, UPDATE and DELETE are enabled separately by environment variable.
- **Row cap with truncation flag:** Output is limited to 1000 rows by default and marked when cut.
- **Query plans:** explain shows the plan, indexes and row estimates.
- **Connection diagnostics:** server_info shows user, grants and active limits.

## Good for

- Ask natural-language questions about a database's contents
- Review a table's columns, indexes and foreign keys
- Find out why a query is slow
- Make a narrowly permitted status update with writes switched on
- Move from another MySQL MCP package

## Install

### Claude Code: Add with the CLI (Terminal)

```sh
claude mcp add mcp-mysql-client --env MYSQL_USER='<MYSQL_USER>' --env MYSQL_PASS='<MYSQL_PASS>' --env MYSQL_DB='<MYSQL_DB>' -- npx -y mcp-mysql-client
```

Add --scope user to use it in every project, or --scope project to share it in .mcp.json.

### Claude Code: Or share it with your project (.mcp.json)

```json
{
  "mcpServers": {
    "mcp-mysql-client": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-mysql-client"
      ],
      "env": {
        "MYSQL_USER": "<MYSQL_USER>",
        "MYSQL_PASS": "<MYSQL_PASS>",
        "MYSQL_DB": "<MYSQL_DB>"
      }
    }
  }
}
```

### Claude Desktop (claude_desktop_config.json)

```json
{
  "mcpServers": {
    "mcp-mysql-client": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-mysql-client"
      ],
      "env": {
        "MYSQL_USER": "<MYSQL_USER>",
        "MYSQL_PASS": "<MYSQL_PASS>",
        "MYSQL_DB": "<MYSQL_DB>"
      }
    }
  }
}
```

Settings → Developer → Edit Config, then quit and reopen Claude Desktop.

### Cursor (~/.cursor/mcp.json)

```json
{
  "mcpServers": {
    "mcp-mysql-client": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-mysql-client"
      ],
      "env": {
        "MYSQL_USER": "<MYSQL_USER>",
        "MYSQL_PASS": "<MYSQL_PASS>",
        "MYSQL_DB": "<MYSQL_DB>"
      }
    }
  }
}
```

Use .cursor/mcp.json in a project to share it with the project.

### VS Code (~/.copilot/mcp-config.json)

```json
{
  "mcpServers": {
    "mcp-mysql-client": {
      "type": "stdio",
      "command": "npx",
      "args": [
        "-y",
        "mcp-mysql-client"
      ],
      "env": {
        "MYSQL_USER": "<MYSQL_USER>",
        "MYSQL_PASS": "<MYSQL_PASS>",
        "MYSQL_DB": "<MYSQL_DB>"
      }
    }
  }
}
```

Or put the same entry in .mcp.json at your workspace root to share it.

### Codex: Add with the CLI (Terminal)

```sh
codex mcp add mcp-mysql-client --env MYSQL_USER='<MYSQL_USER>' --env MYSQL_PASS='<MYSQL_PASS>' --env MYSQL_DB='<MYSQL_DB>' -- npx -y mcp-mysql-client
```

### Codex: Or add to config.toml (~/.codex/config.toml)

```toml
[mcp_servers.mcp-mysql-client]
command = "npx"
args = ["-y", "mcp-mysql-client"]
env = { MYSQL_USER = "<MYSQL_USER>", MYSQL_PASS = "<MYSQL_PASS>", MYSQL_DB = "<MYSQL_DB>" }
```

### Gemini CLI and Antigravity: Gemini CLI (~/.gemini/settings.json)

```json
{
  "mcpServers": {
    "mcp-mysql-client": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-mysql-client"
      ],
      "env": {
        "MYSQL_USER": "<MYSQL_USER>",
        "MYSQL_PASS": "<MYSQL_PASS>",
        "MYSQL_DB": "<MYSQL_DB>"
      }
    }
  }
}
```

Or run: gemini mcp add -s user -e MYSQL_USER='<MYSQL_USER>' -e MYSQL_PASS='<MYSQL_PASS>' -e MYSQL_DB='<MYSQL_DB>' mcp-mysql-client npx -- -y mcp-mysql-client

### Gemini CLI and Antigravity: Antigravity (~/.gemini/config/mcp_config.json)

```json
{
  "mcpServers": {
    "mcp-mysql-client": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-mysql-client"
      ],
      "env": {
        "MYSQL_USER": "<MYSQL_USER>",
        "MYSQL_PASS": "<MYSQL_PASS>",
        "MYSQL_DB": "<MYSQL_DB>"
      }
    }
  }
}
```

Use .agents/mcp_config.json to add it to one workspace only.

### Devin Desktop (~/.config/devin/mcp_config.json)

```json
{
  "mcpServers": {
    "mcp-mysql-client": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-mysql-client"
      ],
      "env": {
        "MYSQL_USER": "<MYSQL_USER>",
        "MYSQL_PASS": "<MYSQL_PASS>",
        "MYSQL_DB": "<MYSQL_DB>"
      }
    }
  }
}
```

On Windows the file is %APPDATA%\\devin\\mcp_config.json. Use .devin/mcp_config.json to share it with a project.

### Cline (cline_mcp_settings.json)

```json
{
  "mcpServers": {
    "mcp-mysql-client": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-mysql-client"
      ],
      "env": {
        "MYSQL_USER": "<MYSQL_USER>",
        "MYSQL_PASS": "<MYSQL_PASS>",
        "MYSQL_DB": "<MYSQL_DB>"
      }
    }
  }
}
```

Open it from the MCP Servers icon → Configure → Configure MCP Servers.

### Zed (Zed settings.json)

```json
{
  "context_servers": {
    "mcp-mysql-client": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-mysql-client"
      ],
      "env": {
        "MYSQL_USER": "<MYSQL_USER>",
        "MYSQL_PASS": "<MYSQL_PASS>",
        "MYSQL_DB": "<MYSQL_DB>"
      }
    }
  }
}
```

Open it with zed: open settings file. Merge context_servers into the settings you already have.

### JetBrains AI Assistant and Junie: AI Assistant (Settings → Tools → AI Assistant → Model Context Protocol (MCP) → Add)

```json
{
  "mcpServers": {
    "mcp-mysql-client": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-mysql-client"
      ],
      "env": {
        "MYSQL_USER": "<MYSQL_USER>",
        "MYSQL_PASS": "<MYSQL_PASS>",
        "MYSQL_DB": "<MYSQL_DB>"
      }
    }
  }
}
```

The AI Assistant docs only show command and args. If the env block is ignored, use Junie for this server.

### JetBrains AI Assistant and Junie: Junie (~/.junie/mcp/mcp.json)

```json
{
  "mcpServers": {
    "mcp-mysql-client": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-mysql-client"
      ],
      "env": {
        "MYSQL_USER": "<MYSQL_USER>",
        "MYSQL_PASS": "<MYSQL_PASS>",
        "MYSQL_DB": "<MYSQL_DB>"
      }
    }
  }
}
```

Use .junie/mcp/mcp.json to share it with a project.

### Kiro (~/.kiro/settings/mcp.json)

```json
{
  "mcpServers": {
    "mcp-mysql-client": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-mysql-client"
      ],
      "env": {
        "MYSQL_USER": "<MYSQL_USER>",
        "MYSQL_PASS": "<MYSQL_PASS>",
        "MYSQL_DB": "<MYSQL_DB>"
      }
    }
  }
}
```

Use .kiro/settings/mcp.json to add it to one workspace only.

### Other clients (your client's MCP settings (most use this shape))

```json
{
  "mcpServers": {
    "mcp-mysql-client": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-mysql-client"
      ],
      "env": {
        "MYSQL_USER": "<MYSQL_USER>",
        "MYSQL_PASS": "<MYSQL_PASS>",
        "MYSQL_DB": "<MYSQL_DB>"
      }
    }
  }
}
```

## Tools

From the tool list in its README, going by the names, 1 of 6 tools changes data; 1 name doesn't say. From the server's own tool labels and tool names; not verified by us.

- `query` (name suggests: reads): Runs a read-only SELECT query.
- `execute` (name suggests: changes): Runs INSERT, UPDATE or DELETE when the matching flag is enabled.
- `explain` (name suggests: reads): Returns the query plan, indexes and row estimates.
- `list_tables` (name suggests: reads): Lists tables with sizes and row estimates.
- `describe_table` (name suggests: reads): Shows columns, indexes and foreign keys in both directions.
- `server_info`: Shows database, user, grants and server limits.

## FAQ

### Can MySQL MCP change the schema?

No. DDL is blocked regardless of settings.

### Is MySQL MCP read-only by default?

Yes. Writes need the ALLOW_* variables and a restart.

### Does MySQL MCP support MariaDB?

The README says it connects to MySQL or MariaDB.

### How do I hide the password?

Use MYSQL_PASS_FILE to read it from a file.

### Is anything reported back?

Anonymous usage statistics can be disabled by setting ASKADS_TELEMETRY to 0.

### Is MySQL MCP free?

Yes. MySQL MCP is open source, so you can use and self-host it for free.

### How do I add MySQL MCP to Claude Code?

Run this command in your terminal: claude mcp add mcp-mysql-client --env MYSQL_USER='<MYSQL_USER>' --env MYSQL_PASS='<MYSQL_PASS>' --env MYSQL_DB='<MYSQL_DB>' -- npx -y mcp-mysql-client

### What are the best alternatives to MySQL MCP?

The closest alternatives to MySQL MCP are MCP Toolbox for Databases, ClickHouse, postgres-mcp, Supabase and mcp-server-mysql.

## Where this comes from

- Description: written from the project's README.
- Install steps: from the official MCP Registry entry.

## Alternatives

- [MCP Toolbox for Databases](https://ai-powered.com/mcp/mcp-toolbox-for-databases-2): MCP Toolbox for Databases is an open-source MCP server for databases.
- [ClickHouse](https://ai-powered.com/mcp/clickhouse): ClickHouse is an open-source MCP server for databases.
- [postgres-mcp](https://ai-powered.com/mcp/postgres-mcp-4): postgres-mcp is an open-source MCP server for databases.
- [Supabase](https://ai-powered.com/mcp/supabase): Supabase is an MCP server for databases.
- [mcp-server-mysql](https://ai-powered.com/mcp/mcp-server-mysql): mcp-server-mysql is an open-source MCP server for databases.
- [anyquery](https://ai-powered.com/mcp/anyquery): anyquery is an open-source MCP server for databases.
- [Pg Aiguide](https://ai-powered.com/mcp/pg-aiguide): Pg Aiguide is an open-source MCP server for databases.
- [mcp-server-qdrant](https://ai-powered.com/mcp/mcp-server-qdrant): mcp-server-qdrant is an open-source MCP server for databases.

---
Source: https://ai-powered.com/mcp/mysql-mcp
