mcp-server-mysql
Provides MySQL database integration for inspecting schemas, listing tables and views, executing SQL queries, and optionally managing data and database objects with opt-in write and management permissions.
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., "@mcp-server-mysqlShow me all tables in the sales database and their row counts"
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.
MCP Server for MySQL
Sponsor — Bloome

Using mcp-server-mysql to let your AI query MySQL? Bloome brings that to your whole team — an AI-agent IM platform where AI agents are members of the chat. Connect your MCP tools and have agents inspect schemas, run queries, and answer data questions for everyone in one thread. Zero local setup, runs in the cloud, on web and mobile.
MCP server that gives Claude and other LLMs access to MySQL — inspect schemas, run queries, and optionally write data, all through the Model Context Protocol.
Related MCP server: MCP Server for MySQL
Key Features
Read-only by default — write operations opt-in via env flags
Claude Code integration — optimized for Anthropic's Claude Code CLI
SSH tunnel support — built-in support for remote databases
Multi-DB mode — query across multiple databases without reconnecting
Schema-specific permissions — per-database read/write control
PII redaction — automatic masking of sensitive data in results
Remote mode — HTTP transport with bearer token auth
SSL/TLS support — encrypted connections with mTLS option
Requirements
Node.js v20+
MySQL 5.7+ (8.0+ recommended)
MySQL user with appropriate privileges
Quick Install
Claude Code (simplest):
claude mcp add mcp_server_mysql \
-e MYSQL_HOST="127.0.0.1" \
-e MYSQL_PORT="3306" \
-e MYSQL_USER="root" \
-e MYSQL_PASS="your_password" \
-e MYSQL_DB="your_database" \
-- npx @benborla29/mcp-server-mysqlClaude Desktop / other clients:
{
"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_password",
"MYSQL_DB": "your_database"
}
}
}
}All write operations are disabled by default. Enable with ALLOW_INSERT_OPERATION=true, ALLOW_UPDATE_OPERATION=true, ALLOW_DELETE_OPERATION=true.
Object/user/privilege management tools are disabled by default. Enable with ALLOW_OBJECT_MANAGEMENT=true, ALLOW_USER_MANAGEMENT=true, ALLOW_PRIVILEGE_MANAGEMENT=true.
Local Development with Reasonix
If you are using Reasonix for local development, use the project-local configuration files instead of the global plugin settings.
Recommended project files
.mcp.json— project MCP server definitionreasonix.toml— Reasonix local overrides for this project
Example .mcp.json
{
"mcpServers": {
"mcp-server-mysql": {
"command": "node",
"args": ["dist/index.js"],
"env": {
"MYSQL_HOST": "10.185.0.98",
"MYSQL_PORT": "3306",
"MYSQL_USER": "admin",
"MYSQL_PASS": "senwy110",
"MYSQL_DB": "",
"ALLOW_OBJECT_MANAGEMENT": "true",
"ALLOW_USER_MANAGEMENT": "true",
"ALLOW_PRIVILEGE_MANAGEMENT": "true"
}
}
}
}Example reasonix.toml
[[plugins]]
name = "mcp-server-mysql"
command = "node"
args = ["dist/index.js"]
cwd = "E:/coding/github/mcp-server-mysql"
env = { ALLOW_OBJECT_MANAGEMENT = "true", ALLOW_PRIVILEGE_MANAGEMENT = "true", ALLOW_USER_MANAGEMENT = "true", MYSQL_DB = "", MYSQL_HOST = "10.185.0.98", MYSQL_PASS = "senwy110", MYSQL_PORT = "3306", MYSQL_USER = "admin" }Important
Do not use
npx @benborla29/mcp-server-mysqlfor local development, because that runs the published package instead of your local changes.Always build first:
npm run buildMake sure
dist/index.jsexists in the current project before starting Reasonix.
Common error
If you see:
Error: Cannot find module 'E:\coding\python\scapoa_scrcu\dist\index.js'then Reasonix is still using an old project path. Fix it by:
Opening the
E:\coding\github\mcp-server-mysqlworkspace in ReasonixRestarting the
mcp-server-mysqlpluginVerifying the current project uses this repo's
.mcp.jsonandreasonix.toml
Verification
After setup, run a quick check:
{ "jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": { "name": "list_views", "arguments": { "database": "mcp_test_db" } } }If it returns view data instead of a path error, the local config is active.
Documentation
Installation Guide — Smithery, Cursor, Codex, Claude Code, local repo, remote mode
Configuration & Environment Variables — all env vars, advanced config
Multi-DB Mode — querying multiple databases
PII Redaction — automatic data masking
Testing — test setup and running
Troubleshooting — common issues and fixes
Tools & Resources
Tool: mysql_query
Execute SQL queries. Read-only by default. Write operations enabled per flag.
Management tools (opt-in) Enable the corresponding env flag before using these tools.
ALLOW_OBJECT_MANAGEMENT=trueALLOW_USER_MANAGEMENT=trueALLOW_PRIVILEGE_MANAGEMENT=true
Object management
list_views— list views in a databasecreate_view— create a viewdrop_view— drop a viewlist_routines— list stored routinesdrop_routine— drop a stored routine
User management
list_users— list MySQL userscreate_user— create a MySQL userdrop_user— drop a MySQL useralter_user— alter a MySQL userset_password— set a MySQL user password
Privilege management
show_grants— show grantsgrant_privilege— grant privilegesrevoke_privilege— revoke privilegesflush_privileges— flush privileges
Resources: mysql://tables
Lists all tables and column metadata for the connected database.
Usage Examples
SQL Query Tool
# Read-only query
mysql_query: { sql: "SELECT * FROM users WHERE id = 1" }Management Tools
Enable the required flags before using management tools.
ALLOW_OBJECT_MANAGEMENT=true
ALLOW_USER_MANAGEMENT=true
ALLOW_PRIVILEGE_MANAGEMENT=trueObject management
# List views
list_views: { database: "app_db" }
# Create view
create_view: { sql: "CREATE VIEW active_users AS SELECT * FROM users WHERE active = 1" }
# Drop view
drop_view: { sql: "DROP VIEW active_users" }
# List routines
list_routines: { database: "app_db", type: "PROCEDURE" }
# Drop routine
drop_routine: { sql: "DROP PROCEDURE cleanup_old_records" }User management
# List users
list_users: {}
# Create user
create_user: { sql: "CREATE USER 'app_user'@'%' IDENTIFIED BY 'secret'" }
# Drop user
drop_user: { sql: "DROP USER 'app_user'@'%'" }
# Alter user
alter_user: { sql: "ALTER USER 'app_user'@'%' IDENTIFIED BY 'new_secret'" }
# Set password
set_password: { sql: "ALTER USER 'app_user'@'%' IDENTIFIED BY 'new_secret'" }Privilege management
# Show grants
show_grants: { sql: "SHOW GRANTS FOR 'app_user'@'%'" }
# Grant privilege
grant_privilege: { sql: "GRANT SELECT ON app_db.* TO 'app_user'@'%'" }
# Revoke privilege
revoke_privilege: { sql: "REVOKE DELETE ON app_db.* FROM 'app_user'@'%'" }
# Flush privileges
flush_privileges: {}Contributing
PRs welcome at github.com/benborla/mcp-server-mysql.
git clone https://github.com/benborla/mcp-server-mysql.git
pnpm install
pnpm run build
pnpm testLicense
MIT — see LICENSE for details.
This server cannot be deployed
Maintenance
Related MCP Connectors
Safe, read-only Postgres and MySQL access for AI agents. Audit log + column-level controls.
- dataOAuthco.thinair
PostgreSQL, MySQL, and SQL Server in one session. 26 read-only MCP tools for AI agents.
Query 40 databases from Claude, ChatGPT, or Cursor — on any device. Read-only, encrypted, audited.
Query your org's data in natural language — read-only MCP access to SQL, NoSQL, files & warehouses.
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceEnables LLMs to interact with MySQL databases by inspecting schemas and executing safe, read-only queries within transactions.9 npm10MIT
- AlicenseNot gradedqualityCmaintenanceA Model Context Protocol server that provides read-only access to MySQL databases, enabling LLMs to inspect database schemas and execute read-only queries.7,922 npm2,119MIT
- AlicenseNot gradedqualityDmaintenanceA Model Context Protocol server providing read-only access to MySQL databases, enabling LLMs to inspect database schemas and execute read-only queries.4 npm1MIT
- AlicenseNot gradedqualityDmaintenanceA Model Context Protocol server that provides read-only access to MySQL databases, enabling LLMs to inspect database schemas and execute read-only queries.7,922 npmMIT