mcp-mysql-explorer
Allows AI agents to explore schemas, query data, and execute SQL statements on a MySQL database. Supports read-only queries (SELECT/SHOW/DESCRIBE/EXPLAIN) and optional write operations (INSERT/UPDATE/DELETE/DDL) when write mode is enabled.
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-mysql-explorer show me 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.
MCP MySQL Server
A Model Context Protocol (MCP) server that connects AI agents (Cursor, Claude Desktop, etc.) to MySQL databases, enabling schema exploration, data querying, and SQL execution through natural language.
Chinese docs: README.zh.md
Features
Tool | Description |
| List all tables in the database |
| View table schema with column types and comments |
| Execute read-only queries (SELECT / SHOW / DESCRIBE / EXPLAIN) |
| Execute write operations (INSERT / UPDATE / DELETE / DDL), disabled in read-only mode |
| Show all indexes of a table |
| Get the CREATE TABLE statement |
| Get database overview (version, size, table count) |
Related MCP server: DatabaseMCP
Installation
pip install mcp-mysql-explorerUsage in Cursor
Open Cursor Settings -> MCP, add a new server. Three ways to configure the database connection. SSH tunneling through a bastion/jump host is also supported.
Option 1: Command-line arguments (recommended)
{
"mcpServers": {
"mysql": {
"command": "mcp-mysql-explorer",
"args": [
"--host", "your-mysql-host",
"--port", "3306",
"--user", "your-user",
"--password", "your-password",
"--database", "your-database"
]
}
}
}Enable write mode explicitly:
{
"mcpServers": {
"mysql": {
"command": "mcp-mysql-explorer",
"args": [
"--host", "your-mysql-host",
"--database", "your-database",
"--allow-write"
]
}
}
}If the database is only reachable through an SSH bastion, add --ssh-* arguments:
{
"mcpServers": {
"mysql": {
"command": "mcp-mysql-explorer",
"args": [
"--host", "mysql.internal",
"--port", "3306",
"--user", "your-db-user",
"--password", "your-db-password",
"--database", "your-database",
"--ssh-host", "bastion.example.com",
"--ssh-port", "22",
"--ssh-user", "your-ssh-user",
"--ssh-private-key", "/Users/you/.ssh/id_rsa"
]
}
}
}In SSH mode,
--host/MYSQL_HOSTis the MySQL address as seen from the SSH server. SSH tunneling is enabled automatically when--ssh-hostorMYSQL_SSH_HOSTis set. You can explicitly disable it with--ssh-enabled false.
Option 2: Environment variables
{
"mcpServers": {
"mysql": {
"command": "mcp-mysql-explorer",
"env": {
"MYSQL_HOST": "your-mysql-host",
"MYSQL_PORT": "3306",
"MYSQL_USER": "your-user",
"MYSQL_PASSWORD": "your-password",
"MYSQL_DATABASE": "your-database",
"MYSQL_READ_ONLY": "true",
"MYSQL_SSH_HOST": "bastion.example.com",
"MYSQL_SSH_PORT": "22",
"MYSQL_SSH_USER": "your-ssh-user",
"MYSQL_SSH_PRIVATE_KEY": "/Users/you/.ssh/id_rsa"
}
}
}
}SSH environment variables:
Environment variable | Description |
| Enable SSH tunneling (true/false). Defaults to enabled when |
| SSH bastion/jump host |
| SSH port, defaults to |
| SSH username |
| SSH password |
| Path to SSH private key |
| SSH private key passphrase |
| Local forwarding bind host, defaults to |
| Local forwarding bind port, defaults to |
Option 3: .env file
Create a .env file in the working directory:
MYSQL_HOST=your-mysql-host
MYSQL_PORT=3306
MYSQL_USER=your-user
MYSQL_PASSWORD=your-password
MYSQL_DATABASE=your-database
MYSQL_READ_ONLY=true
MYSQL_SSH_HOST=bastion.example.com
MYSQL_SSH_USER=your-ssh-user
MYSQL_SSH_PRIVATE_KEY=/Users/you/.ssh/id_rsaThen simply:
{
"mcpServers": {
"mysql": {
"command": "mcp-mysql-explorer"
}
}
}Priority: command-line args > environment variables >
.envfile
Usage in Claude Desktop
Add to your claude_desktop_config.json:
{
"mcpServers": {
"mysql": {
"command": "mcp-mysql-explorer",
"args": [
"--host", "your-mysql-host",
"--user", "your-user",
"--password", "your-password",
"--database", "your-database"
]
}
}
}Run Manually
# With command-line arguments
mcp-mysql-explorer --host localhost --user root --password secret --database mydb
# Explicitly allow write operations
mcp-mysql-explorer --host localhost --user root --password secret --database mydb --allow-write
# Through an SSH bastion
mcp-mysql-explorer --host mysql.internal --user root --password secret --database mydb \
--ssh-host bastion.example.com --ssh-user deploy --ssh-private-key ~/.ssh/id_rsa
# With .env file
mcp-mysql-explorer
# As a Python module
python -m mcp_mysql_explorer --host localhost --database mydbTesting
# Run unit tests (no real database needed)
python scripts/run_tests.py# Optional manual smoke check (reads credentials from env only)
# Required env: MYSQL_HOST, MYSQL_PORT, MYSQL_USER, MYSQL_PASSWORD, MYSQL_DATABASE
python scripts/manual_smoke_check.py --mode bothSecurity Notes
The
querytool only allows SELECT / SHOW / DESCRIBE / EXPLAIN statements.Read-only mode is enabled by default (
MYSQL_READ_ONLY=true).To enable writes, set
MYSQL_READ_ONLY=falseor pass--allow-write.The
execute_sqltool can run write operations only when read-only mode is disabled.Query results are capped at 1000 rows by default.
Table/column identifiers are backtick-wrapped to prevent SQL injection.
License
MIT
Available Tools
7 toolsdescribe_tableC
Get the schema (columns, types, keys) of a specific table.
Args: table_name: Name of the table to describe.
Inputs: table_name (required). Returns: result
execute_sqlB
Execute a write SQL statement (INSERT / UPDATE / DELETE / ALTER / CREATE / DROP, etc).
Use with caution: this modifies the database.
Args: sql: The SQL statement to execute.
Inputs: sql (required). Returns: result
get_create_tableC
Get the CREATE TABLE statement of a specific table.
Args: table_name: Name of the table.
Inputs: table_name (required). Returns: result
get_database_infoA
Get overview information about the connected database, including size, table count, and charset.
Inputs: no named parameters. Returns: result
get_table_indexesB
Show all indexes of a specific table.
Args: table_name: Name of the table.
Inputs: table_name (required). Returns: result
list_tablesA
List all tables in the connected MySQL database.
Inputs: no named parameters. Returns: result
queryA
Execute a read-only SQL query (SELECT / SHOW / DESCRIBE / EXPLAIN).
Only SELECT, SHOW, DESCRIBE, and EXPLAIN statements are allowed.
Args: sql: The SQL query to execute.
Inputs: sql (required). Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 7 tools
The read/write split between query and execute_sql is explicitly stated in both descriptions, so an agent can pick correctly. The introspection tools (describe_table, get_table_indexes, get_create_table) overlap somewhat since DESCRIBE/SHOW can also surface keys and index info, but each has a distinct output focus.
All names are snake_case, but verb conventions are mixed: list_tables/describe_table use one verb family, while get_table_indexes/get_create_table/get_database_info use 'get', and query/execute_sql are bare verb forms. Readable overall, but 'get_create_table' is awkward and the pattern isn't uniform.
Seven tools is well-scoped for a MySQL explorer: schema discovery, ad-hoc read queries, writes, and database metadata each have exactly one owner. No tool feels redundant padding.
The surface covers introspection, read queries, write DDL/DML, and database-level info, so core workflows are supported. Minor gaps exist around database/schema switching (e.g. listing databases or selecting a schema) and explicit transaction control, which agents would have to work around with raw SQL.
Maintenance
Related MCP Connectors
Text-to-SQL MCP server: read-only queries on PostgreSQL, MySQL and SQL Server with your real schema
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.
Related MCP Servers
- FlicenseNot gradedqualityCmaintenanceAn MCP server for MySQL databases that enables schema exploration, query execution, and resource access through a unified interface. It features a LangGraph-based agent that translates natural language into SQL queries with automatic error recovery and schema discovery.-
- FlicenseNot gradedqualityCmaintenanceAn MCP server that enables AI agents to safely explore and interact with MySQL databases through dynamic tool generation from stored procedures. It provides database discovery capabilities and intelligent procedure categorization while enforcing security restrictions to prevent data modification.-
- FlicenseNot gradedqualityBmaintenanceAn MCP server that exposes relational databases (PostgreSQL/MySQL) to AI agents with natural language to SQL query support.19-
- AlicenseNot gradedqualityDmaintenanceA MySQL MCP server for secure database interaction, enabling schema inspection, query execution, and RBAC via AI coding assistants.7MIT