MySQL SQL performance analysis MCP server
Project description
sql-performance-mcp
MySQL SQL performance analysis MCP server.
The workflow is:
- User provides a SQL statement.
- The model calls
get_execution_planto fetch the MySQL execution plan. - The model calls
get_table_schemato fetch table columns. - The model calls
get_indexesto fetch table indexes. - The model uses the
analyze_performanceprompt to assemble the final analysis prompt.
Tools
get_execution_plan
Runs EXPLAIN FORMAT=JSON for a single SQL statement, with a fallback to plain EXPLAIN.
Arguments:
sql: SQL statement to inspect.database: optional MySQL database name. If omitted,MYSQL_DATABASEis used.
get_table_schema
Reads column metadata from information_schema.COLUMNS.
Arguments:
sql: SQL statement to inspect.database: optional MySQL database name.tables: optional explicit table list, useful for complex SQL where table extraction is ambiguous.
get_indexes
Reads index metadata from information_schema.STATISTICS.
Arguments:
sql: SQL statement to inspect.database: optional MySQL database name.tables: optional explicit table list.
analyze_performance
Builds a MySQL performance analysis prompt from:
sqlexecution_planschemaindexes
Configuration
Set MySQL connection settings with environment variables:
$env:MYSQL_HOST = "127.0.0.1"
$env:MYSQL_PORT = "3306"
$env:MYSQL_USER = "root"
$env:MYSQL_PASSWORD = "password"
$env:MYSQL_DATABASE = "app_db"
Optional:
$env:MYSQL_CHARSET = "utf8mb4"
$env:MYSQL_CONNECT_TIMEOUT = "10"
MCP Client Configuration
Use the published package from PyPI in your MCP client config:
{
"mcpServers": {
"sql-performance-mcp": {
"command": "uvx",
"args": ["sql-performance-mcp"],
"env": {
"MYSQL_HOST": "127.0.0.1",
"MYSQL_PORT": "3306",
"MYSQL_USER": "root",
"MYSQL_PASSWORD": "password",
"MYSQL_DATABASE": "app_db"
}
}
}
}
Run
Install dependencies:
uv sync
Run the MCP server:
uv run sql-performance-mcp
If you are not using uv, install from requirements.txt and run:
python -m sql_performance_mcp.server
Notes
- Only MySQL is implemented now.
get_execution_planaccepts one SQL statement only.- SQL table extraction covers common
FROM,JOIN,UPDATE, andINSERT INTOpatterns. For CTEs, nested SQL, or generated SQL, passtablesexplicitly to schema and index tools.
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 sql_performance_mcp-0.1.1.tar.gz.
File metadata
- Download URL: sql_performance_mcp-0.1.1.tar.gz
- Upload date:
- Size: 8.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.11 {"installer":{"name":"uv","version":"0.11.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
62aaf77ec84f472b514294d862b46f96aef19cbfafa63fa67b34f930d1ad4b56
|
|
| MD5 |
189ed0af37e4ac0035ad53d9201db15d
|
|
| BLAKE2b-256 |
c7876850bd2d4d8220f88d7d076b7491c84799f82860035a5a1f7cca7caf995c
|
File details
Details for the file sql_performance_mcp-0.1.1-py3-none-any.whl.
File metadata
- Download URL: sql_performance_mcp-0.1.1-py3-none-any.whl
- Upload date:
- Size: 8.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.11 {"installer":{"name":"uv","version":"0.11.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
19b3815f906a6ef1407d79f06a131565ab45b48a02e5b186533be60303eb98f1
|
|
| MD5 |
dd865056efe1e37c544c924636257c99
|
|
| BLAKE2b-256 |
8f25044ed4468ba87ba55bd0ca1cec426174ba8a98ba7872ae9f0c2f1cf63996
|