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 tablesmysql://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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f5df9cee4541cf3e5b2d67fef893992575ff0f23fcc409e55fa38fa7f9cd629f
|
|
| MD5 |
95e744d8de8cc5d2fc6ffc568850b340
|
|
| BLAKE2b-256 |
94107ed75f6f1715bb97dba9334039691294bfeda041137b1245847d75bae624
|
Provenance
The following attestation bundles were made for mysql_mcp_zag-1.1.0.tar.gz:
Publisher:
main.yml on Michaelzag/mysql-mcp-zag
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mysql_mcp_zag-1.1.0.tar.gz -
Subject digest:
f5df9cee4541cf3e5b2d67fef893992575ff0f23fcc409e55fa38fa7f9cd629f - Sigstore transparency entry: 435960535
- Sigstore integration time:
-
Permalink:
Michaelzag/mysql-mcp-zag@97b640af0ab31f2d1e1b7629f690fcd1c68f6444 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Michaelzag
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
main.yml@97b640af0ab31f2d1e1b7629f690fcd1c68f6444 -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a5b30d2f7a10ab86ccbdee2c53224f854c8aa6e09e6519317954a8035d6cf6d3
|
|
| MD5 |
58d4c943146172e5e4f804c92bca646d
|
|
| BLAKE2b-256 |
23c7ff867200092842c3769f7b536ecbb9e4f802b214c33583d784b5c04588e3
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mysql_mcp_zag-1.1.0-py3-none-any.whl -
Subject digest:
a5b30d2f7a10ab86ccbdee2c53224f854c8aa6e09e6519317954a8035d6cf6d3 - Sigstore transparency entry: 435960560
- Sigstore integration time:
-
Permalink:
Michaelzag/mysql-mcp-zag@97b640af0ab31f2d1e1b7629f690fcd1c68f6444 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Michaelzag
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
main.yml@97b640af0ab31f2d1e1b7629f690fcd1c68f6444 -
Trigger Event:
push
-
Statement type: