SuperAPI AI Directory

pgtuner_mcp

PostgreSQL performance tuning.

Open website

About this tool

pgtuner_mcp is a Model Context Protocol (MCP) server that provides AI-driven performance tuning capabilities for PostgreSQL, helping to identify slow queries, recommend optimal indexes, analyze execution plans, and perform hypothetical index testing with HypoPG.

Main capabilities: retrieve slow query statistics from pg_stat_statements; analyze execution plans with EXPLAIN and EXPLAIN ANALYZE and automatically locate bottlenecks; monitor active queries and long transactions; provide AI index recommendations based on query workload; perform hypothetical index testing with HypoPG without using disk space; find unused and duplicate indexes; estimate index sizes; test query plans with suggested indexes before implementation. It also provides database health scoring, connection utilization, cache hit ratio, lock contention, vacuum health and transaction ID wraparound, replication lag, background writer and checkpoint analysis; vacuum monitoring; I/O performance analysis (including pg_stat_io in PostgreSQL 16+); configuration analysis; and MCP prompt templates and resources.

Usage: supports standard MCP mode (default), HTTP SSE mode, and Streamable HTTP mode (recommended, endpoint /mcp, supporting stateful and stateless). The connection string format is postgresql://user:password@host:port/database. Minimal permissions required for the PostgreSQL user to query system catalogs and extensions must be configured; the PGTUNER_EXCLUDE_USERIDS environment variable can be used to exclude specific users. Requires PostgreSQL 12+ (14+ recommended), pg_stat_statements is required for query analysis, and hypopg is optional.

Limitations: HTTP mode does not include authentication and is only suitable for local use; network deployments must have a reverse proxy in front to handle authentication and TLS; it does not include Bearer/API key authentication, rate limiting, in-process TLS, or per-client tool allowlisting. All tools target only user/application tables and indexes, automatically excluding system catalog tables.