🐳 MCP MySQL Server (Dockerized)

🐳 MCP MySQL Server (Dockerized)

By chalfacre GitHub

Python MCP server for MySQL

docker mysql
Overview

What is MCP MySQL Server?

MCP MySQL Server is a fully containerized server that implements the Model Context Protocol (MCP) using Python and MySQL, designed to facilitate SQL query execution and database management.

How to use MCP MySQL Server?

To use the MCP MySQL Server, clone the repository, configure your MySQL credentials in the .env file, and run the server using Docker commands or Docker Compose.

Key features of MCP MySQL Server?

  • Execute SQL queries via MCP tools.
  • Retrieve table schemas from the connected MySQL database.
  • List all tables in the database.
  • Fully containerized for easy deployment with Docker.

Use cases of MCP MySQL Server?

  1. Running SQL queries in a containerized environment.
  2. Managing MySQL databases with ease using MCP tools.
  3. Simplifying deployment and scaling of MySQL servers.

FAQ from MCP MySQL Server?

  • Is MCP MySQL Server easy to set up?

Yes! It can be set up quickly using Docker with minimal configuration.

  • What are the requirements to run MCP MySQL Server?

You need Python 3.10+, Docker, and a MySQL server or container.

  • Can I modify the MCP MySQL Server?

Yes! It is licensed under MIT, allowing you to use and modify it freely.

Content

🐳 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! 🎉

No tools information available.
MCP-Mealprep
MCP-Mealprep by JoshuaRL

This project takes a number of MCP servers from GitHub locations, packages them together with this repo's GHCR container, and launches them with docker-compose to run as a stack for ML/AI resources.

docker ai
View Details

Simple MCP Server w/ Shell Exec. Connect to Local via Ngrok, or Host Ubuntu24 Container via Docker

docker spring-boot
View Details

-

docker server
View Details

Mirror of

mcp-server mysql
View Details