Get the FREE Ultimate OpenClaw Setup Guide →

mcp -mysql

MCP Server for MySQL databases

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio yuru-sha-mcp-server-mysql docker run -i --rm mcp/mysql mysql://host:port/dbname

How to use

This MCP server provides read-only access to a MySQL database, exposing schema inspection capabilities and the ability to execute read-only queries within safe transactions. It is designed to be used by LLMs and client applications to understand database structures and to fetch data without risking data modification. The server is typically run via Docker or integrated into an orchestration workflow, and it can be configured under a named server like 'mysql' for easy reference in client configurations. Tools offered include database schema discovery (tables, columns, keys) and executing select queries against the target MySQL instance with read-only enforcement.

How to install

Prerequisites:

  • Docker installed and running
  • Optional: Node.js and npm if you plan to install via Smithery or npm package

Installation methods:

  1. Docker (recommended):

    • Build/run using Docker as shown in the repository examples:

      docker run -i --rm mcp/mysql mysql://host:port/dbname

    • Replace mysql://host:port/dbname with your actual connection URL.

  2. Smithery (Node ecosystem):

    • Install via Smithery to integrate with Claude Desktop or other clients:

      npx -y @smithery/cli install @yuru-sha/mcp-server-mysql --client claude

    • This will provision the server through Smithery for Claude Desktop usage.

  3. Direct npm package (if you prefer programmatic usage):

    • Install the npm package (example name used in this project):

      npm install @yuru-sha/mcp-server-mysql

    • Run according to your environment setup (node-based usage not shown here; see package docs).

Additional notes

Notes:

  • This server enforces read-only access; all queries are executed within READ ONLY transactions to protect the underlying database.
  • When using Docker on macOS, connect to the host environment via host.docker.internal if the MySQL server runs on the host network.
  • The provided connection URL should be in the form: mysql://[user][:password]@host[:port]/database, with /database replaced by the intended database name.
  • If you create a dedicated read-only user for production, configure authentication in the connection URL accordingly.
  • The npm package name for this server is @yuru-sha/mcp-server-mysql (if you use Node/npm workflows).
  • For Claude Desktop, add a mcpServers entry with the appropriate command and args to integrate with the UI.

Related MCP Servers

Sponsor this space

Reach thousands of developers