MCP Server for MySQL
MCP server that gives an agent access to MySQL: schema inspection and queries, read-only by default, writes behind flags
Medium risk
We rate an entry medium when the tool runs code, makes network calls or reads project files. Check what exactly it does before installing.
Why this level
- Connects to a database and runs SQL on the agent's request
- With write flags enabled it can modify and delete data
Install
In your terminal, with SkillFoxx CLI
npx skillfoxx add mcp/mcp-server-for-mysqlDetects the agents on your machine, checks the risk and pins the version.
Other ways to install
Run in a terminal
claude mcp add --transport stdio --env 'MYSQL_HOST=<MYSQL_HOST value>' --env 'MYSQL_PORT=<MYSQL_PORT value>' --env 'MYSQL_USER=<MYSQL_USER value>' --env 'MYSQL_PASS=<your MYSQL_PASS>' mcp_server_mysql -- npx -y @benborla29/mcp-server-mysqlOr add to the file .mcp.json, in the project
{
"mcpServers": {
"mcp_server_mysql": {
"command": "npx",
"args": [
"-y",
"@benborla29/mcp-server-mysql"
],
"env": {
"MYSQL_HOST": "<MYSQL_HOST value>",
"MYSQL_PORT": "<MYSQL_PORT value>",
"MYSQL_USER": "<MYSQL_USER value>",
"MYSQL_PASS": "<your MYSQL_PASS>"
}
}
}
}If the file already exists, add the server inside the mcpServers key.
Keys and settings
MYSQL_HOSTrequiredMYSQL_PORTrequiredMYSQL_USERrequiredMYSQL_PASSsecret, requiredMYSQL_DBoptional
Replace the values in angle brackets with your own. Keys never go into install links and are not stored by us.
The button opens the agent and offers to add the server. If nothing happens, copy the config below.
Add to the file ~/.cursor/mcp.json, for all projects
{
"mcpServers": {
"mcp_server_mysql": {
"command": "npx",
"args": [
"-y",
"@benborla29/mcp-server-mysql"
],
"env": {
"MYSQL_HOST": "<MYSQL_HOST value>",
"MYSQL_PORT": "<MYSQL_PORT value>",
"MYSQL_USER": "<MYSQL_USER value>",
"MYSQL_PASS": "<your MYSQL_PASS>"
}
}
}
}If the file already exists, add the server inside the mcpServers key. For a single project, put the same block into .cursor/mcp.json.
Keys and settings
MYSQL_HOSTrequiredMYSQL_PORTrequiredMYSQL_USERrequiredMYSQL_PASSsecret, requiredMYSQL_DBoptional
Replace the values in angle brackets with your own. Keys never go into install links and are not stored by us.
The button opens the agent and offers to add the server. If nothing happens, copy the config below.
Run in a terminal
code --add-mcp '{"name":"mcp_server_mysql","type":"stdio","command":"npx","args":["-y","@benborla29/mcp-server-mysql"],"env":{"MYSQL_HOST":"<MYSQL_HOST value>","MYSQL_PORT":"<MYSQL_PORT value>","MYSQL_USER":"<MYSQL_USER value>","MYSQL_PASS":"<your MYSQL_PASS>"}}'Or add to the file .vscode/mcp.json, in the project
{
"servers": {
"mcp_server_mysql": {
"type": "stdio",
"command": "npx",
"args": [
"-y",
"@benborla29/mcp-server-mysql"
],
"env": {
"MYSQL_HOST": "<MYSQL_HOST value>",
"MYSQL_PORT": "<MYSQL_PORT value>",
"MYSQL_USER": "<MYSQL_USER value>",
"MYSQL_PASS": "<your MYSQL_PASS>"
}
}
}
}If the file already exists, add the server inside the servers key.
Keys and settings
MYSQL_HOSTrequiredMYSQL_PORTrequiredMYSQL_USERrequiredMYSQL_PASSsecret, requiredMYSQL_DBoptional
Replace the values in angle brackets with your own. Keys never go into install links and are not stored by us.
Run in a terminal
codex mcp add mcp_server_mysql --env 'MYSQL_HOST=<MYSQL_HOST value>' --env 'MYSQL_PORT=<MYSQL_PORT value>' --env 'MYSQL_USER=<MYSQL_USER value>' --env 'MYSQL_PASS=<your MYSQL_PASS>' -- npx -y @benborla29/mcp-server-mysqlOr add to the file ~/.codex/config.toml, for all projects
[mcp_servers.mcp_server_mysql]
command = "npx"
args = ["-y", "@benborla29/mcp-server-mysql"]
env = { MYSQL_HOST = "<MYSQL_HOST value>", MYSQL_PORT = "<MYSQL_PORT value>", MYSQL_USER = "<MYSQL_USER value>", MYSQL_PASS = "<your MYSQL_PASS>" }If the file already exists, append the block to the end.
Keys and settings
MYSQL_HOSTrequiredMYSQL_PORTrequiredMYSQL_USERrequiredMYSQL_PASSsecret, requiredMYSQL_DBoptional
Replace the values in angle brackets with your own. Keys never go into install links and are not stored by us.
Add to the file ~/.gemini/settings.json, for all projects
{
"mcpServers": {
"mcp_server_mysql": {
"command": "npx",
"args": [
"-y",
"@benborla29/mcp-server-mysql"
],
"env": {
"MYSQL_HOST": "<MYSQL_HOST value>",
"MYSQL_PORT": "<MYSQL_PORT value>",
"MYSQL_USER": "<MYSQL_USER value>",
"MYSQL_PASS": "<your MYSQL_PASS>"
}
}
}
}If the file already exists, add the server inside the mcpServers key.
Keys and settings
MYSQL_HOSTrequiredMYSQL_PORTrequiredMYSQL_USERrequiredMYSQL_PASSsecret, requiredMYSQL_DBoptional
Replace the values in angle brackets with your own. Keys never go into install links and are not stored by us.
Add to the file ~/.config/devin/mcp_config.json, for all projects
{
"mcpServers": {
"mcp_server_mysql": {
"command": "npx",
"args": [
"-y",
"@benborla29/mcp-server-mysql"
],
"env": {
"MYSQL_HOST": "<MYSQL_HOST value>",
"MYSQL_PORT": "<MYSQL_PORT value>",
"MYSQL_USER": "<MYSQL_USER value>",
"MYSQL_PASS": "<your MYSQL_PASS>"
}
}
}
}If the file already exists, add the server inside the mcpServers key. Legacy Cascade keeps the MCP config in ~/.codeium/windsurf/mcp_config.json.
Keys and settings
MYSQL_HOSTrequiredMYSQL_PORTrequiredMYSQL_USERrequiredMYSQL_PASSsecret, requiredMYSQL_DBoptional
Replace the values in angle brackets with your own. Keys never go into install links and are not stored by us.
Formerly Windsurf.
Add to the file cline_mcp_settings.json, for all projects
{
"mcpServers": {
"mcp_server_mysql": {
"command": "npx",
"args": [
"-y",
"@benborla29/mcp-server-mysql"
],
"env": {
"MYSQL_HOST": "<MYSQL_HOST value>",
"MYSQL_PORT": "<MYSQL_PORT value>",
"MYSQL_USER": "<MYSQL_USER value>",
"MYSQL_PASS": "<your MYSQL_PASS>"
}
}
}
}If the file already exists, add the server inside the mcpServers key. Open the settings file in Cline: MCP Servers tab, Configure MCP Servers.
Keys and settings
MYSQL_HOSTrequiredMYSQL_PORTrequiredMYSQL_USERrequiredMYSQL_PASSsecret, requiredMYSQL_DBoptional
Replace the values in angle brackets with your own. Keys never go into install links and are not stored by us.
Add to the file .roo/mcp.json, in the project
{
"mcpServers": {
"mcp_server_mysql": {
"command": "npx",
"args": [
"-y",
"@benborla29/mcp-server-mysql"
],
"env": {
"MYSQL_HOST": "<MYSQL_HOST value>",
"MYSQL_PORT": "<MYSQL_PORT value>",
"MYSQL_USER": "<MYSQL_USER value>",
"MYSQL_PASS": "<your MYSQL_PASS>"
}
}
}
}If the file already exists, add the server inside the mcpServers key.
Keys and settings
MYSQL_HOSTrequiredMYSQL_PORTrequiredMYSQL_USERrequiredMYSQL_PASSsecret, requiredMYSQL_DBoptional
Replace the values in angle brackets with your own. Keys never go into install links and are not stored by us.
A fork of Roo Code, same .roo folders.
Add to the file opencode.json, in the project
{
"mcp": {
"mcp_server_mysql": {
"type": "local",
"command": [
"npx",
"-y",
"@benborla29/mcp-server-mysql"
],
"environment": {
"MYSQL_HOST": "<MYSQL_HOST value>",
"MYSQL_PORT": "<MYSQL_PORT value>",
"MYSQL_USER": "<MYSQL_USER value>",
"MYSQL_PASS": "<your MYSQL_PASS>"
}
}
}
}If the file already exists, add the server inside the mcp key.
Keys and settings
MYSQL_HOSTrequiredMYSQL_PORTrequiredMYSQL_USERrequiredMYSQL_PASSsecret, requiredMYSQL_DBoptional
Replace the values in angle brackets with your own. Keys never go into install links and are not stored by us.
Add to the file ~/.config/zed/settings.json, for all projects
{
"context_servers": {
"mcp_server_mysql": {
"command": "npx",
"args": [
"-y",
"@benborla29/mcp-server-mysql"
],
"env": {
"MYSQL_HOST": "<MYSQL_HOST value>",
"MYSQL_PORT": "<MYSQL_PORT value>",
"MYSQL_USER": "<MYSQL_USER value>",
"MYSQL_PASS": "<your MYSQL_PASS>"
}
}
}
}If the file already exists, add the server inside the context_servers key.
Keys and settings
MYSQL_HOSTrequiredMYSQL_PORTrequiredMYSQL_USERrequiredMYSQL_PASSsecret, requiredMYSQL_DBoptional
Replace the values in angle brackets with your own. Keys never go into install links and are not stored by us.
Add to the file .codeassistant/mcp.json, in the project
{
"mcpServers": {
"mcp_server_mysql": {
"command": "npx",
"args": [
"-y",
"@benborla29/mcp-server-mysql"
],
"env": {
"MYSQL_HOST": "<MYSQL_HOST value>",
"MYSQL_PORT": "<MYSQL_PORT value>",
"MYSQL_USER": "<MYSQL_USER value>",
"MYSQL_PASS": "<your MYSQL_PASS>"
}
}
}
}If the file already exists, add the server inside the mcpServers key.
Keys and settings
MYSQL_HOSTrequiredMYSQL_PORTrequiredMYSQL_USERrequiredMYSQL_PASSsecret, requiredMYSQL_DBoptional
Replace the values in angle brackets with your own. Keys never go into install links and are not stored by us.
Add the MySQL MCP server: claude mcp add mcp_server_mysql -e MYSQL_HOST="127.0.0.1" -e MYSQL_PORT="3306" -e MYSQL_USER="root" -e MYSQL_PASS="password" -e MYSQL_DB="db" -- npx @benborla29/mcp-server-mysql. Keep write operations disabled.
Other ways from the author
claude mcp add mcp_server_mysql \
-e MYSQL_HOST="127.0.0.1" \
-e MYSQL_PORT="3306" \
-e MYSQL_USER="root" \
-e MYSQL_PASS="your_password" \
-e MYSQL_DB="your_database" \
-- npx @benborla29/mcp-server-mysqlUse your own password; write flags are off by default.
This is third-party code. Review the repository files before installing.
What it does
The server connects an agent to a MySQL database over MCP. It exposes a tool that runs SQL and a resource that lists tables and column metadata, so the agent can read the schema and run selects without manual exports. Only read queries are available by default; insert, update and delete are enabled through separate environment variables. It adds a multi-database mode without reconnecting, per-database permissions, redaction of sensitive fields in results, SSH tunnel access and SSL with an mTLS option. Besides local stdio, it offers a remote HTTP mode with a bearer token.
Who it is for. For developers and analysts who want an agent to read and query MySQL directly from their editor or client.
Good fit when
- You want the agent to explore a schema and write or check SQL
- You want quick reads from MySQL without leaving the editor
- You need remote database access over an SSH tunnel or HTTP with a token
Not a fit when
- You need a database engine other than MySQL
- You cannot give the agent direct access to a production database
Example request
Show the database schema and count orders per month for the last yearLimitations
Requires Node.js 20+ and a MySQL account with suitable privileges. The password and connection settings are passed via environment variables. Write operations are off by default and are enabled with ALLOW_INSERT_OPERATION, ALLOW_UPDATE_OPERATION and ALLOW_DELETE_OPERATION; once on, the agent can change data, so use a least-privilege account and avoid production unless needed.
How to disable. Remove the mcp_server_mysql server from your client's MCP configuration, for example with claude mcp remove or by editing the mcpServers block.
MCP
- Transport
- stdio, http
- Authentication
- not required
| Environment variables | |
|---|---|
| MYSQL_HOST required | MySQL server host |
| MYSQL_PORT required | MySQL port, usually 3306 |
| MYSQL_USER required | Database user name |
| MYSQL_PASS required, secret | Database user password |
| MYSQL_DB | Database name, optional in multi-database mode |
| ALLOW_INSERT_OPERATION | Allow inserts, false by default |
| ALLOW_UPDATE_OPERATION | Allow updates, false by default |
| ALLOW_DELETE_OPERATION | Allow deletes, false by default |
Security check
- Connects to a database and runs SQL on the agent's request
- With write flags enabled it can modify and delete data
README in short
The README presents an MCP server that gives Claude and other LLMs access to MySQL: schema reads, queries and optional writes. It lists features: read-only by default, Claude Code integration, SSH tunnel, multi-database mode, per-database permissions, PII redaction, a remote HTTP mode and SSL with mTLS. It shows npx install commands for Claude Code and a config snippet for Claude Desktop and other clients. The mysql_query tool runs SQL and the mysql://tables resource lists tables. Separate docs cover installation, environment variables, multi-DB mode, redaction, testing and troubleshooting. MIT licensed.
FAQ
Can the agent change data?
Not by default; only reads are allowed. Insert, update and delete are enabled through the separate ALLOW_INSERT_OPERATION, ALLOW_UPDATE_OPERATION and ALLOW_DELETE_OPERATION variables.
How do I reach a remote database?
There is built-in SSH tunnel support plus a remote HTTP mode with a bearer token. See docs/INSTALLATION.md and docs/CONFIGURATION.md.
Related
166 skills for scientific work: bioinformatics, cheminformatics, clinical data, geospatial analysis and 100+ databases
Google's open-source MCP server for databases: ready tools for Postgres, MySQL, BigQuery, Spanner and more, plus custom tools in tools.yaml
Official Hugging Face skills: Hub operations via the hf CLI, datasets, model training, Spaces, evals and deployment
A visualization language for agents and an MCP server: neat charts from a simple semantic spec