MySQL MCP Server
This server lets you interact with a MySQL database through MCP tools for querying, schema inspection, and safe modifications.
Run read-only SQL queries:
querysupports SELECT, SHOW, DESCRIBE, EXPLAIN, and WITH statements (auto-LIMIT applied).Execute write operations:
executesupports INSERT, UPDATE, DELETE, and DDL, with a dry-run option to validate before executing.Discover databases:
list_databaseslists all databases on the server.List tables:
list_tablesshows tables in a database (or current database).Inspect schemas:
describe_tableshows a single table's structure, whiledescribe_all_tablesreturns the entire schema at once.Safely add comments:
add_commentadds or updates table/column comments without altering data or structure, with dry-run support.Enforce safety: read-only mode blocks write tools, query timeouts prevent hanging connections, and SSL support is available.
Provides tools to interact with MySQL databases, allowing for querying data, executing updates, listing databases and tables, and inspecting schema structures with support for SSL and read-only modes.
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 show me the schema for all tables"
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.
@imrieul/mysql-mcp-server
한국어 | 日本語 | 中文 | Español | Português | Français | Русский
A simple MySQL MCP server.
Features
LLM-friendly — compact column/row format, auto LIMIT, error hints with next-action suggestions
Bulk schema —
describe_all_tablesreturns entire DB schema in one callRead-only mode — app-level prefix check + DB-level
SET SESSION TRANSACTION READ ONLYQuery timeout —
Promise.race()based timeout with guaranteed connection cleanupSSL support — one env var to enable encrypted connections
Minimal — 3 dependencies, zero config required
Related MCP server: tokenlite-mysql-mcp
Quick Start
Add to your MCP config (.mcp.json or claude_desktop_config.json):
{
"mcpServers": {
"mysql": {
"command": "npx",
"args": ["-y", "@imrieul/mysql-mcp-server"],
"env": {
"MYSQL_HOST": "localhost",
"MYSQL_PORT": "3306",
"MYSQL_USER": "root",
"MYSQL_PASSWORD": "your-password",
"MYSQL_DATABASE": "your-database"
}
}
}
}Or with a connection string:
{
"mcpServers": {
"mysql": {
"command": "npx",
"args": ["-y", "@imrieul/mysql-mcp-server", "mysql://root:password@localhost:3306/mydb"]
}
}
}Codex
Codex uses TOML config, not mcpServers JSON. Add this to ~/.codex/config.toml or a project-scoped .codex/config.toml:
[mcp_servers.mysql]
command = "npx"
args = ["-y", "@imrieul/mysql-mcp-server"]
[mcp_servers.mysql.env]
MYSQL_HOST = "localhost"
MYSQL_PORT = "3306"
MYSQL_USER = "root"
MYSQL_PASSWORD = "your-password"
MYSQL_DATABASE = "your-database"opencode
Add this to opencode.json or opencode.jsonc:
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"mysql": {
"type": "local",
"command": ["npx", "-y", "@imrieul/mysql-mcp-server"],
"enabled": true,
"environment": {
"MYSQL_HOST": "localhost",
"MYSQL_PORT": "3306",
"MYSQL_USER": "root",
"MYSQL_PASSWORD": "your-password",
"MYSQL_DATABASE": "your-database"
}
}
}
}Read-only mode with SSL
{
"mcpServers": {
"mysql": {
"command": "npx",
"args": ["-y", "@imrieul/mysql-mcp-server", "--readonly"],
"env": {
"MYSQL_HOST": "db.example.com",
"MYSQL_USER": "readonly_user",
"MYSQL_PASSWORD": "password",
"MYSQL_DATABASE": "production",
"MYSQL_SSL": "true",
"MYSQL_QUERY_TIMEOUT": "10000"
}
}
}
}Tools
Tool | Description | Read-only mode |
| Execute SELECT, SHOW, DESCRIBE, EXPLAIN | Allowed |
| Execute INSERT, UPDATE, DELETE, DDL | Blocked |
| List all databases | Allowed |
| List tables in a database | Allowed |
| Show table schema | Allowed |
| Show all table schemas at once | Allowed |
Configuration
Environment variables
Variable | Required | Default | Description |
| Yes | — | MySQL host |
| Yes | — | MySQL user |
| Yes | — | MySQL password |
| No |
| MySQL port |
| No | — | Default database |
| No |
| Read-only mode |
| No |
| Auto LIMIT for SELECT queries |
| No |
| Query timeout in ms (0 to disable) |
| No |
| Enable SSL connection |
Connection string
mysql://user:password@host:port/databasePassed as the first CLI argument. Takes priority over environment variables.
License
MIT
Available Tools
7 toolsadd_commentA
Safely add a comment to a table or column. This tool only modifies comments — it cannot alter table structure, column types, or data. Set dryRun=true to preview the generated SQL without executing it. Use describe_table first to verify column names. Not available in read-only mode.
Inputs: table (required), comment (required), column, dryRun, +1 more.
describe_all_tablesA
Show the schema of all tables at once. Much more efficient than calling describe_table for each table individually. Warning: response can be large for databases with many tables — prefer describe_table for specific tables when possible.
Inputs: database.
describe_tableA
Show the schema/structure of a table, including column names, types, constraints, and comments. Use this before writing queries to ensure correct column names and types. For inspecting all tables at once, use describe_all_tables instead.
Inputs: table (required), database.
executeA
Execute a data modification SQL statement (INSERT, UPDATE, DELETE, CREATE, ALTER, DROP, etc.). Set dryRun=true to validate without executing — uses EXPLAIN for DML, or previews the SQL for DDL. Always confirm destructive operations (DROP, TRUNCATE, DELETE without WHERE) with the user before executing. Not available in read-only mode.
Inputs: sql (required), dryRun.
list_databasesA
List all databases on the MySQL server. Use this as a starting point to discover available databases before querying. Returns a JSON array of database names.
Inputs: no named parameters.
list_tablesA
List all tables in the specified database (or the current database if not specified). Includes table comments when available. Use this before describe_table to find the exact table name.
Inputs: database.
queryA
Execute a read-only SQL query (SELECT, SHOW, DESCRIBE, EXPLAIN). LIMIT is auto-appended to SELECT/WITH queries without one (default: server maxRows). Prefer specific columns over SELECT * to reduce response size. For data modification, use the "execute" tool instead.
Inputs: sql (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 7 tools
All tools have clearly distinct purposes: listing databases, listing tables, describing schemas (single or all), querying read-only, executing modifications, and adding comments. No overlap or confusion.
All tool names use a consistent verb_noun pattern in snake_case (e.g., list_databases, describe_table), with clear verbs like add, describe, execute, list, query. The naming is uniform and predictable.
With 7 tools, the server is well-scoped for MySQL database interactions. Each tool addresses a core operation without redundancy, and the count is appropriate for the domain.
The tool set covers the full lifecycle: discovery (list databases/tables), schema inspection (describe), data querying (query), modifications (execute), and metadata updates (add_comment). The execute tool handles any SQL needed, so there are no gaps.
Maintenance
Related MCP Connectors
Text-to-SQL MCP server: read-only queries on PostgreSQL, MySQL and SQL Server with your real schema
Hosted SQL Server MCP server for Claude, ChatGPT and Cursor, with each action switched per account.
PostgreSQL, MySQL, and SQL Server in one session. 26 read-only MCP tools for AI agents.
Draxlr's remote MCP server connects AI assistants to your SQL databases and dashboards. Explore schemas, run read-only queries, manage saved queries and dashboards, and export results, all with row-level security so each user sees only their own data.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceA Model Context Protocol server providing read-only access to MySQL databases, enabling LLMs to inspect database schemas and execute read-only queries.1MIT
- AlicenseAqualityBmaintenanceSecure and token-efficient MySQL MCP server built specifically for AI agents. Prevents hallucinations, optimizes context windows and blocks dangerous queries.5284 npmMIT
- AlicenseNot gradedqualityDmaintenanceA secure and efficient MCP server for MySQL database operations, enabling LLMs to execute SQL queries with read-only access by default and optional write permissions.22 PyPI3MIT
- AlicenseAqualityDmaintenanceA multi-database MCP server that enables LLMs to safely interact with MySQL, PostgreSQL, SQLite, and others through a unified tool interface, with permission modes and schema resources.1044MIT