Get the FREE Ultimate OpenClaw Setup Guide →

mysql

🐬 MySQL MCP Server - A Model Context Protocol server for MySQL database operations with multi-connection support

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio guangyiding-mysql-mcp-server npx -y @nolimit35/mysql-mcp-server \
  --env LOG_LEVEL="INFO" \
  --env LOG_COLORS="true" \
  --env MYSQL_DANGER_MODE="false" \
  --env MYSQL_DATASOURCES="|dev|username:pass@192.168.xx.xx:3306/xxx;"

How to use

This MCP server provides a MySQL-focused set of tools to manage connections and interact with MySQL databases via the MCP protocol. It supports multiple named connections configured through the environment variable MYSQL_DATASOURCES, enabling you to connect, list, switch, and disconnect from several data sources. It also offers query execution and data-modification capabilities (with a safety mechanism called dangerousMode to prevent accidental changes), as well as utilities to list databases and tables, describe table structures, and view query execution plans. The included tools are designed to be used from Claude Code or via command-line configuration, allowing you to run SQL queries, perform inserts/updates/deletes (with explicit dangerous mode), and inspect schemas and performance plans across different connections.

To use it, configure one or more data sources via MYSQL_DATASOURCES in your environment, then use connect to establish a current active connection, followed by query or execute commands to run SQL statements. You can list databases, tables, and describe tables to understand your schema, and use explain to analyze queries. For multi-connection workflows, you can list_connections, switch_connection, and disconnect as needed to manage which data source is active for subsequent operations.

How to install

Prerequisites:

  • Node.js and npm installed on your system
  • Internet access to install packages

Install (recommended):

npm install -g @nolimit35/mysql-mcp-server

From source (build):

git clone https://github.com/GuangYiDing/mysql-mcp-server.git
cd mysql-mcp-server
npm install
npm run build

Usage notes:

  • You can run the MCP server directly after installation. The configuration in this README shows an npx-based setup that does not require a global install, but you can also run it via a local script if you prefer.
  • Ensure environment variables like MYSQL_DATASOURCES, MYSQL_DANGER_MODE, LOG_LEVEL, and LOG_COLORS are set as needed for your deployment.

Additional notes

Tips and common issues:

  • Data sources must be configured in MYSQL_DATASOURCES with the format: |name|username:password@host:port/database;|name2|username:password@host:port/database; ...
  • The first successfully connected data source becomes the current active connection automatically; you can switch between connections with switch_connection.
  • For modifying data (INSERT/UPDATE/DELETE, etc.), dangerousMode must be explicitly enabled (true); otherwise such operations will be rejected.
  • LOG_LEVEL controls verbosity (DEBUG, INFO, WARN, ERROR, OFF) and LOG_COLORS toggles colored output; adjust for development vs. production logs.
  • When using explain in JSON, TREE, or ANALYZE formats, ensure your MySQL version supports the requested features (TREE requires MySQL 8.0.16+; ANALYZE requires 8.0.18+ and will execute the query).
  • If you modify MYSQL_DATASOURCES, restart the service to apply changes.

Related MCP Servers

Sponsor this space

Reach thousands of developers