home / mcp / mcp server mysql

MCP Server MySQL

Provides an MCP server to access MySQL databases via SSH tunnels with controlled read/write capabilities.

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "benborla-mcp-server-mysql": {
      "command": "npx",
      "args": [
        "-y",
        "@benborla29/mcp-server-mysql"
      ],
      "env": {
        "PATH": "/path/to/node/bin:/usr/bin:/bin",
        "MYSQL_DB": "your_database",
        "NODE_PATH": "/path/to/node/lib/node_modules",
        "MYSQL_HOST": "127.0.0.1",
        "MYSQL_PASS": "your_password",
        "MYSQL_PORT": "3306",
        "MYSQL_USER": "root",
        "ALLOW_DELETE_OPERATION": "false",
        "ALLOW_INSERT_OPERATION": "false",
        "ALLOW_UPDATE_OPERATION": "false"
      }
    }
  }
}

You can run an MCP server that provides access to MySQL databases through SSH tunnels, allowing Claude Code and other clients to inspect schemas and run SQL securely and with controlled permissions.

How to use

Use the MCP server by adding it to your Claude Code setup or your MCP client, then point your client at the server URL or run it locally for test or development. You can operate in single-database mode by specifying a database, or enable multi-database access by leaving the database variable empty. Write permissions are opt-in and governed by explicit flags to protect your data.

How to install

Prerequisites you need before installing the MCP server:

          Additional setup options

          The MCP server supports multiple installation paths. You can install via a package manager, run from a local repository, or operate in remote mode. The following patterns are shown in practice in the setup examples.

          Configuration and usage notes

          You can start with a simple local test using an MCP command like the following to add the server to Claude Code and then run it with npx. You can also run the server directly from a local repository if you are developing.

          Environment and security considerations

          Control write permissions with explicit flags and keep credentials private by using local or user scope configurations. Enable read/write features only when you are prepared to manage the implications.

          Troubleshooting

          If you encounter connection issues, verify MySQL accessibility, validate credentials, and confirm that the required permissions are in place. When path issues occur, ensure Node.js and related binaries are in your PATH and NODE_PATH.

          Available tools

          mysql_query

          Execute SQL queries against the connected database. Supports prepared statements, optional write operations (when enabled), transactions, and query timeouts.