Provides a MySQL database operation interface for AI models via the Model Context Protocol.
Configuration
View docs{
"mcpServers": {
"mcp_mysql_server": {
"url": "http://your-server-address:port/mcp-mysql-server"
}
}
}You can access and manipulate MySQL databases through a standardized MCP interface that lets AI models perform queries, list tables, and inspect table structures safely and efficiently. This server handles connection pooling, multi-user concurrency, and secure handling of credentials so you can focus on building AI-powered data workflows.
You will interact with this MCP server through an MCP client that calls predefined tools to connect to MySQL, run queries, list tables, and describe table structures. There are two deployment approaches: local (stdio) mode where you run the server on your machine or environment, and remote (http) mode where you point clients at a remote MCP endpoint.
Prerequisites: you need Node.js installed on your system. It is recommended to use a recent LTS version of Node.js and npm or npx is available with your Node installation.
# Install the MCP server locally and prepare to run it
# Ensure Node.js and npm are installed on your system
# Install and run the MCP server locally (stdio mode)
export MYSQL_HOST=your_host
export MYSQL_USER=your_user
export MYSQL_PASSWORD=your_password
export MYSQL_DATABASE=your_database
export MYSQL_PORT=3306 # optional, defaults to 3306
npx -y @malove86/mcp-mysql-serverConfigure how the server is exposed to clients using the two deployment modes described below. You can choose the local, self-contained approach or the remote endpoint approach based on your environment and security needs.
Local runtime configuration (stdio) lets you include runtime settings in a MCP config file. Use the following structure to define the local server entry. It starts the MCP server via npx and passes the necessary environment variables for MySQL access.
{
"mcpServers": {
"mysql": {
"command": "npx",
"args": ["-y", "@malove86/mcp-mysql-server"],
"env": {
"MYSQL_HOST": "your_host",
"MYSQL_USER": "your_user",
"MYSQL_PASSWORD": "your_password",
"MYSQL_DATABASE": "your_database",
"MYSQL_PORT": "3306"
}
}
}
}If you want to run the MCP server remotely, you can point clients at a remote endpoint. Use a configuration that specifies the remote URL of the MCP server. The server will accept connections by URL and handle requests over HTTP.
{
"mcpServers": {
"mcp-mysql-server": {
"url": "http://your-server-address:port/mcp-mysql-server"
}
}
}Establishes a connection to the MySQL database using the provided credentials or environment variables.
Executes a SELECT query with optional prepared statement parameters.
Lists all tables in the connected database.
Retrieves the structure of a specified table.