sql-performance-mcp
SQL performance analysis MCP server for MySQL, PostgreSQL, and SQL Server.
The workflow is:
- User provides a SQL statement.
- The model calls
get_execution_planto fetch the 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 the database-appropriate execution plan command for a single SQL statement.
Arguments:
sql: SQL statement to inspect.database: optional database name. If omitted, the matching environment variable is used.database_type: optional database type. Supported values aremysql,postgresql, andsqlserver.
get_table_schema
Reads column metadata from the database's catalog views.
Arguments:
sql: SQL statement to inspect.database: optional database name.tables: optional explicit table list, useful for complex SQL where table extraction is ambiguous.database_type: optional database type.
get_indexes
Reads index metadata from the database's catalog views.
Arguments:
sql: SQL statement to inspect.database: optional database name.tables: optional explicit table list.database_type: optional database type.
analyze_performance
Builds a database-specific performance analysis prompt from:
sqlexecution_planschemaindexes
Configuration
Set database 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"
PostgreSQL:
$env:POSTGRES_HOST = "127.0.0.1"
$env:POSTGRES_PORT = "5432"
$env:POSTGRES_USER = "postgres"
$env:POSTGRES_PASSWORD = "password"
$env:POSTGRES_DATABASE = "app_db"
SQL Server:
$env:SQLSERVER_HOST = "127.0.0.1"
$env:SQLSERVER_PORT = "1433"
$env:SQLSERVER_USER = "sa"
$env:SQLSERVER_PASSWORD = "password"
$env:SQLSERVER_DATABASE = "app_db"
Optional:
$env:SQL_PERFORMANCE_DB_TYPE = "mysql"
$env:POSTGRES_CONNECT_TIMEOUT = "10"
$env:SQLSERVER_DRIVER = "ODBC Driver 18 for SQL Server"
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
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. - For SQL Server and PostgreSQL, use
database_typewhen the default environment setting is not enough.
Metadata
Release files for sql-performance-mcp 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| sql_performance_mcp-0.2.1.tar.gz | 13.9 kB | Without provenance | Details for sql_performance_mcp-0.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sql_performance_mcp-0.2.1-py3-none-any.whl | Python 3 | none | any | Details for sql_performance_mcp-0.2.1-py3-none-any.whl |
Total release size: 28.7 kB
Release files / sql_performance_mcp-0.2.1.tar.gz
| Download URL | sql_performance_mcp-0.2.1.tar.gz |
|---|---|
| Size | 13.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
314e2f45146c512545c4cc3a12fd562147d7bd602592446d8711c95be12ff945
|
|
BLAKE2b-256 checksum How to use checksums |
54e7cbc1151ce668f46f17bee2554ee189de79db5b0533a081d66cb3308996ff
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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}
|
Release files / sql_performance_mcp-0.2.1-py3-none-any.whl
| Download URL | sql_performance_mcp-0.2.1-py3-none-any.whl |
|---|---|
| Size | 14.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8be190c4d15f579e599ba55f931b39dcfc6c87c530336b999e7bfda25474a6f1
|
|
BLAKE2b-256 checksum How to use checksums |
722097fa7e248870d91761af617cce3b32a0d0eed8f410ed58f46816fea4426f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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}
|
Security for sql-performance-mcp 0.2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.