Skip to content
isdaniel avatar

PostgreSQL performance Tuner MCP Server

isdaniel/pgtuner_mcp

AI-assisted PostgreSQL tuning over a live database: slow queries, plans, indexes, bloat, and health.

CCM score
78 of 100
GitHub stars
31
tools
16
transport
STDIO
last updated
Dec 13, 2025
View on GitHub

Own this MCP server? Claim it

What it does

  • Reads performance data with get_slow_queries, analyze_query, get_table_stats, and analyze_disk_io_patterns, plus get_active_queries and analyze_wait_events for live sessions
  • Recommends and tests indexes with get_index_recommendations, explain_with_indexes, and manage_hypothetical_indexes via HypoPG, and flags cleanup candidates with find_unused_indexes
  • Requires a PostgreSQL user with pg_stat_statements, pgstattuple, and HypoPG privileges, configured through the DATABASE_URI environment variable
  • Designed for DBAs and developers who want guided tuning, bloat checks, and vacuum monitoring without writing the diagnostic queries by hand

Tools

16 tools

Public tool metadata for what this MCP can expose to an agent.

get_slow_queriesRetrieve slow queries from pg_stat_statements with detailed stats (total time, mean time, calls, cache hit ratio). Excludes system catalog queries.

Retrieve slow queries from pg_stat_statements with detailed stats (total time, mean time, calls, cache hit ratio). Excludes system catalog queries.

No parameter schema in public metadata yet.

analyze_queryAnalyze a query's execution plan with EXPLAIN ANALYZE, including automated issue detection

Analyze a query's execution plan with EXPLAIN ANALYZE, including automated issue detection

No parameter schema in public metadata yet.

get_table_statsGet detailed table statistics including size, row counts, dead tuples, and access patterns

Get detailed table statistics including size, row counts, dead tuples, and access patterns

No parameter schema in public metadata yet.

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).

Analyze 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).

No parameter schema in public metadata yet.

get_index_recommendationsAI-powered index recommendations based on query workload analysis

AI-powered index recommendations based on query workload analysis

No parameter schema in public metadata yet.

explain_with_indexesRun EXPLAIN with hypothetical indexes to test improvements without creating real indexes

Run EXPLAIN with hypothetical indexes to test improvements without creating real indexes

No parameter schema in public metadata yet.

manage_hypothetical_indexesCreate, list, drop, or reset HypoPG hypothetical indexes. Supports hide/unhide existing indexes.

Create, list, drop, or reset HypoPG hypothetical indexes. Supports hide/unhide existing indexes.

No parameter schema in public metadata yet.

find_unused_indexesFind unused and duplicate indexes that can be safely dropped

Find unused and duplicate indexes that can be safely dropped

No parameter schema in public metadata yet.

check_database_healthComprehensive health check with scoring (connections, cache, locks, replication, wraparound, disk, checkpoints)

Comprehensive health check with scoring (connections, cache, locks, replication, wraparound, disk, checkpoints)

No parameter schema in public metadata yet.

get_active_queriesMonitor active queries, find long-running transactions and blocked queries. By default excludes system processes.

Monitor active queries, find long-running transactions and blocked queries. By default excludes system processes.

No parameter schema in public metadata yet.

analyze_wait_eventsAnalyze wait events to identify I/O, lock, or CPU bottlenecks. Focuses on client backend processes.

Analyze wait events to identify I/O, lock, or CPU bottlenecks. Focuses on client backend processes.

No parameter schema in public metadata yet.

review_settingsReview PostgreSQL settings by category with optimization recommendations

Review PostgreSQL settings by category with optimization recommendations

No parameter schema in public metadata yet.

analyze_table_bloatAnalyze table bloat using pgstattuple extension. Shows dead tuple counts, free space, and wasted space percentage.

Analyze table bloat using pgstattuple extension. Shows dead tuple counts, free space, and wasted space percentage.

No parameter schema in public metadata yet.

analyze_index_bloatAnalyze B-tree index bloat using pgstatindex. Shows leaf density, fragmentation, and empty/deleted pages. Also supports GIN and Hash indexes.

Analyze B-tree index bloat using pgstatindex. Shows leaf density, fragmentation, and empty/deleted pages. Also supports GIN and Hash indexes.

No parameter schema in public metadata yet.

get_bloat_summaryGet a comprehensive overview of database bloat with top bloated tables/indexes, total reclaimable space, and priority maintenance actions.

Get a comprehensive overview of database bloat with top bloated tables/indexes, total reclaimable space, and priority maintenance actions.

No parameter schema in public metadata yet.

monitor_vacuum_progressTrack manual VACUUM, VACUUM FULL, and autovacuum operations. Monitor progress percentage, dead tuples collected, index vacuum rounds, and estimated time remaining. Includes autovacuum configuration review and tables needing maintenance.

Track manual VACUUM, VACUUM FULL, and autovacuum operations. Monitor progress percentage, dead tuples collected, index vacuum rounds, and estimated time remaining. Includes autovacuum configuration review and tables needing maintenance.

No parameter schema in public metadata yet.

Readme

PostgreSQL Performance Tuning MCP

PyPI - Version PyPI - Downloads Python 3.10+ Pepy Total Downloads Docker Pulls

badge

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.

Features


View the full README on GitHub

Details

Repository
github.com/isdaniel/pgtuner_mcp
Categories
Databases, Monitoring & Observability
Package
pgtuner-mcp
Transport
STDIO
Registry
MCP registry, active

More from isdaniel

All 2

Similar to PostgreSQL performance Tuner MCP Server

More Databases