Skip to main content

MySQL SQL performance analysis MCP server

Project description

sql-performance-mcp

中文说明

MySQL SQL performance analysis MCP server.

The workflow is:

  1. User provides a SQL statement.
  2. The model calls get_execution_plan to fetch the MySQL execution plan.
  3. The model calls get_table_schema to fetch table columns.
  4. The model calls get_indexes to fetch table indexes.
  5. The model uses the analyze_performance prompt 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_DATABASE is 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:

  • sql
  • execution_plan
  • schema
  • indexes

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"

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_plan accepts one SQL statement only.
  • SQL table extraction covers common FROM, JOIN, UPDATE, and INSERT INTO patterns. For CTEs, nested SQL, or generated SQL, pass tables explicitly 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

sql_performance_mcp-0.1.0.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sql_performance_mcp-0.1.0-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

Details for the file sql_performance_mcp-0.1.0.tar.gz.

File metadata

  • Download URL: sql_performance_mcp-0.1.0.tar.gz
  • Upload date:
  • Size: 8.3 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

Hashes for sql_performance_mcp-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3ca50dfe87d6c9d58c080874bedd4342feaae4ffd72891873bc8aee6d320165d
MD5 de6efdda82fff32068702c48a47d46eb
BLAKE2b-256 b9b0e8cb4593a56a063bf3831458d41fab13a9a2680e46709b3eeefbe8eabab3

See more details on using hashes here.

File details

Details for the file sql_performance_mcp-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: sql_performance_mcp-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.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

Hashes for sql_performance_mcp-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 62b04da8320a30856aeccfb664b038393ce35ed440c1ce4a1364bbd8e6377336
MD5 1fe80fc16c6ae78590157a7de5446de0
BLAKE2b-256 e0a0d8e3f12e9835581289573140c57d396f784b7161e9e235c91e27b63f60c4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page