Lists all available tables in the connected MySQL database
Retrieves data from a specified MySQL table
Executes a custom SQL query against the MySQL database
MySQL Database Access provides a secure bridge between AI applications and MySQL databases. It enables structured exploration and analysis of database content through a controlled interface, allowing AI systems to safely query and retrieve data without direct database access. With comprehensive error handling and logging, it ensures reliable and secure database operations while maintaining proper access controls.
MySQL Database Access enables AI applications to safely interact with MySQL databases through a controlled interface. This implementation follows the Model Context Protocol (MCP) to provide structured access to database resources, allowing AI systems to explore and analyze data without direct database access.
You can install the MySQL Database Access in several ways:
pip install mysql-mcp-server
npx -y @smithery/cli install mysql-mcp-server --client claude
The MySQL Database Access requires database connection details to be provided as environment variables:
MYSQL_HOST
: Database host (default: localhost)MYSQL_PORT
: Database port (default: 3306)MYSQL_USER
: Database usernameMYSQL_PASSWORD
: Database passwordMYSQL_DATABASE
: Database nameTo use MySQL Database Access with Claude Desktop, add the following configuration 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"
}
}
}
}
Replace the placeholder values with your actual database connection details.
To use MySQL Database Access with Visual Studio Code, add the following 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: You'll need to install uv
for this configuration to work.
When using MySQL Database Access, follow these security best practices:
If you encounter issues:
The MySQL Database Access is designed to be integrated with AI applications and should not be run directly as a standalone program.