by designcomputer
Enables secure interaction with MySQL databases via the Model Context Protocol, allowing AI applications to list tables, read contents, and execute queries safely.
Provides a Model Context Protocol implementation that mediates communication between AI applications (such as Claude Desktop or VS Code extensions) and MySQL databases, offering a controlled interface for database exploration and analysis.
pip install mysql-mcp-server
MYSQL_HOST=localhost
MYSQL_PORT=3306 # optional, defaults to 3306
MYSQL_USER=your_username
MYSQL_PASSWORD=your_password
MYSQL_DATABASE=your_database
claude_desktop_config.json
or VS Code mcp.json
). The client launches the server via the command defined in the MCP configuration.pip
or Smithery integrationQ: Can I run the server as a standalone Python script? A: The server is designed to be launched by an MCP client, not directly as a standalone program.
Q: Do I need to install Node.js or npm? A: No. The core server runs on Python. Node‑related commands are only for optional Smithery or client‑side integrations.
Q: How do I limit the queries that can be executed? A: Implement query whitelisting or use a MySQL user with minimal privileges as recommended in the security guidelines.
Q: Where can I find more security recommendations?
A: See the SECURITY.md
file in the repository for detailed best‑practice instructions.
Q: Which AI platforms are supported? A: The server works with any MCP‑compatible client, including Claude Desktop, VS Code extensions, and custom MCP inspectors.
A Model Context Protocol (MCP) implementation that enables secure interaction with MySQL databases. This server component facilitates communication between AI applications (hosts/clients) and MySQL databases, making database exploration and analysis safer and more structured through a controlled interface.
Note: MySQL MCP Server is not designed to be used as a standalone server, but rather as a communication protocol implementation between AI applications and MySQL databases.
pip install mysql-mcp-server
To install MySQL MCP Server for Claude Desktop automatically via Smithery:
npx -y @smithery/cli install mysql-mcp-server --client claude
Set the following environment variables:
MYSQL_HOST=localhost # Database host
MYSQL_PORT=3306 # Optional: Database port (defaults to 3306 if not specified)
MYSQL_USER=your_username
MYSQL_PASSWORD=your_password
MYSQL_DATABASE=your_database
Add this to your claude_desktop_config.json
:
{
"mcpServers": {
"mysql": {
"command": "uv",
"args": [
"--directory",
"path/to/mysql_mcp_server",
"run",
"mysql_mcp_server"
],
"env": {
"MYSQL_HOST": "localhost",
"MYSQL_PORT": "3306",
"MYSQL_USER": "your_username",
"MYSQL_PASSWORD": "your_password",
"MYSQL_DATABASE": "your_database"
}
}
}
}
Add this to your mcp.json
:
{
"servers": {
"mysql": {
"type": "stdio",
"command": "uvx",
"args": [
"--from",
"mysql-mcp-server",
"mysql_mcp_server"
],
"env": {
"MYSQL_HOST": "localhost",
"MYSQL_PORT": "3306",
"MYSQL_USER": "your_username",
"MYSQL_PASSWORD": "your_password",
"MYSQL_DATABASE": "your_database"
}
}
}
}
Note: Will need to install uv for this to work
While MySQL MCP Server isn't intended to be run standalone or directly from the command line with Python, you can use the MCP Inspector to debug it.
The MCP Inspector provides a convenient way to test and debug your MCP implementation:
# Install dependencies
pip install -r requirements.txt
# Use the MCP Inspector for debugging (do not run directly with Python)
The MySQL MCP Server is designed to be integrated with AI applications like Claude Desktop and should not be run directly as a standalone Python program.
# Clone the repository
git clone https://github.com/designcomputer/mysql_mcp_server.git
cd mysql_mcp_server
# Create virtual environment
python -m venv venv
source venv/bin/activate # or `venv\Scripts\activate` on Windows
# Install development dependencies
pip install -r requirements-dev.txt
# Run tests
pytest
This MCP implementation requires database access to function. For security:
See MySQL Security Configuration Guide for detailed instructions on:
⚠️ IMPORTANT: Always follow the principle of least privilege when configuring database access.
MIT License - see LICENSE file for details.
git checkout -b feature/amazing-feature
)git commit -m 'Add some amazing feature'
)git push origin feature/amazing-feature
)Please log in to share your review and rating for this MCP.
{ "mcpServers": { "mysql": { "command": "npx", "args": [ "-y", "mysql-mcp-server" ], "env": { "MYSQL_HOST": "<YOUR_HOST>", "MYSQL_PORT": "3306", "MYSQL_USER": "<YOUR_USERNAME>", "MYSQL_PASSWORD": "<YOUR_PASSWORD>", "MYSQL_DATABASE": "<YOUR_DATABASE>" } } } }
Explore related MCPs that share similar capabilities and solve comparable challenges
by googleapis
An MCP server that streamlines database tool development by handling connection pooling, authentication, observability, and secure access, allowing agents to interact with databases via natural language.
by bytebase
Provides a universal gateway that lets MCP‑compatible clients explore and query MySQL, PostgreSQL, SQL Server, MariaDB, and SQLite databases through a single standardized interface.
by benborla
Provides read‑only access to MySQL databases for large language models, allowing schema inspection and safe execution of SQL queries.
by ClickHouse
Enables AI assistants to run read‑only ClickHouse queries, list databases and tables, and execute embedded chDB queries through an MCP interface.
by chroma-core
Offers an MCP server exposing Chroma's vector database capabilities for LLM applications, supporting collection and document management, multiple embedding functions, and flexible client types such as in‑memory, persistent, HTTP, and cloud.
by kiliczsh
Enables LLMs to interact with MongoDB databases via a standardized interface, offering schema inspection, query execution, aggregation, and write capabilities, with optional read‑only mode and smart ObjectId handling.
by domdomegg
Provides read and write access to Airtable bases for AI systems, enabling inspection of schemas and manipulation of records.
by XGenerationLab
A Model Context Protocol (MCP) server that enables natural language queries to databases
by apache
Provides an MCP backend service built with Python and FastAPI to interact with Apache Doris databases, enabling natural language to SQL conversion, query execution, metadata extraction, and comprehensive enterprise data governance.