Get the FREE Ultimate OpenClaw Setup Guide →

mcp -mysql

这是一款增强型MySQL MCP服务,专为 MySQL 数据库提供完善的只读访问能力。高性能的MCP服务能让大语言模型全面查看数据库结构,高效执行查询、分析,还具备更多高级特性。

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio chenlinyang-mcp-server-mysql node /full/path/to/mcp-server-mysql/dist/index.js \
  --env PATH="/path/to/node/bin:/usr/bin:/bin" \
  --env MYSQL_DB="your_database" \
  --env MYSQL_HOST="127.0.0.1" \
  --env MYSQL_PASS="your_password" \
  --env MYSQL_PORT="3306" \
  --env MYSQL_USER="root" \
  --env ALLOW_DDL_OPERATION="false" \
  --env MULTI_DB_WRITE_MODE="false" \
  --env ALLOW_DELETE_OPERATION="false" \
  --env ALLOW_INSERT_OPERATION="false" \
  --env ALLOW_UPDATE_OPERATION="false" \
  --env SCHEMA_DDL_PERMISSIONS="" \
  --env SCHEMA_DELETE_PERMISSIONS="" \
  --env SCHEMA_INSERT_PERMISSIONS="" \
  --env SCHEMA_UPDATE_PERMISSIONS="" \
  --env MYSQL_DISABLE_READ_ONLY_TRANSACTIONS="false"

How to use

This MCP server exposes a MySQL database access layer over SSH tunnels with Claude Code integration. It is designed to let Claude Code analyze your database schema, inspect tables, and safely run SQL queries against a configured MySQL instance. By default, write operations are disabled for safety; enable specific write permissions via the environment variables if you trust the model and need to modify data. The server supports per-database access control when MYSQL_DB is set, and includes SSH tunnel support for remote databases. To use it, configure Claude Code to start the MCP server (as shown in the README) and point Claude Code to the hosted MCP server entry, including the required environment variables for your database connection.

How to install

Prerequisites:

  • Node.js v20 or newer
  • npm or pnpm
  • Git
  • A running MySQL 5.7+ instance (MySQL 8.0+ recommended)
  1. Clone the repository:
git clone https://github.com/chenlinyang/mcp-server-mysql.git
cd mcp-server-mysql
  1. Install dependencies:
npm install
# or
pnpm install
  1. Build the project (if applicable):
npm run build
# or
pnpm run build
  1. Run locally to test (optional):
node dist/index.js
  1. Configure Claude Code to use the MCP server (example):
  • Global or per-project configuration as shown in the README. Example snippet:
{
  "mcpServers": {
    "mcp_server_mysql": {
      "command": "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",
        "MULTI_DB_WRITE_MODE": "false",
        "ALLOW_INSERT_OPERATION": "false",
        "ALLOW_UPDATE_OPERATION": "false",
        "ALLOW_DELETE_OPERATION": "false",
        "ALLOW_DDL_OPERATION": "false"
      }
    }
  }
}

Additional notes

Notes and tips:

  • For security, keep write operations disabled by default and only enable INSERT/UPDATE/DELETE when you explicitly require them and understand the risks.
  • If using a remote database, configure SSH tunneling as described in the repository's setup guide.
  • The MYSQL_DB setting enables strict per-database access, preventing cross-database queries.
  • Review and adapt the environment variable names to your deployment environment, especially any SSL, pool size, or timeout settings.
  • Ensure Claude Code is updated to the same MCP server interface version to avoid compatibility issues.

Related MCP Servers

Sponsor this space

Reach thousands of developers