MySQL MCP Server
Enables full database management including schema inspection, CRUD operations, query execution, and administration of MySQL databases, stored procedures, functions, triggers, and views.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@MySQL MCP Servershow me the schema for the users table"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
MySQL MCP Server (Python & FastAPI)
A powerful Model Context Protocol (MCP) server that connects your AI assistant (like Claude Desktop) directly to your MySQL database. This server is written in Python, uses aiomysql for asynchronous database pooling, and is powered by FastAPI to support both standard STDIO and HTTP-based SSE transports.
🚀 Features
This server implements a wide range of MCP capabilities to give you full visibility and control over your MySQL database.
🛠️ Tools
Table Management
list-tables: List all tables in the database.describe-table: Get the schema (columns, types, keys) of a specific table.create-table: Create a new table using a SQL query.
Data Operations (CRUD)
insert-row: Insert a new row into a table using JSON data.update-row: Update existing rows with a convenient JSON-based WHERE clause.delete-row: Delete rows with a safety-first JSON-based WHERE clause.
Query Execution
execute-query: Execute read-only SQL queries (SELECT,SHOW,DESCRIBE). Safe for exploration.execute-write-query: Execute write SQL queries (INSERT,UPDATE,DELETE,ALTER, etc.). Use with caution.
Database Administration
create-database: Create a new database.
Advanced Objects Inspection
Stored Procedures:
list-procedures,show-procedure(view CREATE statement).Functions:
list-functions,show-function(view CREATE statement).Triggers:
list-triggers,show-trigger.Views:
list-views,show-view.
📦 Resources
Access database content directly as standard MCP resources:
mysql://<table_name>/schema: View the full JSON schema of a table.mysql://<table_name>/data: View the first 100 rows of a table as JSON.
💬 Prompts
Pre-built templates to help the AI perform complex tasks:
analyze-table: "Analyze the structure and sample data for table 'Users'..."Automatically fetches schema and sample data to provide insights.
optimize-query: "Analyze this query for performance..."Helps you write faster, more efficient SQL.
Related MCP server: MCPDB - Database Access MCP Server
📦 Installation & Setup
Clone the repository:
git clone <repository-url> cd mysql-mcp-serverInstall the dependencies: Ensure you have Python 3.10+ installed. Install requirements using
pip:pip install -r requirements.txt
⚙️ Running the Server
The server can run in two modes:
Mode 1: STDIO Transport (Local Integration)
Directly run the script with your database URL as the argument. This is the mode used by desktop clients like Claude Desktop.
python main.py mysql://user:password@localhost:3306/database_nameMode 2: SSE Transport (Web / Networked Server via FastAPI)
Run the FastAPI web server by specifying a port:
python main.py --port 8000 mysql://user:password@localhost:3306/database_nameAlternatively, you can set the environment variable and run via standard uvicorn:
# On Windows (cmd):
set MYSQL_URL=mysql://user:password@localhost:3306/database_name
# On Windows (PowerShell):
$env:MYSQL_URL="mysql://user:password@localhost:3306/database_name"
# On Linux/macOS:
export MYSQL_URL="mysql://user:password@localhost:3306/database_name"
uvicorn main:app --host 0.0.0.0 --port 8000Visit http://localhost:8000 to view the server status and connection dashboard.
🛠️ Claude Desktop Configuration
Add the following block to your claude_desktop_config.json depending on your preferred transport:
Option A: Direct STDIO Connection (No server to run in background)
{
"mcpServers": {
"mysql-stdio": {
"command": "python",
"args": [
"c:/Users/bhave/OneDrive/Desktop/MySQL MCP Server/main.py",
"mysql://user:password@localhost:3306/database_name"
]
}
}
}Note: Ensure you use the absolute path to main.py on your machine.
Option B: Remote SSE Connection (Requires running FastAPI server on port 8000)
{
"mcpServers": {
"mysql-sse": {
"command": "python",
"args": [
"-m",
"mcp.client.sse",
"http://localhost:8000/sse"
]
}
}
}💡 Usage Examples
Once connected in Claude, you can use queries like:
Exploration: "What tables are in my database?"
Schema: "Show me the schema for the
orderstable."Data Analysis: "Select the top 5 customers who spent the most money."
Modification: "Insert a new user named 'Alice' into the
userstable."Optimization: "Analyze this query and tell me why it's slow:
SELECT * FROM logs"
🔒 Security Note
This server has powerful capabilities, including write access (execute-write-query, delete-row, etc.). Always ensure you are connecting to a database where you have appropriate permissions, and be careful when asking the AI to modify data.
📄 License
MIT
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/bhaveshrmahajan/mysql-mcp-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server