MySQL MCP Server
This server lets an MCP client (e.g. Claude) inspect and query a local MySQL database with read-only guarantees, and make changes only after your explicit approval.
Check the server —
select_mysql_versionreturns the MySQL version.Explore schemas —
list_tableslists all tables in the connected database;describe_tableshows a table's columns, types and constraints.Run read queries —
queryexecutesSELECT-style statements (with optional?params) enforced read-only inside aREAD ONLYtransaction.Make approved writes —
mutaterunsINSERT,UPDATEorDELETE(and DDL only ifALLOW_DDL=true), but only after you approve the exact SQL, params and estimated row count.Stay safe — writes are audit-logged, declined/timeouts mean no change, and
READ_ONLY=trueremovesmutateentirely.
Allows connecting to a MySQL database to inspect schema, list tables, describe columns, and run read/write queries.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@MySQL MCP Server list all tables in the database"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
MySQL Mate
Let Claude (or any MCP client) read your local MySQL database so you stop switching between your editor, a SQL client and the terminal. Reads stay read-only, and nothing in your database changes unless you approve it.
The problem
Debugging on a local workstation usually means jumping back and forth:
Read the code to work out which tables and columns a feature touches.
Open a SQL client, find the right schema, and write a query by hand.
Copy the results back into your editor or chat, compare them with what the code expects, and repeat.
Every round trip takes minutes, and you lose context each time you switch tools. An AI assistant can read your code, but it can't see your data, so it ends up guessing about schemas and row contents.
The obvious fix is to give the AI direct database access. That raises a new worry: what stops it from running an UPDATE, DELETE or DROP TABLE on its own?
Related MCP server: mcp-mysql-server
The solution
This MCP server connects Claude to your MySQL database with guardrails built in:
Claude can look on its own. It lists tables, describes schemas and runs read queries while it reads your code, so it checks its assumptions against real data in the same conversation.
Reads are guaranteed read-only. The
querytool accepts only read statements, and runs each one inside a MySQLREAD ONLYtransaction. If something slips past the check, MySQL itself rejects the write.Every write needs your explicit approval. The
mutatetool shows you the exact SQL, its parameters and an estimated row count, and it runs only after you approve. This is enforced by the server, not just by a client setting.Schema changes are off by default. You decide whether
DROP,ALTERorTRUNCATEare possible at all.
The result is that you can let the AI investigate freely, while you stay in control of every change.
How to use
You need Node.js 18+ and a running MySQL database.
Claude Desktop
Download mysql-mate.mcpb (always the latest release).
Double-click it, then fill in your database host, user, password and database name.
Claude Code
claude mcp add mysql \
-e DB_HOST=127.0.0.1 -e DB_USER=claude_reader -e DB_PASSWORD=your_password -e DB_NAME=your_database \
-- npx -y mysql-mateOther MCP clients (Cursor, VS Code, Claude Desktop JSON config…)
{
"mcpServers": {
"mysql": {
"command": "npx",
"args": ["-y", "mysql-mate"],
"env": {
"DB_HOST": "127.0.0.1",
"DB_USER": "claude_reader",
"DB_PASSWORD": "your_password",
"DB_NAME": "your_database"
}
}
}
}From source
git clone https://github.com/iamdylanngo/mysql-mate && cd mysql-mate
npm install && npm run build
claude mcp add mysql -e DB_HOST=127.0.0.1 -e DB_USER=claude_reader -e DB_PASSWORD=your_password -e DB_NAME=your_database \
-- node "$(pwd)/build/index.js"Optional settings (read-only mode, schema changes, audit log) are listed under Configuration.
Example prompts
"Read
src/orders/service.tsand check whether theorderstable actually has the columns it queries.""Why does user 42 see an empty cart? Look at the code and the
cart_itemsrows for that user.""Find orders stuck in
pendingfor more than a day, then propose a fix.""Mark order 1001 as shipped." (Claude asks you to approve the
UPDATEbefore it runs.)
Tools
Tool | What it does | Changes data? |
| Returns the MySQL server version | No |
| Lists the tables in the connected database | No |
| Shows columns, types and constraints for a table | No |
| Runs | No, enforced read-only |
| Runs | Yes, only after your approval |
Why it's safe to use
Each layer works on its own, so one failing doesn't open the door.
Risk | What stops it |
The AI sneaks a write into a "read" |
|
The AI changes data without asking |
|
No answer | Fails closed. Declining, cancelling or a 5-minute timeout means the statement is not run |
A client that can't show the server prompt | Falls back to the client's own tool permission prompt for |
"Always allow" set on the tool by mistake | The server still asks when the client supports approval prompts. Clients without them rely on the tool prompt only |
Dropping or altering tables | DDL ( |
SQL injection tricks | Stacked statements ( |
"What did it change?" | Every write attempt (executed, declined, blocked or failed) is logged as JSON to stderr and, optionally, to |
Read tools are marked readOnlyHint: true and mutate is marked destructiveHint: true, so clients can show the right level of caution. You can safely set the read tools to Always allow, and investigation will flow without prompts.
What an approval looks like
The AI wants to run an UPDATE statement:
UPDATE orders SET status = ? WHERE id = ?
Params: ["shipped", 1001]
Estimated rows affected: ~1
[ ] Approve this database change [Accept] [Decline]Recommended setup
Use a dedicated MySQL user, not
root. The database's own permissions are the strongest guard.-- Investigation only CREATE USER 'claude_reader'@'localhost' IDENTIFIED BY '...'; GRANT SELECT ON your_database.* TO 'claude_reader'@'localhost'; -- Or allow approved writes on specific tables GRANT SELECT, INSERT, UPDATE, DELETE ON your_database.orders TO 'claude_writer'@'localhost';Turn on
READ_ONLY=truewhen you only want investigation.Point it at local or staging databases. Don't connect it to production.
Set
AUDIT_LOG_FILEif you want a record of every change.
Configuration
Variable | Default | Description |
|
| MySQL host |
|
| MySQL port |
|
| MySQL user |
| (empty) | MySQL password |
|
| Database name |
|
| Connection pool size |
|
|
|
|
|
|
| (unset) | File to append one JSON line per write attempt |
Releasing
Releases are built automatically by .github/workflows/release.yml:
git tag v1.0.3 && git push origin v1.0.3The workflow builds the server, sets the version from the tag, publishes mysql-mate to npm (with provenance), packs the .mcpb bundle and attaches it to a GitHub Release. You can also run it by hand from the Actions tab. A version that's already on npm is skipped, so re-running a release is safe.
npm authentication, one of:
Trusted publishing (recommended): on npmjs.com, open the package's Settings → Trusted publishing, add GitHub Actions with repository
iamdylanngo/mysql-mateand workflowrelease.yml. No secret needed.Token: create a granular access token with publish rights and save it as the
NPM_TOKENrepository secret.
Trusted publishing can only be set up once the package exists, so do the very first publish by hand:
npm login
npm publish --access publicTech stack
MCP SDK: MCP server framework
mysql2: MySQL client with promise support
Zod: input schema validation
TypeScript
License
Available Tools
5 toolsdescribe_tableC
Show columns, types, and constraints for a table.
Inputs: tableName (required).
list_tablesB
Listing all table, that connected to the database.
Inputs: no named parameters.
mutateC
Run an INSERT, UPDATE, or DELETE statement with optional params
Inputs: sql (required), params.
queryB
Run a read-only SELECT query with optional params (? placeholders).
Inputs: sql (required), params.
select_mysql_versionD
MySQL version.
Inputs: no named parameters.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 5 tools
Each tool has a distinct purpose: listing tables, describing a table, running SELECT queries, running INSERT/UPDATE/DELETE, and fetching MySQL version. There is no overlap.
Tool names mix verb_noun patterns (list_tables, describe_table) with single-verb names (mutate, query) and a verbose name (select_mysql_version). The inconsistency could confuse an agent about naming conventions.
With 5 tools covering listing, describing, querying, mutating, and version checking, the tool count is well-scoped for a MySQL server providing basic database interaction.
The tools cover essential read/write operations and schema inspection, but lack DDL tools like create or drop table. The mutate tool is limited to DML, so agents cannot perform schema changes.
Maintenance
Related MCP Connectors
Hosted MySQL MCP server for Claude, ChatGPT and Cursor, with each action switched per account.
Hosted SQL Server MCP server for Claude, ChatGPT and Cursor, with each action switched per account.
Talk to your public-facing AI from any MCP client — Claude, ChatGPT, Cursor, Cline, Windsurf.
Connect ChatGPT and Claude to your Mac, Windows or Linux with secure MCP remote access.
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceA Model Context Protocol (MCP) server that connects Claude Code to MySQL databases. Supports SSH tunnels, SSL/TLS, and multiple simultaneous connections.46 npm1MIT
- AlicenseNot gradedqualityDmaintenanceProvides a lightweight MySQL database interface via stdio, enabling query execution, data manipulation, schema inspection, and connection testing using FastMCP tools.3MIT
- AlicenseAqualityDmaintenanceA Model Context Protocol (MCP) server for interacting with MySQL databases. Provides tools for querying, inspecting, and modifying databases directly from Claude.77 npmMIT
- AlicenseNot gradedqualityDmaintenanceMCP server for MySQL/MariaDB/Aurora MySQL that enables executing SQL queries, explaining query plans, inspecting schema, checking health, and running diagnostic playbooks through Claude.Apache 2.0