================== /// MCP /// /// MYS /// ================== [server:online] [protocol:ready]
mysql_mcp_server
by designcomputer
Python implementation of a Model Context Protocol (MCP) server that safely exposes MySQL databases to AI clients.
698
162
Open Source01
List available MySQL tables as resources
Return a list of MySQL tables that can be accessed through the server
02
Read table contents
Retrieve and return the rows of a specified MySQL table
03
Execute SQL queries with proper error handling
Run arbitrary SQL statements against the connected MySQL database while handling errors safely
04
Secure database access through environment variables
Manage database connection credentials via environment variables for secure access
05
Comprehensive logging
Generate detailed logs for all database operations and server activities
Installation
1. Clone the repository
git clone https://github.com/designcomputer/mysql_mcp_server.git
cd mysql_mcp_server
2. Create and activate a virtual environment (recommended)
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
3. Install Python dependencies
pip install --upgrade pip
pip install -r requirements.txt
# or, when a Poetry lockfile is present
poetry install --no-root
4. Configure connection credentials (environment variables)
export MCP_SERVER_HOST=0.0.0.0
export MCP_SERVER_PORT=8000
export MYSQL_HOST=localhost
export MYSQL_PORT=3306
export MYSQL_USER=myuser
export MYSQL_PASSWORD=mypass
export MYSQL_DATABASE=mydb
# Optional security key for MCP tokens
export MCP_SECRET_KEY=change-me
Alternatively, create a .env file with the same keys.
5. (Optional) Spin up MySQL locally via Docker
docker run -d --name mcp-mysql -e MYSQL_ROOT_PASSWORD=mypass -e MYSQL_DATABASE=mydb -p 3306:3306 mysql:8
6. Run database migrations (if supplied)
alembic upgrade head # or invoke provided scripts in ./migrations
7. Start the MCP server
uvicorn mcp_server.app:app --host $MCP_SERVER_HOST --port $MCP_SERVER_PORT --reload
8. Verify it’s alive
curl http://localhost:8000/health
Docker-Compose shortcut
-----------------------
docker compose up -d # brings up both the server and MySQL
The service will now listen (default) on http://localhost:8000.
Documentation
# Transform Your Database Development with MySQL MCP Server + Augment Code Stop context-switching between your IDE and database tools. The MySQL MCP Server transforms Augment Code into a powerful database-aware coding assistant that can directly query your MySQL databases, analyze schemas, and generate database-specific code—all without leaving your development environment. ## Supercharge Your Database Workflow Once configured in Augment's MCP settings, this server gives your AI assistant direct access to your MySQL database through a secure, controlled interface. Now when you're building data-driven applications, Augment can instantly query your actual database schema, examine table relationships, and generate code based on your real data structure. Ask Augment to "show me the user table schema" or "generate a SQL query to find inactive users from the last 30 days" and watch it execute queries against your live database, returning actual results that inform better code generation. ## Real-World Productivity Gains Imagine you're building a new feature that requires understanding complex table relationships. Instead of manually exploring your database, simply ask Augment: "What are the foreign key relationships for the orders table?" It will query your database directly and provide detailed schema information. Building an ORM model? Augment can examine your existing table structure and generate accurate SQLAlchemy or Django models that match your database perfectly. Debugging a slow query? Augment can analyze your table indexes and suggest optimizations based on your actual data distribution. **Setup is straightforward**: Install via `pip install mysql-mcp-server`, add your database credentials to Augment's MCP configuration, and immediately unlock database-driven development capabilities. Your AI assistant evolves from a general code generator to a database-aware partner that understands your data layer as intimately as your application code.
License: MIT License
Updated 7/15/2025