# MySQL MCP Server

> MySQL MCP Server is an open-source MCP server for databases. Read-only MySQL access for AI assistants across multiple saved connection profiles. 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/ranjian/mcp-mysql
- **MCP Registry name:** io.github.ranjian/mcp-mysql
- **Categories:** [databases](https://ai-powered.com/categories/databases)
- **Listing updated:** 2026-11-30

## About

Connects an AI client to one or more MySQL databases through a single profile file that holds each connection's host, credentials and usage notes. Instead of handing a model a general database login, you define named connections such as production, test or reporting, and the assistant picks the right one based on the notes attached to each.

The server exposes just two tools: one lists the configured connections and the databases they reach, and the other runs SQL against a chosen connection and database, falling back to defaults when none is given. Usage notes are passed to the model before it writes any query, which helps it stay within the rules you set for each database.

It suits developers and analysts who query MySQL from Cursor, Claude Desktop or similar clients and want exploratory reads without exposing write access. Safety depends on the database account: the server itself does not block writes, so a read-only MySQL user is the expected setup.

## Features

- **Multiple connection profiles:** Store several MySQL connections with separate credentials and descriptions in one file.
- **Two-tool interface:** Lists connections and runs SQL, keeping the surface small for the model to use.
- **Per-connection usage notes:** Attach rules to each database so the model knows what it may query and how.
- **Default connection and database:** Set defaults so queries run without naming a target every time.
- **Stdio transport:** Runs as a local process launched by MCP clients through a standard command.

## Good for

- Letting an AI assistant explore a test database schema and sample rows
- Running reporting queries against a read replica from a coding assistant
- Switching between production and staging data sources within one chat session
- Drafting and checking SELECT statements before running them on a live database

## Install

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

```sh
claude mcp add mcp-mysql --env MCP_DB_PROFILES_FILE='<MCP_DB_PROFILES_FILE>' -- uvx jj-mcp-mysql
```

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": {
      "command": "uvx",
      "args": [
        "jj-mcp-mysql"
      ],
      "env": {
        "MCP_DB_PROFILES_FILE": "<MCP_DB_PROFILES_FILE>"
      }
    }
  }
}
```

### Claude Desktop (claude_desktop_config.json)

```json
{
  "mcpServers": {
    "mcp-mysql": {
      "command": "uvx",
      "args": [
        "jj-mcp-mysql"
      ],
      "env": {
        "MCP_DB_PROFILES_FILE": "<MCP_DB_PROFILES_FILE>"
      }
    }
  }
}
```

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

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

```json
{
  "mcpServers": {
    "mcp-mysql": {
      "command": "uvx",
      "args": [
        "jj-mcp-mysql"
      ],
      "env": {
        "MCP_DB_PROFILES_FILE": "<MCP_DB_PROFILES_FILE>"
      }
    }
  }
}
```

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

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

```json
{
  "mcpServers": {
    "mcp-mysql": {
      "type": "stdio",
      "command": "uvx",
      "args": [
        "jj-mcp-mysql"
      ],
      "env": {
        "MCP_DB_PROFILES_FILE": "<MCP_DB_PROFILES_FILE>"
      }
    }
  }
}
```

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 --env MCP_DB_PROFILES_FILE='<MCP_DB_PROFILES_FILE>' -- uvx jj-mcp-mysql
```

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

```toml
[mcp_servers.mcp-mysql]
command = "uvx"
args = ["jj-mcp-mysql"]
env = { MCP_DB_PROFILES_FILE = "<MCP_DB_PROFILES_FILE>" }
```

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

```json
{
  "mcpServers": {
    "mcp-mysql": {
      "command": "uvx",
      "args": [
        "jj-mcp-mysql"
      ],
      "env": {
        "MCP_DB_PROFILES_FILE": "<MCP_DB_PROFILES_FILE>"
      }
    }
  }
}
```

Or run: gemini mcp add -s user -e MCP_DB_PROFILES_FILE='<MCP_DB_PROFILES_FILE>' mcp-mysql uvx -- jj-mcp-mysql

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

```json
{
  "mcpServers": {
    "mcp-mysql": {
      "command": "uvx",
      "args": [
        "jj-mcp-mysql"
      ],
      "env": {
        "MCP_DB_PROFILES_FILE": "<MCP_DB_PROFILES_FILE>"
      }
    }
  }
}
```

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

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

