Skip to main content

A modern MySQL Model Context Protocol (MCP) server built with FastMCP

Project description

MySQL MCP Server

A modern MySQL Model Context Protocol (MCP) server built with FastMCP.

Features

  • Execute SQL queries via MCP tools
  • Browse database tables and structure via MCP resources
  • SSL certificate support
  • Connection pooling and error handling
  • Full type safety with Python 3.13+

Installation

Using uvx (Recommended)

The easiest way to use MySQL MCP Server is with uvx:

uvx mysql-mcp-zag

From Source (Alternative)

If you prefer to install from source:

git clone https://github.com/MichaelZag/mysql_mcp.git
cd mysql_mcp
uv sync

Configuration

The MySQL MCP server accepts the following command line arguments:

Required Arguments

  • --user: MySQL username
  • --password: MySQL password
  • --database: MySQL database name

Optional Arguments

  • --host: MySQL server host (default: localhost)
  • --port: MySQL server port (default: 3306)
  • --ssl-ca: Path to SSL CA certificate file
  • --ssl-cert: Path to SSL client certificate file
  • --ssl-key: Path to SSL client private key file
  • --ssl-disabled: Disable SSL connection
  • --charset: Character set (default: utf8mb4)
  • --collation: Collation (default: utf8mb4_unicode_ci)
  • --sql-mode: SQL mode (default: TRADITIONAL)

SSL Configuration Examples

# Basic SSL with CA certificate
uvx mysql-mcp-zag --user admin --password secret --database mydb --ssl-ca /path/to/ca.pem

# Full SSL with client certificates
uvx mysql-mcp-zag --user admin --password secret --database mydb \
  --ssl-ca /path/to/ca.pem \
  --ssl-cert /path/to/client-cert.pem \
  --ssl-key /path/to/client-key.pem

# Disable SSL entirely
uvx mysql-mcp-zag --user admin --password secret --database mydb --ssl-disabled

Usage

As MCP Server

Configure in your MCP client (e.g., Claude Desktop):

Using uvx (Recommended)

{
  "mcpServers": {
    "mysql": {
      "command": "uvx",
      "args": [
        "mysql-mcp-zag",
        "--host", "localhost",
        "--user", "your_user",
        "--password", "your_password",
        "--database", "your_database"
      ]
    }
  }
}

Using local installation

{
  "mcpServers": {
    "mysql": {
      "command": "uv",
      "args": [
        "--directory", "/path/to/mysql-mcp",
        "run", "mysql-mcp",
        "--host", "localhost",
        "--user", "your_user",
        "--password", "your_password",
        "--database", "your_database"
      ]
    }
  }
}

Direct Usage

Using uvx

uvx mysql-mcp-zag --user your_user --password your_password --database your_database

Using local installation

uv run mysql-mcp --user your_user --password your_password --database your_database

Available Tools

  • execute_sql: Execute SQL queries

Available Resources

  • mysql://tables: List all tables
  • mysql://tables/{table}: Describe table structure

Development

# Run tests
uv run pytest

# Lint and format
uv run ruff check --fix src tests
uv run black src tests
uv run mypy src

# Run server locally
uv run mysql-mcp --user your_user --password your_password --database your_database

Requirements

  • Python 3.13+
  • MySQL server
  • UV package manager

Created by Michael Zag, Michael@MichaelZag.com

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mysql_mcp_zag-1.0.1.tar.gz (50.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mysql_mcp_zag-1.0.1-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file mysql_mcp_zag-1.0.1.tar.gz.

File metadata

  • Download URL: mysql_mcp_zag-1.0.1.tar.gz
  • Upload date:
  • Size: 50.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for mysql_mcp_zag-1.0.1.tar.gz
Algorithm Hash digest
SHA256 dd1111cf0b3ca7f95c1ff31d14a81f6b5bb55746e37fc3ed1a0f29f2a3aaadcf
MD5 8f06776bd5f5ef6082fb7cc84ee1a67e
BLAKE2b-256 787c94835b2db492732197047acef3a1efff6eb38df2656df9210be829c9dabc

See more details on using hashes here.

Provenance

The following attestation bundles were made for mysql_mcp_zag-1.0.1.tar.gz:

Publisher: main.yml on Michaelzag/mysql_mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mysql_mcp_zag-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: mysql_mcp_zag-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 6.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for mysql_mcp_zag-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f15fb3471ae898cc57c3f19f3dc09ec38aba532822eaa14627498594e8122ea9
MD5 f127381e82d02aa5f1b6e07b6fde607e
BLAKE2b-256 463e2115bbc09ab0a4f1bb5c40a2ea0aae6f3bac3057f2d09ea0c16fefd07f99

See more details on using hashes here.

Provenance

The following attestation bundles were made for mysql_mcp_zag-1.0.1-py3-none-any.whl:

Publisher: main.yml on Michaelzag/mysql_mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page