MySQL MCP server: what its write switches really stop, and how to make your agent ask
The one tool of @benborla29/mcp-server-mysql 2.0.9, checked by running it against MySQL 8.4: what its write switches and read-only transaction really stop, how SET GLOBAL took the server offline with every write off, how a DELETE hidden in a versioned comment passed as an INSERT, why per-schema permissions trusted a comment, and the Claude Code settings that make it ask.
Checked on by running @benborla29/mcp-server-mysql 2.0.9 (npm, run with npx) from benborla/mcp-server-mysql and reading its tools/list answer. Each tier is the tool risk checker’s reading, with our reason wherever we changed it. Written by the people who make VariantGate.
The short answer
Its one tool runs any SQL a parser lets through, and the write switches are only that parser's guess. Sign it in as a MySQL user with nothing but SELECT on the tables it needs, which refused everything we tried, and make mysql_query ask.
- Can run on their own
- 0
- Should ask a person
- 1
Which MySQL server this is
This page is about @benborla29/mcp-server-mysql, Ben Borla’s MySQL server on npm. We ran 2.0.9, its latest release, with npx against MySQL 8.4.13 in Docker, first signed in as root, as its README’s setup does, then as a user that can only read. It offers one tool, mysql_query, which runs the SQL it is given. Under npx it called itself “MySQL MCP Server” 1.0.0, and its description began “[vundefined]”. Four switches turn writes on: ALLOW_INSERT_OPERATION, ALLOW_UPDATE_OPERATION, ALLOW_DELETE_OPERATION and ALLOW_DDL_OPERATION, all off by default. SCHEMA_*_PERMISSIONS set them per database, and leaving MYSQL_DB empty starts multi-database mode.
How it decides what is a write
We read its code. It parses the SQL with node-sql-parser, and only seven statement types count as writes: insert, update, delete, create, alter, drop and truncate. If the switch for one is on, the whole text runs in an ordinary transaction and is committed. Everything else, including CALL, REPLACE, RENAME, GRANT, SET and LOAD DATA, is treated as a read: the server runs SET SESSION TRANSACTION READ ONLY, runs the statement and rolls back. What the parser cannot read is refused with “Parsing failed”, which is how DO SLEEP(1), KILL 1 and FLUSH PRIVILEGES were stopped.
With every write switch off, as root
The read-only transaction refused, or the parser did:
DELETE,SELECT 1; DELETE …, aDELETEinside/*!50000 … */, andCALLof a procedure that deletes, even one that runsCOMMITfirst.REPLACE INTO,LOAD DATA,SELECT … FOR UPDATE,LOCK TABLES,RENAME TABLEandGRANT;TRUNCATEandCREATE USERwere refused as DDL.
What a transaction cannot undo got through. SET GLOBAL offline_mode = 1 succeeded, and the next login by another user failed with “The server is currently in offline mode”. SET PERSIST max_connections = 66 was written to mysqld-auto.cnf, so it outlasts a restart. SELECT … INTO OUTFILE wrote the customers to a file in /var/lib/mysql-files/, the image’s secure_file_priv folder; a path in /tmp was refused. Where secure_file_priv is empty, MySQL allows any path it can write to. As root it also read the password hashes in mysql.user and a table in a database other than MYSQL_DB.
With only inserts allowed, a hidden DELETE ran
The parser skips /*! … */ as a comment; MySQL runs what is inside it. With only ALLOW_INSERT_OPERATION on, a plain DELETE was refused, and this was not:
/*!50000 DELETE FROM customers WHERE id = 4 OR name = '*/
INSERT INTO orders VALUES (9, 1, 1) /*' */The parser saw an INSERT. MySQL saw a DELETE whose WHERE ends in a string holding the rest. The answer was “Insert successful on schema 'app'. Affected rows: 1”; customer 4 was gone and no order 9 was added. We tried this with inserts; from the code, any write switch that is on opens the same door, because the parser only has to see that statement type.
Per-schema permissions trust the first name they see
- With
MYSQL_DB=app, the schema checked is alwaysapp. UnderSCHEMA_DELETE_PERMISSIONS=app:true,other:false,DELETE FROM other.secrets WHERE id = 1deleted the row, and the answer said “on schema 'app'”. - In multi-database mode it takes the first
USE nameorname.tablein the text. UnderSCHEMA_DELETE_PERMISSIONS=sandbox:true,DELETE FROM app.customers WHERE id = 1was refused, but addingOR name = 'USE sandbox', or a comment/* sandbox.x */, deleted fromapp. - Its multi-database guide says that mode is read-only by default. The code only writes a log line: with
ALLOW_DELETE_OPERATION=trueandMULTI_DB_WRITE_MODEunset, aDELETEran. - The read-only hint looks only at the four global switches. With just a schema permission set, the tool still said “(READ-ONLY)” and
readOnlyHint: truewhile deletes ran.
Turning off read-only transactions
MYSQL_DISABLE_READ_ONLY_TRANSACTIONS=true, which its configuration guide marks with a warning, removes the one check that held above. With every write switch still off, a hidden DELETE, a CALL and a REPLACE each reported rows affected and were then rolled back, but RENAME TABLE and GRANT ALL ON *.* commit on their own and stayed. The tool still described itself as read-only.
Logging and defaults
From its code: logging is off unless ENABLE_LOGGING=true; its configuration guide names MYSQL_ENABLE_LOGGING, which the code does not read. Turned on, it printed each query, values included, to standard output, the channel MCP messages travel on, so our client had to skip those lines. The password was masked. The user defaults to root with an empty password, and with MYSQL_SSL=true the certificate is not checked unless MYSQL_SSL_REJECT_UNAUTHORIZED=true. The guide also lists MYSQL_QUERY_TIMEOUT, MYSQL_RATE_LIMIT and MYSQL_MAX_QUERY_COMPLEXITY; the code reads none of them.
Give it a MySQL user that can only read
CREATE USER 'agent_ro'@'%' IDENTIFIED BY '…';
GRANT SELECT ON app.customers TO 'agent_ro'@'%';
GRANT SELECT ON app.orders TO 'agent_ro'@'%';claude mcp add mysql -e MYSQL_HOST=db.internal -e MYSQL_PORT=3306 -e MYSQL_USER=agent_ro -e MYSQL_PASS=… -e MYSQL_DB=app -- npx -y @benborla29/mcp-server-mysql@2.0.9Every query still asks; signed in as this user, what you approve is which rows it reads, not whether it writes. Signed in as a user with only SELECT on app, the server could not do any of the above, even with inserts and deletes switched on and read-only transactions off: MySQL refused SET GLOBAL, SET PERSIST, INTO OUTFILE, mysql.user, the other database, the hidden DELETE and GRANT. Leave the switches off anyway, and set MYSQL_USER yourself rather than taking the root default.
Check the folder the server starts in. Its code loads a .env file from there, and Claude Code starts it in your project. A MYSQL_CONNECTION_STRING in that file takes the place of MYSQL_USER: with -e MYSQL_USER=agent_ro and a root connection string in .env, SELECT CURRENT_USER() answered root@%. An ALLOW_*_OPERATION line there would switch writes on the same way. Keep database settings for the server out of the project’s .env.
Its one tool
Hard to undo1 toolAsk a person every time. Consider two people, or deny it if the agent never needs it.
mysql_query[MySQL MCP Server [vundefined]] Run SQL queries against MySQL database (READ-ONLY)
Server says: read-only
Our call: Calls itself read-only, but runs any SQL its parser lets through: signed in as root with every write switch off, SET GLOBAL offline_mode = 1 locked other users out, and with only inserts allowed, a DELETE hidden in a versioned comment ran.
Claude Code asks for every call
Claude Code asks before every MCP tool it has no rule for. Added as mysql, this server’s tools are named mcp__mysql__<tool>. None of its tools only looks, so there is no allow rule to add: leave it without one and every call asks, including any tool a later version of the server adds.
The command that adds the server:
claude mcp add mysql -e MYSQL_HOST=db.internal -e MYSQL_PORT=3306 -e MYSQL_USER=agent_ro -e MYSQL_PASS=… -e MYSQL_DB=app -- npx -y @benborla29/mcp-server-mysql@2.0.9Send the rest to a person, not the terminal
A prompt in the terminal only works while someone is watching it. With this hook, every call of the server becomes a request in your VariantGate inbox, on your phone or in Slack, and Claude Code waits for the answer. The matcher covers the whole server, so a tool added later is sent too. Put the key in VARIANTGATE_KEY, or run the one-command setup for Claude Code first.
{
"hooks": {
"PreToolUse": [
{
"matcher": "mcp__mysql__.*",
"hooks": [
{ "type": "command", "command": "variantgate hook claude-code", "timeout": 180 }
]
}
]
}
}Disagree with a tier, or run the server with other flags? Open these tools in the tool risk checker, change what you like, and copy the settings for your own setup. It runs in your browser and starts from its own reading, so a tool we marked as only looking by hand asks there until you change it.
Any MCP client: put the proxy in front
Claude Desktop, Cursor and most other MCP clients have no hook to send a call to a person. The VariantGate MCP proxy does it in the server’s place: it starts the server and holds every call until someone approves it in the inbox. Run npx -y https://variantgate.com/sdk/variantgate-agent-0.15.0.tgz login once to save a key, then use this in claude_desktop_config.json or ~/.cursor/mcp.json:
{
"mcpServers": {
"mysql": {
"args": [
"-y",
"https://variantgate.com/sdk/variantgate-agent-0.15.0.tgz",
"mcp-proxy",
"--name",
"mysql",
"--",
"npx",
"-y",
"@benborla29/mcp-server-mysql@2.0.9"
],
"command": "npx",
"env": {
"MYSQL_HOST": "db.internal",
"MYSQL_PORT": "3306",
"MYSQL_USER": "agent_ro",
"MYSQL_PASS": "…",
"MYSQL_DB": "app"
}
}
}
}Already have it in Claude Desktop? One command rewrites the file for you, with every call asking, and keeps the old one (setup vscode does the same for VS Code; how it works):
npx -y https://variantgate.com/sdk/variantgate-agent-0.15.0.tgz setup claude-desktopThe same in Claude Code, instead of the hook. The proxy now asks about every call that matters, so an allow rule for the whole server, mcp__mysql, keeps Claude Code from asking a second time in the terminal:
claude mcp add mysql -e MYSQL_HOST=db.internal -e MYSQL_PORT=3306 -e MYSQL_USER=agent_ro -e MYSQL_PASS=… -e MYSQL_DB=app -- npx -y https://variantgate.com/sdk/variantgate-agent-0.15.0.tgz mcp-proxy --name mysql -- npx -y @benborla29/mcp-server-mysql@2.0.9When the agent should write
Add the server a second time under its own name, such as mysql-write, signed in as a user granted INSERT or UPDATE on just the tables it needs, so the rules for mcp__mysql__ do not cover it. Treat the grant as the limit, not the switches. When you approve a query, read its comments too: in MySQL, /*! … */ is code.
See it before you decide.
The playground runs the whole approval loop in your browser, no account needed. When it fits, the free plan covers 100 requests a month.