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-zag.git
cd mysql-mcp-zag
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.1.0.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.1.0-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mysql_mcp_zag-1.1.0.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.1.0.tar.gz
Algorithm Hash digest
SHA256 f5df9cee4541cf3e5b2d67fef893992575ff0f23fcc409e55fa38fa7f9cd629f
MD5 95e744d8de8cc5d2fc6ffc568850b340
BLAKE2b-256 94107ed75f6f1715bb97dba9334039691294bfeda041137b1245847d75bae624

See more details on using hashes here.

Provenance

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

Publisher: main.yml on Michaelzag/mysql-mcp-zag

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.1.0-py3-none-any.whl.

File metadata

  • Download URL: mysql_mcp_zag-1.1.0-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.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a5b30d2f7a10ab86ccbdee2c53224f854c8aa6e09e6519317954a8035d6cf6d3
MD5 58d4c943146172e5e4f804c92bca646d
BLAKE2b-256 23c7ff867200092842c3769f7b536ecbb9e4f802b214c33583d784b5c04588e3

See more details on using hashes here.

Provenance

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

Publisher: main.yml on Michaelzag/mysql-mcp-zag

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