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 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_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
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.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
930cc31e7c3cebbb779a53b93d752ec750f27ccad95f7599c3e2558c845cfab5
|
|
| MD5 |
e9d2e9e90fd719c2d2c0d302c5cf8df2
|
|
| BLAKE2b-256 |
6b299c4a9a4722c2a1b33c5e6794d9ed1d4b7dc5c5d48ec590ebfa5b27ddbc1e
|
Provenance
The following attestation bundles were made for mysql_mcp_zag-1.0.0.tar.gz:
Publisher:
main.yml on Michaelzag/mysql_mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mysql_mcp_zag-1.0.0.tar.gz -
Subject digest:
930cc31e7c3cebbb779a53b93d752ec750f27ccad95f7599c3e2558c845cfab5 - Sigstore transparency entry: 435738372
- Sigstore integration time:
-
Permalink:
Michaelzag/mysql_mcp@1efe85dbb446fd2b029b3b5702946233c89209bb -
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@1efe85dbb446fd2b029b3b5702946233c89209bb -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8164780625bf1ee8fd361814b0027ce750be0f15964ec741abacb5b502452f32
|
|
| MD5 |
84360aa3aca48e94c673739934c6f5a5
|
|
| BLAKE2b-256 |
a11f782894c7acbd097a2219f767adcd2598eaaf3d71aec96f9ae41368be65e2
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mysql_mcp_zag-1.0.0-py3-none-any.whl -
Subject digest:
8164780625bf1ee8fd361814b0027ce750be0f15964ec741abacb5b502452f32 - Sigstore transparency entry: 435738388
- Sigstore integration time:
-
Permalink:
Michaelzag/mysql_mcp@1efe85dbb446fd2b029b3b5702946233c89209bb -
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@1efe85dbb446fd2b029b3b5702946233c89209bb -
Trigger Event:
push
-
Statement type: