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"

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_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.1.tar.gz (8.8 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.1-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

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

Hashes for sql_performance_mcp-0.1.1.tar.gz
Algorithm Hash digest
SHA256 62aaf77ec84f472b514294d862b46f96aef19cbfafa63fa67b34f930d1ad4b56
MD5 189ed0af37e4ac0035ad53d9201db15d
BLAKE2b-256 c7876850bd2d4d8220f88d7d076b7491c84799f82860035a5a1f7cca7caf995c

See more details on using hashes here.

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

Hashes for sql_performance_mcp-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 19b3815f906a6ef1407d79f06a131565ab45b48a02e5b186533be60303eb98f1
MD5 dd865056efe1e37c544c924636257c99
BLAKE2b-256 8f25044ed4468ba87ba55bd0ca1cec426174ba8a98ba7872ae9f0c2f1cf63996

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