MySQL MCP Server
A lightweight server for executing SQL queries and inspecting schemas across multiple MySQL database connections. It provides tools for managing persistent connection configurations and exploring database structures through natural language.
README
MySQL MCP Server
A lightweight Model Context Protocol (MCP) server for MySQL database operations. Supports multiple named connections and runs in a minimal Docker container.
Features
- Multiple Connections: Manage multiple MySQL connections with unique names
- Persistent Storage: Connection configs saved to SQLite (survives restarts)
- Query Execution: Execute arbitrary SQL queries with parameterized support
- Schema Inspection: List databases, tables, and describe table structures
- Minimal Footprint: Alpine-based Docker image (~92MB)
- Pre-configured Connections: Optionally load connections from environment variables
Tools
| Tool | Description |
|---|---|
add_connection |
Add a new MySQL connection with a unique name |
remove_connection |
Remove an existing connection |
list_connections |
List all active connections |
execute_query |
Execute SQL queries on a named connection |
list_databases |
List all databases on a connection |
list_tables |
List tables in a database |
describe_table |
Get table schema/structure |
Quick Start
Build the Docker Image
docker build -t mysql-mcp .
Run with Docker
# Run interactively (for MCP stdio communication)
# Mount ./config to persist connection data
docker run -i --rm -v $(pwd)/config:/app/config mysql-mcp
Pre-configure Connections
Set the MYSQL_CONNECTIONS environment variable with a JSON array:
docker run -i --rm \
-v $(pwd)/config:/app/config \
-e MYSQL_CONNECTIONS='[{"name": "prod", "host": "mysql.example.com", "port": 3306, "user": "admin", "password": "secret", "database": "myapp"}]' \
mysql-mcp
Docker Compose
docker-compose up -d
MCP Configuration
Add to your MCP client configuration (e.g., Claude Desktop):
{
"mcpServers": {
"mysql": {
"command": "docker",
"args": ["run", "-i", "--rm", "-v", "/path/to/config:/app/config", "mysql-mcp"],
"env": {
"MYSQL_CONNECTIONS": "[{\"name\": \"dev\", \"host\": \"host.docker.internal\", \"port\": 3306, \"user\": \"root\", \"password\": \"secret\"}]"
}
}
}
}
Note: Use host.docker.internal to connect to MySQL running on your host machine.
Usage Examples
Add a Connection
{
"name": "add_connection",
"arguments": {
"name": "production",
"host": "db.example.com",
"port": 3306,
"user": "app_user",
"password": "secure_password",
"database": "myapp"
}
}
Execute a Query
{
"name": "execute_query",
"arguments": {
"connection": "production",
"query": "SELECT * FROM users WHERE status = %s LIMIT 10",
"params": ["active"]
}
}
List Tables
{
"name": "list_tables",
"arguments": {
"connection": "production",
"database": "myapp"
}
}
Development
Run Locally (without Docker)
# Install dependencies
pip install -r requirements.txt
# Run the server
python src/server.py
Test with a Local MySQL
Uncomment the MySQL service in docker-compose.yml:
docker-compose up -d
Persistence
Connection configurations are stored in a SQLite database at /app/config/connections.db. Mount a volume to ./config to persist connections across container restarts:
docker run -i --rm -v $(pwd)/config:/app/config mysql-mcp
The database stores:
- Connection name, host, port, user, password, and default database
Security Notes
- Passwords are stored in the SQLite database - ensure the config directory has appropriate permissions
- Use environment variables for initial seeding; they will be saved to the store
- The container runs as a non-root user (uid 1000)
- Consider using Docker secrets or a vault for sensitive credentials
- Set
MCP_CONFIG_PATHenvironment variable to customize the config directory
License
MIT
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.