mysql_query
Run SQL queries against MySQL database (READ-ONLY)
Let an agent inspect schemas and query MySQL — read-only by default, with writes opt-in one operation at a time.
LABSCO SUMMARY
Instead of pasting a table into the conversation, the model writes the query and reads the rows back. Writes are not a single on switch — insert, update, delete and DDL are separate flags, and they can be set per database, so a development schema can be writable while production stays read-only on the same connection.
A MySQL server with one tool and one resource: mysql_query runs SQL, and mysql://tables lists the tables and their column metadata. Everything else is configuration — what it may write, which databases it can reach, how the connection is secured, and what gets masked on the way out.
mysql_query)mysql://tables)ALLOW_INSERT_OPERATION, ALLOW_UPDATE_OPERATION, ALLOW_DELETE_OPERATION and ALLOW_DDL_OPERATION each turn on one class of write and nothing elseSELECT * refused while it is on unless you allow itMYSQL_RATE_LIMIT at 100 queries a minute, MYSQL_MAX_QUERY_COMPLEXITY, a 30000 ms query timeout and a 10-connection pool, all adjustableNode.js v20 or newer, MySQL 5.7 or newer with 8.0 recommended, and a MySQL user with the privileges you intend to use. npx @benborla29/mcp-server-mysql with MYSQL_HOST, MYSQL_PORT, MYSQL_USER, MYSQL_PASS and MYSQL_DB set — omit MYSQL_DB for multi-DB mode. Every write class is off until you turn it on, and the read-only transaction enforcement behind them has its own disable flag that is worth leaving alone. Grant the database user only what the flags allow, so the two limits agree.
One command plus credentials — npm install -g @benborla29/mcp-server-mysql, then supply credentials
USE CASES
Have the model write the SQL and read the rows. No export, no pasted table, and no stale copy of a number that changed this morning.
Read the tables resource rather than querying information_schema by hand. Column metadata comes with it, which is usually the half of the answer you were about to ask for next.
Set the schema-specific permission lists so insert and update are allowed on development and denied on production. One connection, two risk profiles, decided in configuration rather than in the prompt.
Turn on PII redaction so sensitive columns are masked before results reach the model, and add your own column names and patterns for the fields it would not guess. SELECT * is refused while redaction is on unless you allow it, which is the point.
Use the built-in SSH tunnel, or SSL with client certificates for mTLS. The remote HTTP mode behind a bearer token covers the case where the server itself is not local either.
The rate limit, the complexity ceiling and the query timeout are all set before anything runs. A model that writes an expensive join is a normal event, not an incident.
Counted once with only startup setup. Other versions, modes or optional credentials may expose a different list.
mysql_queryRun SQL queries against MySQL database (READ-ONLY)
BEFORE YOU INSTALL
1 tool when we connected. All write operations are disabled by default; INSERT, UPDATE, DELETE and DDL each need their own flag, with per-database overrides. Schema browsing is an MCP resource, mysql://tables, not a tool.
CONTEXT COST
Rated by the size of the one tool definition that rides along on every turn
INSTALLATION
npm install -g @benborla29/mcp-server-mysqlclaude mcp add mcp_server_mysql -e MYSQL_HOST="127.0.0.1" -e MYSQL_PORT="3306" -e MYSQL_USER="root" -e MYSQL_PASS="<YOUR_MYSQL_PASS>" -e MYSQL_DB="<YOUR_MYSQL_DB>" -- npx @benborla29/mcp-server-mysql{
"mcpServers": {
"mcp_server_mysql": {
"command": "npx",
"args": [
"-y",
"@benborla29/mcp-server-mysql"
],
"env": {
"MYSQL_HOST": "127.0.0.1",
"MYSQL_PORT": "3306",
"MYSQL_USER": "root",
"MYSQL_PASS": "<YOUR_MYSQL_PASS>",
"MYSQL_DB": "<YOUR_MYSQL_DB>"
}
}
}
}codex mcp add mcp_server_mysql --env MYSQL_HOST="127.0.0.1" --env MYSQL_PORT="3306" --env MYSQL_USER="root" --env MYSQL_PASS="<YOUR_MYSQL_PASS>" --env MYSQL_DB="<YOUR_MYSQL_DB>" -- npx -y @benborla29/mcp-server-mysqlCreate a .env file and copy from the example at https://github.com/benborla/mcp-server-mysql/blob/main/.env
Set your MySQL credentials, IS_REMOTE_MCP=true, REMOTE_SECRET_KEY to a secure string, and optionally PORT (default: 3000)
Load and run:
source .env
npx @benborla29/mcp-server-mysqlConfigure your agent — <YOUR_HOST> is the machine running the server, and the Bearer value is your REMOTE_SECRET_KEY:
{
"mcpServers": {
"mysql": {
"url": "http://<YOUR_HOST>:3000/mcp",
"type": "http",
"headers": {
"Authorization": "Bearer <YOUR_REMOTE_SECRET_KEY>"
}
}
}
}"type": "http" is how Claude Code and VS Code name this transport; Cline and Roo Code spell it "streamableHttp" (as the project's docs do), and Cursor reads the url without a type.