MySQL MCP Server
The MySQL MCP Server provides tools to interact with a MySQL database: query, modify, and inspect schemas.
query: Execute read-only SQL (SELECT, SHOW, DESCRIBE, EXPLAIN, WITH/CTE); auto-appends LIMIT to prevent oversized resultsexecute: Run data modification statements (INSERT, UPDATE, DELETE, CREATE, ALTER, DROP); supportsdryRunmode for validation; blocked in read-only modelist_databases: List all available databases on the serverlist_tables: List all tables in a specified database, including table commentsdescribe_table: Show schema of a specific table (column names, types, constraints, comments)describe_all_tables: Retrieve the full schema of every table in a database in a single calladd_comment: Add or update comments on a table or column without altering data; supportsdryRun; blocked in read-only modeRead-only mode: Blocks all write operations at both application and database session level
SSL support: Encrypted connections enabled via environment variable
Query timeout: Automatic timeout with connection cleanup
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 "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 MCP Servershow 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
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
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
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/ImRieul/mysql-mcp-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server