PostgreSQL Performance Tuner MCP Server

provides AI-powered PostgreSQL performance tuning capabilities.

Local serverstdioPython

What is the PostgreSQL Performance Tuner MCP Server?

provides AI-powered PostgreSQL performance tuning capabilities.

What you get

A Model Context Protocol (MCP) server that provides AI-powered PostgreSQL performance tuning capabilities. This server helps identify slow queries, recommend optimal indexes, analyze execution plans, and leverage HypoPG for hypothetical index testing.

More MCP options

Compare MCP servers by category, or browse hosted MCP servers if you prefer an endpoint over a local process.

Maintainer setup documentation.

Recorded tools

Check the linked publisher documentation and your connected client's tool list. Names and availability can vary with the server version and account permissions.

ToolWhat it does
get_slow_queriesRetrieve slow queries from pg_stat_statements with detailed stats (total time, mean time, calls, cache hit ratio). Excludes system catalog queries.
analyze_queryAnalyze a query's execution plan with EXPLAIN ANALYZE, including automated issue detection
get_table_statsGet detailed table statistics including size, row counts, dead tuples, and access patterns
analyze_disk_io_patternsAnalyze disk I/O read/write patterns, identify hot tables, buffer cache efficiency, and I/O bottlenecks. Supports filtering by analysis type (all, buffer_pool, tables, indexes, temp_files, checkpoints).
get_index_recommendationsAI-powered index recommendations based on query workload analysis
explain_with_indexesRun EXPLAIN with hypothetical indexes to test improvements without creating real indexes
manage_hypothetical_indexesCreate, list, drop, or reset HypoPG hypothetical indexes. Supports hide/unhide existing indexes.
find_unused_indexesFind unused and duplicate indexes that can be safely dropped
check_database_healthComprehensive health check with scoring (connections, cache, locks, replication, wraparound, disk, checkpoints)
get_active_queriesMonitor active queries, find long-running transactions and blocked queries. By default excludes system processes.
analyze_wait_eventsAnalyze wait events to identify I/O, lock, or CPU bottlenecks. Focuses on client backend processes.
review_settingsReview PostgreSQL settings by category with optimization recommendations
analyze_table_bloatAnalyze table bloat using pgstattuple extension. Shows dead tuple counts, free space, and wasted space percentage.
analyze_index_bloatAnalyze B-tree index bloat using pgstatindex. Shows leaf density, fragmentation, and empty/deleted pages. Also supports GIN and Hash indexes.

How to install the PostgreSQL Performance Tuner MCP Server

claude mcp add pgtuner --env DATABASE_URI=your-value --env PGTUNER_EXCLUDE_USERIDS=your-value -- uvx pgtuner_mcp

Configuration

VariableDescriptionRequired
DATABASE_URIConfiguration value read at startup.Optional
PGTUNER_EXCLUDE_USERIDSConfiguration value read at startup.Optional

Example prompts to try

  • “Use PostgreSQL Performance Tuner to get slow queries.”
  • “Use PostgreSQL Performance Tuner to analyze query.”
  • “Use PostgreSQL Performance Tuner to get table stats.”

Frequently asked questions

provides AI-powered PostgreSQL performance tuning capabilities. Confirm the tools offered by your installed version in the connected client. Tool availability and permissions depend on the server and account configuration.