mysql-mcp
Provides tools for querying MySQL databases, allowing AI agents to list tables, describe schemas, run structured SELECT queries, check permissions, and optionally insert/update rows.
Click on "Install 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-mcpwhat are the columns in the orders table?"
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-mcp
Query MySQL tables from Claude Code — read-only by default.
An MCP server that gives Claude Code (and any MCP client) read access to a MySQL database through structured, parameterized query tools. No raw SQL passthrough by default — the tool surface is designed so the worst possible outcome is a SELECT that returns too many rows.
Modeled on Agent360's browser-mcp (same MCP server patterns: stdio transport, lifecycle handling, LLM-facing tool descriptions).
Testing
npm testThree layers, all under node --test (no test framework dependency):
File | Layer | Needs DB? |
SQL builder security contract (identifiers, params, clamps, footgun defense) | No | |
Error → LLM-hint mapping + result truncation | No | |
Full MCP protocol against a real MySQL, via test/helpers/mcp-client.js | Yes — suites skip gracefully when unreachable |
Integration env (defaults match the local Docker dev setup; override freely):
TEST_DB_HOST / TEST_DB_PORT / TEST_DB_USER / TEST_DB_PASSWORD / TEST_DB_NAME
TEST_DB_RW_USER / TEST_DB_RW_PASSWORD → write suite (skipped if unset)
TEST_DB_ADMIN_PASSWORD → cleanup of write-test rowsRelated MCP server: mysql-mcp
Status — M5
Five read tools plus two opt-in write tools, all integration-tested against a real MySQL:
Tool | What it does |
| Verify MCP + MySQL connectivity, returns guiding errors |
|
|
| Column names/types/keys/defaults/comments via information_schema |
| Structured queries — key/value WHERE, column lists, order, limit (hard cap 200) |
| Shows the account's grants and whether it is read-only |
| INSERT + read-back of the inserted row |
| UPDATE with REQUIRED where, default LIMIT 1 (cap 100) + read-back of the new state |
Writing — opt-in at two levels
Write tools exist only when both hold:
Server: started with
ALLOW_WRITES=1— otherwise the tools are not even advertised intools/list, and dispatch refuses them anyway.Database: the connected account holds INSERT/UPDATE grants (verify with
check_permissions).
Safety defaults on update_rows: where is required (a where-less UPDATE is
rejected — the classic footgun), limit defaults to 1 and caps at 100.
Every write reads the affected rows back and returns the verified new state.
Security — three tiers, all enforced
Tier | Defense | Where |
1. Database | SELECT-only account ( | Your DBA work — verified by |
2. Connection |
| |
3. Application | No raw SQL passthrough; identifier allowlist + | db.js |
Every tool call is audited to stderr — shape only (tool, table name, row count), never values. Same secret-hygiene contract as browser-mcp's action log.
Reliability & LLM experience
Errors are LLM-actionable. Raw MySQL/network errors are classified and shipped with a hint that says what to do next:
Error: Table 'x' doesn't exist→Hint: Call list_tables...,Unknown column→Hint: Call describe_table..., connection failures →Hint: Check DB_HOST / DB_PORT...(marked retryable).Retry policy. Transient connection failures retry once automatically (SELECTs are idempotent); SQL errors never retry. Same read-only/retryable split as browser-mcp's CDP whitelist.
Result truncation. Results are capped at 50,000 serialized chars (on top of the 200-row cap). When truncated, the response carries
truncated: true,fetched, and a hint telling the model to narrow (WHERE filters, fewer columns, offset paging) instead of re-querying bigger.
Roadmap
✅ M1–M6 core done: skeleton, query tools, security, reliability, opt-in writes, test suite
⏸️ npm publishing — skipped by decision; add
@scopename, LICENSE, registry metadata (server.json/glama.json) if you ever publish
Install (local — no npm publish needed)
cd /path/to/mysql-mcp
node bin/cli.js installThis writes the mysql-mcp server into ~/.claude/mcp.json, pointing at this
checkout's index.js by absolute path (dev-mode install, same pattern as
browser-mcp's install.sh). Credentials use ${VAR} placeholders — Claude Code
resolves them from your environment, never stored in the config file:
{
"mcpServers": {
"mysql-mcp": {
"command": "node",
"args": ["/path/to/mysql-mcp/index.js"],
"env": {
"DB_HOST": "${DB_HOST}",
"DB_PORT": "${DB_PORT}",
"DB_USER": "${DB_USER}",
"DB_PASSWORD": "${DB_PASSWORD}",
"DB_NAME": "${DB_NAME}"
}
}
}
}Database account — read-only, always
CREATE USER 'mcp_ro'@'%' IDENTIFIED BY '<strong-password>';
GRANT SELECT ON <your_db>.* TO 'mcp_ro'@'%';Point it at a read replica if you have one.
Dev
npm ci
node index.js # → [mysql-mcp] MySQL MCP server running (stdio)Environment variables
Var | Default | Description |
|
| MySQL host |
|
| MySQL port |
| (required) | MySQL user |
| (empty) | MySQL password |
| (none) | Default database |
|
| Per-query timeout in ms |
| (unset) | Set to |
License
MIT
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseAqualityDmaintenanceAn MCP server that provides read-only access to MySQL databases.451970MIT
- Alicense-qualityDmaintenanceA lightweight MCP server providing safe, read-only access to MySQL databases. It enables users to query multiple MySQL instances securely while preventing write operations.848MIT
- Alicense-qualityCmaintenanceA production-ready MCP server for MySQL database operations, providing secure HTTP endpoints for read-only queries, performance analysis, and server monitoring.459MIT
- Alicense-qualityBmaintenanceA MySQL MCP server for local stdio clients, enabling database queries and management with read-only/write modes, audit logging, and configurable security.655MIT
Related MCP Connectors
An MCP server giving access to Grafana dashboards, data and more.
Read-only MCP server for ClassQuill, a tutoring-business-management platform.
Read-only MCP server for wafergraph.com's semiconductor & AI supply-chain data: 30 tools, no auth.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/zuozhu20100425/mysql-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server