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 "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., "@mcp-mysql-explorershow 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) |
Installation
pip install mcp-mysql-explorerUsage in Cursor
Open Cursor Settings -> MCP, add a new server. Three ways to configure the database connection:
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"
]
}
}
}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"
}
}
}
}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=trueThen 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
# 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
This server cannot be installed
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/xsg22/mcp-mysql-explorer'
If you have feedback or need assistance with the MCP directory API, please join our Discord server