MySQL MCP Server
Read-only MySQL access for AI assistants across multiple saved connection profiles
MySQL MCP Server is an open-source MCP server for databases. It runs locally on your machine and is started by your AI client.
- Pricing
- Open source
- Platforms
- CLI, Self-hosted
- Runs
- Locally
- What it can do
- Can change data (1 tool)
- Version
- 0.1.0
Similar MCP servers
Install
Add with the CLI
Run in a terminal
claude mcp add mcp-mysql --env MCP_DB_PROFILES_FILE='<MCP_DB_PROFILES_FILE>' -- uvx jj-mcp-mysqlAdd --scope user to use it in every project, or --scope project to share it in .mcp.json.
Or share it with your project
Add to .mcp.json
{
"mcpServers": {
"mcp-mysql": {
"command": "uvx",
"args": [
"jj-mcp-mysql"
],
"env": {
"MCP_DB_PROFILES_FILE": "<MCP_DB_PROFILES_FILE>"
}
}
}
}Add to claude_desktop_config.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.
Add to ~/.cursor/mcp.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.
Add to ~/.copilot/mcp-config.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.
Add with the CLI
Run in a terminal
codex mcp add mcp-mysql --env MCP_DB_PROFILES_FILE='<MCP_DB_PROFILES_FILE>' -- uvx jj-mcp-mysqlOr add to config.toml
Add to ~/.codex/config.toml
[mcp_servers.mcp-mysql]
command = "uvx"
args = ["jj-mcp-mysql"]
env = { MCP_DB_PROFILES_FILE = "<MCP_DB_PROFILES_FILE>" }Add to your client's MCP settings (most use this shape)
{
"mcpServers": {
"mcp-mysql": {
"command": "uvx",
"args": [
"jj-mcp-mysql"
],
"env": {
"MCP_DB_PROFILES_FILE": "<MCP_DB_PROFILES_FILE>"
}
}
}
}Gemini CLI and Antigravity
Gemini CLI
Add to ~/.gemini/settings.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
Antigravity
Add to ~/.gemini/config/mcp_config.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 (formerly Windsurf)
Add to ~/.config/devin/mcp_config.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
Add to cline_mcp_settings.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
Add to Zed settings.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
Add to Settings → Tools → AI Assistant → Model Context Protocol (MCP) → Add
{ "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.
Junie
Add to ~/.junie/mcp/mcp.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
Add to ~/.kiro/settings/mcp.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.
Using several servers? Build one config file with the MCP config generator.
Configuration
MCP_DB_PROFILES_FILEAbsolute path to the db_profiles.json connection profile file.Required
About MySQL MCP Server
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.
Tools this server provides (2)
Taken from the project documentation; the running server may differ.
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_connectionsName suggests: reads
- List connections, their usage notes and available databases
- execute_sqlName suggests: changes
- Run SQL on a chosen connection and database; omit connection or database to use the defaults
What it does
- 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
Pricing
Open source
Free and open source; self-hosted on your machine.
More servers for the same service
MySQL MCP Server 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.
