Skip to content
MCP server

Database MCP Mysql

Safer MySQL access for AI clients, read-only by default with row and time limits

Runs locally

Database MCP Mysql 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.5.0

Similar MCP servers

Install

Add with the CLI

Run in a terminal

claude mcp add database-mcp-mysql --env MYSQL_HOST='<MYSQL_HOST>' --env MYSQL_USER='<MYSQL_USER>' --env MYSQL_PASSWORD='<MYSQL_PASSWORD>' --env MYSQL_DATABASE='<MYSQL_DATABASE>' -- npx -y @database-mcp/mysql

Add --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": {
    "database-mcp-mysql": {
      "command": "npx",
      "args": [
        "-y",
        "@database-mcp/mysql"
      ],
      "env": {
        "MYSQL_HOST": "<MYSQL_HOST>",
        "MYSQL_USER": "<MYSQL_USER>",
        "MYSQL_PASSWORD": "<MYSQL_PASSWORD>",
        "MYSQL_DATABASE": "<MYSQL_DATABASE>"
      }
    }
  }
}

Claude Code setup guide

Add to claude_desktop_config.json

{
  "mcpServers": {
    "database-mcp-mysql": {
      "command": "npx",
      "args": [
        "-y",
        "@database-mcp/mysql"
      ],
      "env": {
        "MYSQL_HOST": "<MYSQL_HOST>",
        "MYSQL_USER": "<MYSQL_USER>",
        "MYSQL_PASSWORD": "<MYSQL_PASSWORD>",
        "MYSQL_DATABASE": "<MYSQL_DATABASE>"
      }
    }
  }
}

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

Claude Desktop setup guide

Add to ~/.cursor/mcp.json

{
  "mcpServers": {
    "database-mcp-mysql": {
      "command": "npx",
      "args": [
        "-y",
        "@database-mcp/mysql"
      ],
      "env": {
        "MYSQL_HOST": "<MYSQL_HOST>",
        "MYSQL_USER": "<MYSQL_USER>",
        "MYSQL_PASSWORD": "<MYSQL_PASSWORD>",
        "MYSQL_DATABASE": "<MYSQL_DATABASE>"
      }
    }
  }
}

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

Cursor setup guide

Add to ~/.copilot/mcp-config.json

{
  "mcpServers": {
    "database-mcp-mysql": {
      "type": "stdio",
      "command": "npx",
      "args": [
        "-y",
        "@database-mcp/mysql"
      ],
      "env": {
        "MYSQL_HOST": "<MYSQL_HOST>",
        "MYSQL_USER": "<MYSQL_USER>",
        "MYSQL_PASSWORD": "<MYSQL_PASSWORD>",
        "MYSQL_DATABASE": "<MYSQL_DATABASE>"
      }
    }
  }
}

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

VS Code setup guide

Add with the CLI

Run in a terminal

codex mcp add database-mcp-mysql --env MYSQL_HOST='<MYSQL_HOST>' --env MYSQL_USER='<MYSQL_USER>' --env MYSQL_PASSWORD='<MYSQL_PASSWORD>' --env MYSQL_DATABASE='<MYSQL_DATABASE>' -- npx -y @database-mcp/mysql

Or add to config.toml

Add to ~/.codex/config.toml

[mcp_servers.database-mcp-mysql]
command = "npx"
args = ["-y", "@database-mcp/mysql"]
env = { MYSQL_HOST = "<MYSQL_HOST>", MYSQL_USER = "<MYSQL_USER>", MYSQL_PASSWORD = "<MYSQL_PASSWORD>", MYSQL_DATABASE = "<MYSQL_DATABASE>" }

Codex setup guide

Add to your client's MCP settings (most use this shape)

