# Mysql

> Mysql is an open-source MCP server for databases. Read-only MySQL access for AI clients: schema inspection, query plans and performance. It runs locally on your machine and is started by your AI client.

- **Kind:** MCP server
- **Pricing:** Open source
- **Platforms:** API, CLI, vscode, self-hosted
- **Repository:** https://github.com/marcelo-ochoa/servers/tree/HEAD/src/mysql
- **MCP Registry name:** io.github.marcelo-ochoa/mysql
- **Categories:** [databases](https://ai-powered.com/categories/databases)
- **Listing updated:** 2026-11-18

## About

The README describes this server as a way for LLM clients to look at MySQL databases without changing them. Queries run inside a READ ONLY transaction, so the assistant can inspect schemas, explain execution plans and pull table statistics but is not meant to write data.

The server exposes four tools and a schema resource for each table. Connection details can come from MYSQL_USER and MYSQL_PASSWORD environment variables or from a mysql-connect tool called at runtime, and a connection string can be passed at startup. A separate mysql-awr tool produces an Oracle AWR-style performance report, which draws on performance_schema when it is enabled.

The README covers setup for Claude Desktop, VS Code and Antigravity, using either npx or a Docker image. It is aimed at developers and database administrators who want an assistant to help with query tuning and schema review.

## Features

- **Read-only query execution:** Runs SQL inside a READ ONLY transaction so queries cannot modify data.
- **Query plan explanation:** Returns the execution plan for a SQL statement in JSON form.
- **Table statistics:** Reports table, index and column statistics for a named table.
- **Performance report:** Generates an AWR-style report with InnoDB metrics and top queries, using performance_schema when available.
- **Schema resources:** Exposes column names and data types for each table as JSON resources.
- **Runtime reconnection:** Lets the client reconnect with new credentials through a mysql-connect tool.

## Good for

- Asking an assistant to review a slow query and its execution plan
- Inspecting table structure and column types before writing SQL
- Gathering index and table statistics for a database under investigation
- Generating a performance report and asking for tuning suggestions

## Install

### Claude Code (Terminal)

```sh
claude mcp add mysql --env MYSQL_PASSWORD='<MYSQL_PASSWORD>' -- npx -y @marcelo-ochoa/server-mysql
```

### Claude Desktop (claude_desktop_config.json)

```json
{
  "mcpServers": {
    "mysql": {
      "command": "npx",
      "args": [
        "-y",
        "@marcelo-ochoa/server-mysql"
      ],
      "env": {
        "MYSQL_PASSWORD": "<MYSQL_PASSWORD>"
      }
    }
  }
}
```

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

```json
{
  "mcpServers": {
    "mysql": {
      "command": "npx",
      "args": [
        "-y",
        "@marcelo-ochoa/server-mysql"
      ],
      "env": {
        "MYSQL_PASSWORD": "<MYSQL_PASSWORD>"
      }
    }
  }
}
```

### VS Code (.vscode/mcp.json)

```json
{
  "servers": {
    "mysql": {
      "type": "stdio",
      "command": "npx",
      "args": [
        "-y",
        "@marcelo-ochoa/server-mysql"
      ],
      "env": {
        "MYSQL_PASSWORD": "<MYSQL_PASSWORD>"
      }
    }
  }
}
```

### Windsurf (~/.codeium/windsurf/mcp_config.json)

```json
{
  "mcpServers": {
    "mysql": {
      "command": "npx",
      "args": [
        "-y",
        "@marcelo-ochoa/server-mysql"
      ],
      "env": {
        "MYSQL_PASSWORD": "<MYSQL_PASSWORD>"
      }
    }
  }
}
```

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

```json
{
  "mcpServers": {
    "mysql": {
      "command": "npx",
      "args": [
        "-y",
        "@marcelo-ochoa/server-mysql"
      ],
      "env": {
        "MYSQL_PASSWORD": "<MYSQL_PASSWORD>"
      }
    }
  }
}
```

## Tools

- `mysql-query`: Execute read-only SQL queries against the connected MySQL database
- `mysql-explain`: Explain plan SQL queries against the connected MySQL database
- `mysql-stats`: Get statistics for a given table in the current connected database
- `mysql-connect`: Reconnect using new credentials
- `mysql-awr`: Generate a MySQL performance report similar to Oracle AWR

## FAQ

### Can this server modify data in MySQL?

The README says the query tool runs all queries within a READ ONLY transaction and describes the server as providing read-only access.

### How are database credentials supplied?

Through the MYSQL_USER and MYSQL_PASSWORD environment variables, or by calling the mysql-connect tool with a connection string, username and password.

### Does the performance report require anything in MySQL?

The README says top query statistics need performance_schema to be enabled; without it the report still generates with fewer query-level details.

### Is Mysql free?

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

### How do I add Mysql to Claude Code?

Run this command in your terminal: claude mcp add mysql --env MYSQL_PASSWORD='<MYSQL_PASSWORD>' -- npx -y @marcelo-ochoa/server-mysql

### What are the best alternatives to Mysql?

The closest alternatives to Mysql are AI2SQL, MCP Local WP, SaturnSQL, AdoMcp and PostgreSQL MCP Server.

## Where this comes from

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

## Alternatives

- [AI2SQL](https://ai-powered.com/mcp/ai2sql): AI2SQL is a freemium MCP server for databases.
- [MCP Local WP](https://ai-powered.com/mcp/mcp-local-wp): MCP Local WP is an open-source MCP server for databases.
- [SaturnSQL](https://ai-powered.com/mcp/saturnsql): SaturnSQL is an MCP server for databases.
- [AdoMcp](https://ai-powered.com/mcp/adomcp): AdoMcp is an open-source MCP server for databases.
- [PostgreSQL MCP Server](https://ai-powered.com/mcp/postgresql-mcp-server-5): PostgreSQL MCP Server is an open-source MCP server for databases.
- [dryrun](https://ai-powered.com/mcp/dryrun): dryrun is an open-source MCP server for databases.
- [Universal DB (read-only)](https://ai-powered.com/mcp/universal-db-read-only): Universal DB (read-only) is an open-source MCP server for databases.
- [Knack MCP by usefulapi](https://ai-powered.com/mcp/knack-mcp-by-usefulapi): Knack MCP by usefulapi is a freemium MCP server for databases.

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