```json
{
  "mcpServers": {
    "mcp-mysql": {
      "command": "uvx",
      "args": [
        "jj-mcp-mysql"
      ],
      "env": {
        "MCP_DB_PROFILES_FILE": "<MCP_DB_PROFILES_FILE>"
      }
    }
  }
}
```

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": {
      "command": "uvx",
      "args": [
        "jj-mcp-mysql"
      ],
      "env": {
        "MCP_DB_PROFILES_FILE": "<MCP_DB_PROFILES_FILE>"
      }
    }
  }
}
```

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

### Zed (Zed settings.json)

```json
{
  "context_servers": {
    "mcp-mysql": {
      "command": "uvx",
      "args": [
        "jj-mcp-mysql"
      ],
      "env": {
        "MCP_DB_PROFILES_FILE": "<MCP_DB_PROFILES_FILE>"
      }
    }
  }
}
```

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": {
      "command": "uvx",
      "args": [
        "jj-mcp-mysql"
      ],
      "env": {
        "MCP_DB_PROFILES_FILE": "<MCP_DB_PROFILES_FILE>"
      }
    }
  }
}
```

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": {
      "command": "uvx",
      "args": [
        "jj-mcp-mysql"
      ],
      "env": {
        "MCP_DB_PROFILES_FILE": "<MCP_DB_PROFILES_FILE>"
      }
    }
  }
}
```

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

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

```json
{
  "mcpServers": {
    "mcp-mysql": {
      "command": "uvx",
      "args": [
        "jj-mcp-mysql"
      ],
      "env": {
        "MCP_DB_PROFILES_FILE": "<MCP_DB_PROFILES_FILE>"
      }
    }
  }
}
```

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": {
      "command": "uvx",
      "args": [
        "jj-mcp-mysql"
      ],
      "env": {
        "MCP_DB_PROFILES_FILE": "<MCP_DB_PROFILES_FILE>"
      }
    }
  }
}
```

## Tools

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

- `list_connections` (name suggests: reads): List connections, their usage notes and available databases
- `execute_sql` (name suggests: changes): Run SQL on a chosen connection and database; omit connection or database to use the defaults

## FAQ

### Can the server write to the database?

The server does not block writes on its own, so the documentation recommends connecting with a read-only MySQL account.

### Where are credentials stored?

In a db_profiles.json file whose path is set through the MCP_DB_PROFILES_FILE environment variable. The file is git-ignored in the project.

### Which tools does MySQL MCP Server provide?

It provides list_connections, which shows connections and their databases, and execute_sql, which runs SQL on a chosen connection.

### How is MySQL MCP Server installed?

The Python package jj-mcp-mysql is installed with pipx or pip, and the installed command is mcp-mysql.

### Is MySQL MCP Server free?

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

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

Run this command in your terminal: claude mcp add mcp-mysql --env MCP_DB_PROFILES_FILE='<MCP_DB_PROFILES_FILE>' -- uvx jj-mcp-mysql

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

The closest alternatives to MySQL MCP Server are MySQL (read-only, switchable), DataLink, MySQL MCP, Custom MCP Database and Db Access MCP.

## 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

- [MySQL (read-only, switchable)](https://ai-powered.com/mcp/mysql-read-only-switchable): MySQL (read-only, switchable) is an open-source MCP server for databases.
- [DataLink](https://ai-powered.com/mcp/datalink): DataLink is an open-source MCP server for databases.
- [MySQL MCP](https://ai-powered.com/mcp/mysql-mcp): MySQL MCP is an open-source MCP server for databases.
- [Custom MCP Database](https://ai-powered.com/mcp/custom-mcp-database): Custom MCP Database is an open-source MCP server for databases.
- [Db Access MCP](https://ai-powered.com/mcp/db-access-mcp): Db Access MCP is an open-source MCP server for databases.
- [Read Only Local Mysql MCP Server](https://ai-powered.com/mcp/read-only-local-mysql-mcp-server): Read Only Local Mysql MCP Server is an open-source MCP server for databases.
- [Mysql MCP](https://ai-powered.com/mcp/mysql-mcp-2): Mysql MCP is an open-source MCP server for databases.
- [Database MCP](https://ai-powered.com/mcp/database-mcp): Database MCP is an open-source MCP server for databases.

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