{
  "mcpServers": {
    "database-mcp-mysql": {
      "command": "npx",
      "args": [
        "-y",
        "@database-mcp/mysql"
      ],
      "env": {
        "MYSQL_HOST": "<MYSQL_HOST>",
        "MYSQL_USER": "<MYSQL_USER>",
        "MYSQL_PASSWORD": "<MYSQL_PASSWORD>",
        "MYSQL_DATABASE": "<MYSQL_DATABASE>"
      }
    }
  }
}
  • Gemini CLI and Antigravity

    Gemini CLI

    Add to ~/.gemini/settings.json

    {
      "mcpServers": {
        "database-mcp-mysql": {
          "command": "npx",
          "args": [
            "-y",
            "@database-mcp/mysql"
          ],
          "env": {
            "MYSQL_HOST": "<MYSQL_HOST>",
            "MYSQL_USER": "<MYSQL_USER>",
            "MYSQL_PASSWORD": "<MYSQL_PASSWORD>",
            "MYSQL_DATABASE": "<MYSQL_DATABASE>"
          }
        }
      }
    }

    Or run: gemini mcp add -s user -e MYSQL_HOST='<MYSQL_HOST>' -e MYSQL_USER='<MYSQL_USER>' -e MYSQL_PASSWORD='<MYSQL_PASSWORD>' -e MYSQL_DATABASE='<MYSQL_DATABASE>' database-mcp-mysql npx -- -y @database-mcp/mysql

    Antigravity

    Add to ~/.gemini/config/mcp_config.json

    {
      "mcpServers": {
        "database-mcp-mysql": {
          "command": "npx",
          "args": [
            "-y",
            "@database-mcp/mysql"
          ],
          "env": {
            "MYSQL_HOST": "<MYSQL_HOST>",
            "MYSQL_USER": "<MYSQL_USER>",
            "MYSQL_PASSWORD": "<MYSQL_PASSWORD>",
            "MYSQL_DATABASE": "<MYSQL_DATABASE>"
          }
        }
      }
    }

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

    Gemini CLI and Antigravity setup guide

  • Devin Desktop (formerly Windsurf)

    Add to ~/.config/devin/mcp_config.json

    {
      "mcpServers": {
        "database-mcp-mysql": {
          "command": "npx",
          "args": [
            "-y",
            "@database-mcp/mysql"
          ],
          "env": {
            "MYSQL_HOST": "<MYSQL_HOST>",
            "MYSQL_USER": "<MYSQL_USER>",
            "MYSQL_PASSWORD": "<MYSQL_PASSWORD>",
            "MYSQL_DATABASE": "<MYSQL_DATABASE>"
          }
        }
      }
    }

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

    Devin Desktop setup guide

  • Cline

    Add to cline_mcp_settings.json

    {
      "mcpServers": {
        "database-mcp-mysql": {
          "command": "npx",
          "args": [
            "-y",
            "@database-mcp/mysql"
          ],
          "env": {
            "MYSQL_HOST": "<MYSQL_HOST>",
            "MYSQL_USER": "<MYSQL_USER>",
            "MYSQL_PASSWORD": "<MYSQL_PASSWORD>",
            "MYSQL_DATABASE": "<MYSQL_DATABASE>"
          }
        }
      }
    }

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

    Cline setup guide

  • Zed

    Add to Zed settings.json

    {
      "context_servers": {
        "database-mcp-mysql": {
          "command": "npx",
          "args": [
            "-y",
            "@database-mcp/mysql"
          ],
          "env": {
            "MYSQL_HOST": "<MYSQL_HOST>",
            "MYSQL_USER": "<MYSQL_USER>",
            "MYSQL_PASSWORD": "<MYSQL_PASSWORD>",
            "MYSQL_DATABASE": "<MYSQL_DATABASE>"
          }
        }
      }
    }

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

    Zed setup guide

  • JetBrains AI Assistant and Junie

    AI Assistant

    Add to Settings → Tools → AI Assistant → Model Context Protocol (MCP) → Add

    {
      "mcpServers": {
        "database-mcp-mysql": {
          "command": "npx",
          "args": [
            "-y",
            "@database-mcp/mysql"
          ],
          "env": {
            "MYSQL_HOST": "<MYSQL_HOST>",
            "MYSQL_USER": "<MYSQL_USER>",
            "MYSQL_PASSWORD": "<MYSQL_PASSWORD>",
            "MYSQL_DATABASE": "<MYSQL_DATABASE>"
          }
        }
      }
    }

    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": {
        "database-mcp-mysql": {
          "command": "npx",
          "args": [
            "-y",
            "@database-mcp/mysql"
          ],
          "env": {
            "MYSQL_HOST": "<MYSQL_HOST>",
            "MYSQL_USER": "<MYSQL_USER>",
            "MYSQL_PASSWORD": "<MYSQL_PASSWORD>",
            "MYSQL_DATABASE": "<MYSQL_DATABASE>"
          }
        }
      }
    }

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

    JetBrains AI Assistant and Junie setup guide

  • Kiro

    Add to ~/.kiro/settings/mcp.json

    {
      "mcpServers": {
        "database-mcp-mysql": {
          "command": "npx",
          "args": [
            "-y",
            "@database-mcp/mysql"
          ],
          "env": {
            "MYSQL_HOST": "<MYSQL_HOST>",
            "MYSQL_USER": "<MYSQL_USER>",
            "MYSQL_PASSWORD": "<MYSQL_PASSWORD>",
            "MYSQL_DATABASE": "<MYSQL_DATABASE>"
          }
        }
      }
    }

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

    Kiro setup guide

