Get the FREE Ultimate OpenClaw Setup Guide →

mcp -mysql

MCP server from youngsu5582/mcp-server-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 youngsu5582-mcp-server-mysql uv --directory path/to/mysql_mcp_server run mysql_mcp_server \
  --env MYSQL_HOST="localhost" \
  --env MYSQL_PORT="3306" \
  --env MYSQL_USER="your_username" \
  --env MYSQL_DATABASE="your_database" \
  --env MYSQL_PASSWORD="your_password"

How to use

This MCP server exposes a controlled interface to a MySQL database, allowing AI assistants to list available tables, read data from tables, and execute SQL queries in a safe, auditable way. The server uses environment-based credentials to restrict access and provides comprehensive logging to help you monitor activity. You can integrate it with clients like Claude Desktop or your own tooling by pointing the MCP client at the configured server and passing the appropriate requests to perform read operations or run queries.

To use it, configure the CLI/IDE integration to launch the MCP server as shown in the example configuration. The server is started via the uv runner, with environment variables set to the database credentials. Ensure the MySQL user has the minimal permissions required for the operations you intend (listing tables, reading data, and executing allowed queries). After startup, you can issue MCP requests to discover tables, read rows, and submit parameterized SQL queries through the MCP protocol.

How to install

Prerequisites:

  • Python environment (recommended: Python 3.8+)
  • pip (Python package manager)
  • Access to a MySQL server (host, port, user, password, database)

Install the MCP package from PyPI:

pip install mysql-mcp-server

Configure environment variables (example):

export MYSQL_HOST=localhost
export MYSQL_PORT=3306
export MYSQL_USER=your_username
export MYSQL_PASSWORD=your_password
export MYSQL_DATABASE=your_database

Run the MCP server via the UV-Runner (as shown in the README example):

uv --directory path/to/mysql_mcp_server run mysql_mcp_server

If you need to run locally without UV, ensure you adjust the command to suit your environment and verify the server starts without errors. You should see logs indicating connection to MySQL and readiness to serve MCP requests.

Additional notes

Tips and caveats:

  • Do not commit or expose environment variables containing credentials; use a secrets manager or environment management in production.
  • Grant the MySQL user only the permissions strictly needed for MCP operations (read, select, and any whitelisted write operations).
  • Enable and monitor logs for all database operations to aid auditing and debugging.
  • If you rotate credentials, restart the MCP server to pick up changes.
  • Ensure network access between the MCP server host and the MySQL server is allowed (firewalls, allowed IPs, etc.).

Related MCP Servers

Sponsor this space

Reach thousands of developers