A Model Context Protocol server that provides read-only access to MySQL databases.
4.2K
A Model Context Protocol server that provides read-only access to MySQL databases. This server enables LLMs to inspect database schemas, execute and explain read-only queries, and analyze performance metrics.
mysql-query
sql (string): The SQL query to executemysql-explain
sql (string): The SQL query to explainmysql-stats
name (string): The table namemysql-connect
connectionString (string): MySQL connect string (e.g., host.docker.internal:3306/mydb)user (string): Username (e.g., root)password (string): Passwordmysql-awr
The server provides schema information for each table in the MySQL database:
mysql://<database>/<table>/schema)
The MySQL server uses environment variables for secure credential management:
MYSQL_USER: MySQL username (required)MYSQL_PASSWORD: MySQL password (required)The connection string should contain only the host, port, and database information (without embedded credentials).
Supported connection string formats:
mysql://host:port/dbnamehost:port/dbnameTo use this server with the Claude Desktop app, add the following configuration to the "mcpServers" section of your claude_desktop_config.json:
host.docker.internal if the MySQL server is running on the host network (e.g., localhost)MYSQL_USER and MYSQL_PASSWORD{
"mcpServers": {
"mysql": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-e", "MYSQL_USER=myuser",
"-e", "MYSQL_PASSWORD=mypassword",
"mochoa/mcp-mysql",
"host.docker.internal:3306/mydb"
]
}
}
}
{
"mcpServers": {
"mysql": {
"command": "npx",
"args": [
"-y",
"@marcelo-ochoa/server-mysql",
"localhost:3306/mydb"
],
"env": {
"MYSQL_USER": "myuser",
"MYSQL_PASSWORD": "mypassword"
}
}
}
}
Replace /mydb with your database name.
Note: Replace the following placeholders with your actual values:
myuser and mypassword with your MySQL credentialslocalhost:3306 with your MySQL server host and portmydb with your database nameFor manual installation, add the following JSON block to your User Settings (JSON) file in VS Code. You can do this by pressing Ctrl + Shift + P and typing Preferences: Open User Settings (JSON).
Optionally, you can add it to a file called .vscode/mcp.json in your workspace. This will allow you to share the configuration with others.
Note that the
mcpkey is not needed in the.vscode/mcp.jsonfile.
Note: When using Docker and connecting to a MySQL server on your host machine, use host.docker.internal instead of localhost in the connection URL.
{
"mcp": {
"inputs": [
{
"type": "promptString",
"id": "mysql_url",
"description": "MySQL URL (e.g. mysql://host.docker.internal:3306/mydb)"
},
{
"type": "promptString",
"id": "mysql_user",
"description": "MySQL username"
},
{
"type": "promptString",
"id": "mysql_password",
"description": "MySQL password",
"password": true
}
],
"servers": {
"mysql": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-e", "MYSQL_USER=${input:mysql_user}",
"-e", "MYSQL_PASSWORD=${input:mysql_password}",
"mochoa/mcp-mysql",
"${input:mysql_url}"
]
}
}
}
}
{
"mcp": {
"inputs": [
{
"type": "promptString",
"id": "mysql_url",
"description": "MySQL URL (e.g. mysql://localhost:3306/mydb)"
},
{
"type": "promptString",
"id": "mysql_user",
"description": "MySQL username"
},
{
"type": "promptString",
"id": "mysql_password",
"description": "MySQL password",
"password": true
}
],
"servers": {
"mysql": {
"command": "npx",
"args": [
"-y",
"@marcelo-ochoa/server-mysql",
"${input:mysql_url}"
],
"env": {
"MYSQL_USER": "${input:mysql_user}",
"MYSQL_PASSWORD": "${input:mysql_password}"
}
}
}
}
}
Put this in ~/.gemini/antigravity/mcp_config.json
{
"mcpServers": {
"mysql": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-e",
"MYSQL_USER=myuser",
"-e",
"MYSQL_PASSWORD=mypassword",
"mochoa/mcp-mysql",
"host.docker.internal:3306/mydb"
]
}
},
"inputs": []
}
For optimal performance monitoring with the mysql-awr tool, ensure that the Performance Schema is enabled in your MySQL configuration:
[mysqld]
performance_schema = ON
The Performance Schema provides detailed query statistics and performance metrics. If it's not enabled, the AWR report will still generate but with limited query-level statistics.
Docker:
docker build -t mochoa/mcp-mysql -f src/mysql/Dockerfile .
NPM:
cd src/mysql
npm install
npm run build
Sample prompts to try with the MySQL MCP server:
users tableSee MySQL AWR in action for an example of a performance report generated by the mysql-awr tool, highlighting specific optimization opportunities.
See Change Log for the history of changes.
As usual, the code of this extension is at GitHub, feel free to suggest changes and make contributions.
This MCP server is licensed under the MIT License. This means you are free to use, modify, and distribute the software, subject to the terms and conditions of the MIT License. For more details, please see the LICENSE file in the project repository.
Content type
Image
Digest
sha256:da3cab0ef…
Size
102.5 MB
Last updated
about 1 month ago
docker pull mochoa/mcp-mysql