Ben Borla
Built by Metorial, the integration platform for agentic AI.
Ben Borla
🚀 This is a modified version optimized for Claude Code with SSH tunnel support
Original Author: @benborla29
Original Repository: https://github.com/benborla/mcp-server-mysql
License: MIT
MYSQL_DISABLE_READ_ONLY_TRANSACTIONS for CREATE TABLE supportA Model Context Protocol server that provides access to MySQL databases through SSH tunnels. This server enables Claude and other LLMs to inspect database schemas and execute SQL queries securely.
There are several ways to install and configure the MCP server but the most common would be checking this website https://smithery.ai/server/@benborla29/mcp-server-mysql
For Cursor IDE, you can install this MCP server with the following command in your project:
MCP Get provides a centralized registry of MCP servers and simplifies the installation process.
Codex CLI installation is similar to Claude Code below
codex mcp add mcp_server_mysql \
--env MYSQL_HOST="127.0.0.1" \
--env MYSQL_PORT="3306" \
--env MYSQL_USER="root" \
--env MYSQL_PASS="your_password" \
--env MYSQL_DB="your_database" \
--env ALLOW_INSERT_OPERATION="false" \
--env ALLOW_UPDATE_OPERATION="false" \
--env ALLOW_DELETE_OPERATION="false" \
-- npx -y @benborla29/mcp-server-mysql
If you already have this MCP server configured in Claude Desktop, you can import it automatically:
claude mcp add-from-claude-desktop
This will show an interactive dialog where you can select your mcp_server_mysql server to import with all existing configuration.
Using NPM/PNPM Global Installation:
First, install the package globally:
# Using npm
npm install -g @benborla29/mcp-server-mysql
# Using pnpm
pnpm add -g @benborla29/mcp-server-mysql
Then add the server to Claude Code:
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" \
-e ALLOW_INSERT_OPERATION="false" \
-e ALLOW_UPDATE_OPERATION="false" \
-e ALLOW_DELETE_OPERATION="false" \
-- npx @benborla29/mcp-server-mysql
Using Local Repository (for development):
If you're running from a cloned repository:
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" \
-e ALLOW_INSERT_OPERATION="false" \
-e ALLOW_UPDATE_OPERATION="false" \
-e ALLOW_DELETE_OPERATION="false" \
-e PATH="/path/to/node/bin:/usr/bin:/bin" \
-e NODE_PATH="/path/to/node/lib/node_modules" \
-- /path/to/node /full/path/to/mcp-server-mysql/dist/index.js
Replace:
/path/to/node with your Node.js binary path (find with which node)/full/path/to/mcp-server-mysql with the full path to your cloned repositoryUsing Unix Socket Connection:
For local MySQL instances using Unix sockets:
claude mcp add mcp_server_mysql \
-e MYSQL_SOCKET_PATH="/tmp/mysql.sock" \
-e MYSQL_USER="root" \
-e MYSQL_PASS="your_password" \
-e MYSQL_DB="your_database" \
-e ALLOW_INSERT_OPERATION="false" \
-e ALLOW_UPDATE_OPERATION="false" \
-e ALLOW_DELETE_OPERATION="false" \
-- npx @benborla29/mcp-server-mysql
Consider which scope to use based on your needs:
# Local scope (default) - only available in current project
claude mcp add mcp_server_mysql [options...]
# User scope - available across all your projects
claude mcp add mcp_server_mysql -s user [options...]
# Project scope - shared with team members via .mcp.json
claude mcp add mcp_server_mysql -s project [options...]
For database servers with credentials, local or user scope is recommended to keep credentials private.
After adding the server, verify it's configured correctly:
# List all configured servers
claude mcp list
# Get details for your MySQL server
claude mcp get mcp_server_mysql
# Check server status within Claude Code
/mcp
For multi-database mode, omit the MYSQL_DB environment variable:
claude mcp add mcp_server_mysql_multi \
-e MYSQL_HOST="127.0.0.1" \
-e MYSQL_PORT="3306" \
-e MYSQL_USER="root" \
-e MYSQL_PASS="your_password" \
-e MULTI_DB_WRITE_MODE="false" \
-- npx @benborla29/mcp-server-mysql
For advanced features, add additional environment variables:
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" \
-e MYSQL_POOL_SIZE="10" \
-e MYSQL_QUERY_TIMEOUT="30000" \
-e MYSQL_CACHE_TTL="60000" \
-e MYSQL_RATE_LIMIT="100" \
-e MYSQL_SSL="true" \
-e ALLOW_INSERT_OPERATION="false" \
-e ALLOW_UPDATE_OPERATION="false" \
-e ALLOW_DELETE_OPERATION="false" \
-e MYSQL_ENABLE_LOGGING="true" \
-- npx @benborla29/mcp-server-mysql
Server Connection Issues: Use /mcp command in Claude Code to check server status and authenticate if needed.
Path Issues: If using a local repository, ensure Node.js paths are correctly set:
# Find your Node.js path
which node
# For PATH environment variable
echo "$(which node)/../"
# For NODE_PATH environment variable
echo "$(which node)/../../lib/node_modules"
Permission Errors: Ensure your MySQL user has appropriate permissions for the operations you've enabled.
Server Not Starting: Check Claude Code logs or run the server directly to debug:
# Test the server directly
npx @benborla29/mcp-server-mysql
For manual installation:
# Using npm
npm install -g @benborla29/mcp-server-mysql
# Using pnpm
pnpm add -g @benborla29/mcp-server-mysql
After manual installation, you'll need to configure your LLM application to use the MCP server (see Configuration section below).
If you want to clone and run this MCP server directly from the source code, follow these steps:
Clone the repository
git clone https://github.com/benborla/mcp-server-mysql.git
cd mcp-server-mysql
Install dependencies
npm install
# or
pnpm install
Build the project
npm run build
# or
pnpm run build
Configure Claude Desktop
Add the following to your Claude Desktop configuration file (claude_desktop_config.json):
{
"mcpServers": {
"mcp_server_mysql": {
"command": "/path/to/node",
"args": [
"/full/path/to/mcp-server-mysql/dist/index.js"
],
"env": {
"MYSQL_HOST": "127.0.0.1",
"MYSQL_PORT": "3306",
"MYSQL_USER": "root",
"MYSQL_PASS": "your_password",
"MYSQL_DB": "your_database",
"ALLOW_INSERT_OPERATION": "false",
"ALLOW_UPDATE_OPERATION": "false",
"ALLOW_DELETE_OPERATION": "false",
"PATH": "/path/to/node/bin:/usr/bin:/bin", //