About MySQL MCP Server
A Python MySQL MCP server built with FastMCP 2.0. It provides tools for queries and database structure inspection, and supports Docker-based deployment.
Key features
- 01Execute SQL queries and updates
- 02List database tables
- 03Retrieve table schemas
- 04Describe database structure
- 05Docker and docker-compose packaging
Use cases
- 01Run queries against MySQL
- 02Inspect table schemas
- 03Review database structure
MCP support
The server exposes MCP tools for query execution, updates, table listing, schema retrieval, and database description.
Configuration
Local server config is the same for every client. Copy it into your client’s MCP config file.
Tools
Local servers expose tools only once running on your machine, and the maintainer has not provided a tool list.
Details
From the project READMEMySQL MCP Server
A MySQL Model Context Protocol (MCP) server implemented with FastMCP 2.0 and Python.
Features
- Execute SQL queries via MCP functions
- Get database schema information
- Fully containerized with Docker and docker-compose
- Packaged with Poetry for dependency management
MCP Tools
The server provides the following MCP tools:
execute_query: Execute a SQL query and return resultsexecute_update: Execute an update/insert SQL queryget_tables: Get a list of tables in the databaseget_table_schema: Get schema information for a specific tabledescribe_database: Get comprehensive database structure information
Setup
Prerequisites
- Docker and docker-compose
- Poetry (for local development)
- Python 3.13+
Cursor Integration
To integrate with Cursor, add the following to your ~/.cursor/mcp.json file:
{
"mcpServers": {
"mysqlMcp": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-e",
"MYSQL_HOST",
"-e",
"MYSQL_PORT",
"-e",
"MYSQL_USER",
"-e",
"MYSQL_PASSWORD",
"-e",
"MYSQL_DATABASE",
"mysql-mcp-server"
],
"env": {
"MYSQL_HOST": "host.docker.internal",
"MYSQL_PORT": "3306",
"MYSQL_USER": "root",
"MYSQL_PASSWORD": "password",
"MYSQL_DATABASE": "mcpdb"
}
}
}
}
Docker Build
To build the Docker image separately:
docker build -t mysql-mcp-server .
Comments
New to MCP?
From what the protocol is to installing your first server, these answers cover most first questions.
An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.