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

uv sync

Configuration

Set environment variables:

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

# Optional
export MYSQL_CERT=/path/to/cert.crt  # Supports .crt, .pem, and other SSL certificate formats
export MYSQL_CHARSET=utf8mb4

Usage

As MCP Server

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

{
  "mcpServers": {
    "mysql": {
      "command": "uv",
      "args": ["--directory", "/path/to/mysql-mcp", "run", "mysql_mcp_server"],
      "env": {
        "MYSQL_HOST": "localhost",
        "MYSQL_USER": "user",
        "MYSQL_PASSWORD": "password",
        "MYSQL_DATABASE": "database"
      }
    }
  }
}

Direct Usage

uv run mysql_mcp_server

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_server

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.0.tar.gz (49.1 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.0-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mysql_mcp_zag-1.0.0.tar.gz
  • Upload date:
  • Size: 49.1 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.0.tar.gz
Algorithm Hash digest
SHA256 930cc31e7c3cebbb779a53b93d752ec750f27ccad95f7599c3e2558c845cfab5
MD5 e9d2e9e90fd719c2d2c0d302c5cf8df2
BLAKE2b-256 6b299c4a9a4722c2a1b33c5e6794d9ed1d4b7dc5c5d48ec590ebfa5b27ddbc1e

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: mysql_mcp_zag-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 5.4 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8164780625bf1ee8fd361814b0027ce750be0f15964ec741abacb5b502452f32
MD5 84360aa3aca48e94c673739934c6f5a5
BLAKE2b-256 a11f782894c7acbd097a2219f767adcd2598eaaf3d71aec96f9ae41368be65e2

See more details on using hashes here.

Provenance

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