- Home
- MCP servers
- MySQL
MySQL
- python
1.1k
GitHub Stars
python
Language
6 months ago
First Indexed
2 months ago
Catalog Refreshed
Documentation & install
Readme and setup notes from the catalogue, plus a client-ready config you can copy for your MCP host.
Installation
Add the following to your MCP client configuration file.
Configuration
View docs{
"mcpServers": {
"designcomputer-mysql_mcp_server": {
"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_DATABASE": "your_database",
"MYSQL_PASSWORD": "your_password"
}
}
}
}You can securely interact with MySQL databases through a dedicated MCP server that exposes a controlled interface for AI applications. It lets you list tables, read data, and run SQL queries with proper error handling, all while keeping credentials and access tightly managed via environment variables.
How to use
Use a compatible MCP client (for example, Claude Desktop or Visual Studio Code with the MCP extension) to connect to the MySQL MCP Server. The MCP server acts as a bridge between your AI host and the MySQL database, enabling you to explore data sources and perform queries in a structured, auditable way.
How to install
Prerequisites: make sure you have Python installed (for the server package) and, if you choose the Smithery route, Node.js is available on your system.
Install the MySQL MCP Server package with Python’s package manager.
pip install mysql-mcp-server
Additional configuration and usage notes
Configure the following environment variables to enable secure access to your MySQL database:
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
With Claude Desktop
Add this MCP server configuration to your Claude Desktop setup to run the MySQL MCP Server via a local process.
{
"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"
}
}
}
}
With Visual Studio Code
Add a MCP server entry to your VS Code configuration to run the server as a stdio process.
{
"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"
}
}
}
}
Debugging with MCP Inspector
If you need to debug the MCP implementation interactively, you can use the MCP Inspector. Install dependencies and then launch the inspector tooling to test the MCP configuration without running the server directly through Python.
# Install inspector dependencies
pip install -r requirements.txt
# Use the MCP Inspector for debugging
Development
To contribute or run the project locally, clone the repository, set up a virtual environment, install development dependencies, and run tests.
git clone https://github.com/designcomputer/mysql_mcp_server.git
cd mysql_mcp_server
python -m venv venv
source venv/bin/activate # or `venv\Scripts\activate` on Windows
pip install -r requirements-dev.txt
pytest
Security considerations
Never commit environment variables or credentials. Use a database user with minimal permissions and enable logging for auditability. Consider implementing query whitelisting for production use.
Available tools
list_tables
Lists available MySQL tables as resources that you can explore or query.
read_table
Reads and returns the contents of a selected table.
execute_sql
Executes a SQL query with proper error handling and returns results or errors.
secure_access
Ensures secure access via environment variables and minimal privilege database users.
logging
Provides comprehensive logging of database operations for audit and debugging.