๐ณ MCP MySQL Server (Dockerized)
This project provides a fully containerized MCP (Model Context Protocol) server using Python, FastMCP, and MySQL.
๐ฆ Features
- Run SQL queries via MCP tools
- Retrieve table schemas
- List all tables in a connected MySQL database
- Containerized using Docker and ready for deployment
๐ Getting Started
1. Clone the Repository and Navigate
git clone <this-repo-url>
cd mcp_docker
2. Configure Environment
Copy .env.example
to .env
and fill in your MySQL credentials:
DB_HOST=your-db-host
DB_USER=your-db-user
DB_PASSWORD=your-db-password
DB_NAME=your-db-name
3. Build and Run with Docker
docker build -t mcp-mysql-server .
docker run --env-file .env -p 8000:8000 mcp-mysql-server
4. Using Docker Compose (optional)
Start both MySQL and MCP server with one command:
docker compose up --build
Note: If using Docker Compose, set
DB_HOST=db
in your.env
file.
๐งช Tools Exposed
run_sql_query(query: str) -> list
get_table_schema(table_name: str) -> list
list_tables() -> list
You can interact with the server via an MCP-compatible client.
๐ File Structure
mcp_docker/
โโโ Dockerfile
โโโ requirements.txt
โโโ .env.example
โโโ docker-compose.yml
โโโ mcp_mysql_server.py
โโโ README.md
๐ Requirements
- Python 3.10+
- Docker
- MySQL server or container
- fastmcp
๐ License
MIT โ feel free to use and modify!
Happy coding! ๐
MCP MySQL Server
Project Details
- chalfacre/pysql_mcp
- Last Updated: 4/16/2025
Recomended MCP Servers
A MCP server for our beloved terminal multiplexer tmux.
An MCP server for reading dlis files
This MCP server integrates with your Google Drive and Google Sheets, to enable creating and modifying spreadsheets.
Model Context Protocol Servers
CLI to set up and deploy MCP Servers to Cloudflare Workers in seconds. Just write TypeScript functions to...
Ethereum Tools for Claude - A comprehensive blockchain analysis toolkit that enables Claude AI to audit smart contracts,...
A book series on JavaScript. @YDKJS on twitter.
An experimental ModelContextProtocol server connecting LLMs to DefectDojo for AI-powered security workflows. Enables natural language interaction with vulnerability...