Using several servers? Build one config file with the MCP config generator.

Configuration

  • MYSQL_HOSTDatabase hostRequired
  • MYSQL_USERDatabase user (a read-only user is recommended)Required
  • MYSQL_PASSWORDDatabase password (or use MYSQL_PASSWORD_FILE)
  • MYSQL_DATABASEDatabase nameRequired
  • MYSQL_HOSTDatabase hostRequired
  • MYSQL_USERDatabase user (a read-only user is recommended)Required
  • MYSQL_PASSWORDDatabase password (or use MYSQL_PASSWORD_FILE)
  • MYSQL_DATABASEDatabase nameRequired
  • MYSQL_HOSTDatabase hostRequired
  • MYSQL_USERDatabase user (a read-only user is recommended)Required
  • MYSQL_PASSWORDDatabase password (or use MYSQL_PASSWORD_FILE)
  • MYSQL_DATABASEDatabase nameRequired

About Database MCP Mysql

Connection settings for this MySQL variant are MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD (or MYSQL_PASSWORD_FILE) and MYSQL_DATABASE, passed at launch rather than typed into a chat. The registry entry suggests a read-only MySQL user for extra protection.

Two tools do the work: search_objects walks the schema from a table list down to columns, indexes and foreign keys, and execute_sql runs statements under a SQL guard and a read-only session, stopping at 1000 rows or 30 seconds unless configured otherwise.

The same repository ships SQLite, libSQL, MariaDB and Postgres versions with identical behaviour, installable from npm, PyPI or cargo and released under the MIT licence.

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.

execute_sqlName suggests: changes
Run SQL against the database, read-only by default.
search_objectsName suggests: reads
List tables, or show columns, indexes and foreign keys for a table.

What it does

MySQL environment config
Takes host, user, password and database from MYSQL_* variables.
Progressive schema view
search_objects goes from table list to columns, indexes and keys.
Guarded execute_sql
Enforces read-only mode, a 1000-row cap and a 30-second timeout by default.
Password files
Supports MYSQL_PASSWORD_FILE for mounted secrets.
Redacted logging
Keeps passwords out of logs.
Shared conformance tests
Behaves the same across npm, PyPI and Rust builds.

Good for

  • Ask questions about a MySQL schema in plain language
  • Run safe reporting queries on a replica
  • Review table indexes during a performance check
  • Let a coding agent look at sample rows without write access

Pricing

Open source

MIT licensed

More servers for the same service

Database MCP Mysql FAQ

Which environment variables does Database MCP Mysql need?

MYSQL_HOST, MYSQL_USER, MYSQL_DATABASE and a password via MYSQL_PASSWORD or a file.

Can the assistant modify data?

Not in the default read-only mode.

Where can I get Database MCP Mysql?

npm as @database-mcp/mysql, PyPI as database-mcp-mysql, or crates.io as database-mcp-rs-mysql.

Does Database MCP Mysql log passwords?

No, the README says secrets never appear in logs.

Is Database MCP Mysql free?

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

How do I add Database MCP Mysql to Claude Code?

Run this command in your terminal: claude mcp add database-mcp-mysql --env MYSQL_HOST='<MYSQL_HOST>' --env MYSQL_USER='<MYSQL_USER>' --env MYSQL_PASSWORD='<MYSQL_PASSWORD>' --env MYSQL_DATABASE='<MYSQL_DATABASE>' -- npx -y @database-mcp/mysql

What are the best alternatives to Database MCP Mysql?

The closest alternatives to Database MCP Mysql are Midplane, Datatomcp, Gulliver, GaussDB Read-Only MCP and Zektor.

Where this comes from

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

How AIPoweredBot checks servers