Get the FREE Ultimate OpenClaw Setup Guide →

mysql

A server application designed on top of MCP to interact with Cursor and MySQL.

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio mineru98-mysql-mcp-server docker run -d --name mcp-mysql -e MYSQL_HOST=localhost -e MYSQL_PORT=3306 -e MYSQL_USER=root -e MYSQL_PASSWORD=mcpTest1234!!! -e MYSQL_DATABASE=mcp_test -e MCP_PORT=8081 -p 3306:3306 mineru/mcp-mysql:1.0.0 \
  --env MCP_PORT="8081" \
  --env MYSQL_HOST="localhost" \
  --env MYSQL_PORT="3306" \
  --env MYSQL_USER="root" \
  --env MYSQL_DATABASE="mcp_test" \
  --env MYSQL_PASSWORD="your-database-password"

How to use

This MCP server provides a set of tools to interact with a MySQL database via the Model Context Protocol. The server exposes executors such as create_table, desc_table, explain, insert_query, show_tables, and select_query, enabling an AI model to programmatically manage schema, inspect tables, run queries, and fetch results. Tools are registered and accessible through the MCP interface, allowing dynamic tool discovery and execution. To use it, connect to the MCP server (typically on port 8081 inside your deployment) and request the list of available tools, then issue tool-specific execution requests with the appropriate parameters. The architecture separates the AI-facing controller from the Executors (which perform actual database operations), ensuring a clean model-to-action workflow.

How to install

Prerequisites:

  • Docker (and Docker Compose if using docker-compose)
  • Access to a MySQL instance or the ability to run one in Docker
  • Basic familiarity with environment variables for database credentials

Option A: Docker

  1. Pull and run the server with the provided environment variables:

    docker run -d --name mcp-mysql
    -e MYSQL_HOST=localhost
    -e MYSQL_PORT=3306
    -e MYSQL_USER=root
    -e MYSQL_PASSWORD=mcpTest1234!!!
    -e MYSQL_DATABASE=mcp_test
    -e MCP_PORT=8081
    -p 3306:3306 mineru/mcp-mysql:1.0.0

  2. Ensure the MySQL instance is accessible at the configured host/port and that MCP_PORT (8081 by default) is reachable.

Option B: Docker Compose

  1. Use the pre-configured setup:

    docker-compose up -d

  2. The stack will start the MySQL database and the MCP server as defined in the compose file.

Option C: Python (development)

  1. Install dependencies:

    pip install -r requirements.txt

  2. Run the server:

    python mysql_mcp_server/main.py run

Note: Ensure .env contains the required credentials if using the Python setup.

Additional notes

Tips and considerations:

  • Keep database credentials secure. Use strong passwords in production and consider using a secrets manager.
  • The MCP tools include create_table, desc_table, explain, insert_query, show_tables, and select_query. Tools must be imported and registered in the server as described in the repository documentation.
  • If you modify tools, update the init.py exports so the TOOLS_DEFINITION set remains accurate.
  • For security, enable network-restriction or authentication on the MCP endpoint to prevent unauthorized access.
  • When running via Docker, ensure MySQL_HOST points to a reachable host (localhost may refer to the container itself; use host.docker.internal or an external hostname as needed).
  • Check logs via docker logs mcp-mysql or the equivalent Python process logs for troubleshooting.

Related MCP Servers

Sponsor this space

Reach thousands of developers