MySQL MCP
Bind an AI client to one MySQL or MariaDB database, read-only unless you allow writes
MySQL MCP 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
- 1.1.1
- Listing updated
Similar MCP servers
Install
Add with the CLI
Run in a 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-clientAdd --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-client": {
"command": "npx",
"args": [
"-y",
"mcp-mysql-client"
],
"env": {
"MYSQL_USER": "<MYSQL_USER>",
"MYSQL_PASS": "<MYSQL_PASS>",
"MYSQL_DB": "<MYSQL_DB>"
}
}
}
}Add to claude_desktop_config.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.
Add to ~/.cursor/mcp.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.
Add to ~/.copilot/mcp-config.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.
Add with the CLI
Run in a terminal
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-clientOr add to config.toml
Add to ~/.codex/config.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>" }Add to your client's MCP settings (most use this shape)
{
"mcpServers": {
"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
Add to ~/.gemini/settings.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
Antigravity
Add to ~/.gemini/config/mcp_config.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 (formerly Windsurf)
Add to ~/.config/devin/mcp_config.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
Add to cline_mcp_settings.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
Add to Zed settings.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
Add to Settings → Tools → AI Assistant → Model Context Protocol (MCP) → Add
{ "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.
Junie
Add to ~/.junie/mcp/mcp.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
Add to ~/.kiro/settings/mcp.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.
Using several servers? Build one config file with the MCP config generator.
Configuration
MYSQL_HOSTDatabase host.MYSQL_PORTDatabase port.MYSQL_USERMySQL user. Use one with the least privileges the task needs, never root.RequiredMYSQL_PASSPassword for that user. Treat it as a secret; MYSQL_PASS_FILE reads it from a file instead.MYSQL_DBThe one database this server is bound to. No tool can leave it.RequiredMYSQL_SSLRequire a TLS connection to the server.MYSQL_SSL_CAPath to the CA bundle verifying the server certificate; implies MYSQL_SSL.ALLOW_INSERT_OPERATIONAllow INSERT statements through the execute tool.ALLOW_UPDATE_OPERATIONAllow UPDATE statements through the execute tool.ALLOW_DELETE_OPERATIONAllow DELETE statements through the execute tool.MYSQL_MAX_ROWSRow cap for one read; the result is marked truncated when it is hit.MYSQL_TIMEOUT_MSStatement timeout in milliseconds; the connection is dropped on expiry.
About MySQL MCP
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.
Tools this server provides (6)
Taken from the project documentation; the running server may differ.
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.
- queryName suggests: reads
- Runs a read-only SELECT query.
- executeName suggests: changes
- Runs INSERT, UPDATE or DELETE when the matching flag is enabled.
- explainName suggests: reads
- Returns the query plan, indexes and row estimates.
- list_tablesName suggests: reads
- Lists tables with sizes and row estimates.
- describe_tableName suggests: reads
- Shows columns, indexes and foreign keys in both directions.
- server_info
- Shows database, user, grants and server limits.
What it does
- 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
Pricing
Open source
MIT licence
More servers for the same service
MySQL MCP 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.
