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.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.1.1-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mysql_mcp_zag-1.1.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.1.1.tar.gz
Algorithm Hash digest
SHA256 bb762c76a1478c0680bb3080a87e3bf9d61ef6a6f4d4a2966c9ffcab7d86ffe9
MD5 d2ed53fca57bb9a3ed3c0c1f5c5a5dac
BLAKE2b-256 71356d8a491760ae14958c21f16f8b9fca4c7ce133aa90b87dbf10e110616fef

See more details on using hashes here.

Provenance

The following attestation bundles were made for mysql_mcp_zag-1.1.1.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.1-py3-none-any.whl.

File metadata

  • Download URL: mysql_mcp_zag-1.1.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.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c5c2548ba621de20b0ee5670876b4e082d42f06d47205ed70c68924dfe5855cd
MD5 ff2cbc4ae9b063fb548946e27a4b21f6
BLAKE2b-256 966dcf62af6aa3966d5ba43d72548683e5d1445d11f6786414db203e38d2e0d4

See more details on using hashes here.

Provenance

The following attestation bundles were made for mysql_mcp_zag-1.1.1-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