Back to MCP Directory
MySQL
Model Context Protocol moderate risk

MySQL

MySQL MCP Server provides a secure interface between AI applications and MySQL databases, enabling controlled data access and query execution.

Connections & Capabilities

Connects To

GitHubMySQL

Capabilities

readwriteexec

Quickstart

Install

pip install mysql-mcp-server

Config

{
  "mcpServers": {
    "mysql": {
      "command": "uv",
      "args": [
        "--directory",
        "path/to/mysql_mcp_server",
        "run",
        "mysql_mcp_server"
      ],
      "env": {
        "MYSQL_HOST": "localhost",
        "MYSQL_PORT": "3306",
        "MYSQL_USER": "your_username",
        "MYSQL_PASSWORD": "your_password",
        "MYSQL_DATABASE": "your_database"
      }
    }
  }
}

Exposed MCP Tools (3)

safe
list_tables

Lists available tables in the connected MySQL database.

Read-only operation that does not modify data.

safe
read_table

Reads the contents of a specified table.

Read-only operation; retrieves data without modification.

high
execute_query

Executes a provided SQL query against the database.

Can potentially modify or delete data, depending on the query.

Safety Assessment

This server is relatively safe for read operations and simple queries when properly configured with restricted user permissions. However, it becomes risky when executing complex or user-provided SQL queries without proper input validation and query whitelisting.

  • Uses environment variables for secure database credentials.
  • Provides logging for auditing database operations.
  • Suggests using a dedicated MySQL user with minimal permissions.
  • Offers error handling for SQL queries.
  • Executes arbitrary SQL queries, posing a risk of SQL injection if not carefully managed.
  • Requires careful configuration to avoid exposing sensitive data.
  • Relies on the user to implement query whitelisting.
  • Does not inherently sandbox SQL execution.