Multi-database SQL performance analysis MCP server
Project description
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.
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.2.1.tar.gz.
File metadata
- Download URL: sql_performance_mcp-0.2.1.tar.gz
- Upload date:
- Size: 13.9 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 |
314e2f45146c512545c4cc3a12fd562147d7bd602592446d8711c95be12ff945
|
|
| MD5 |
457a83f33b727fbfd616c04736e399b4
|
|
| BLAKE2b-256 |
54e7cbc1151ce668f46f17bee2554ee189de79db5b0533a081d66cb3308996ff
|
File details
Details for the file sql_performance_mcp-0.2.1-py3-none-any.whl.
File metadata
- Download URL: sql_performance_mcp-0.2.1-py3-none-any.whl
- Upload date:
- Size: 14.8 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 |
8be190c4d15f579e599ba55f931b39dcfc6c87c530336b999e7bfda25474a6f1
|
|
| MD5 |
e20e031f1710e7438f2a152b45bf15bd
|
|
| BLAKE2b-256 |
722097fa7e248870d91761af617cce3b32a0d0eed8f410ed58f46816fea4426f
|