isdaniel avatar

PostgreSQL performance Tuner MCP Server

isdaniel/pgtuner_mcp

Connects Claude to your PostgreSQL database through pg_stat_statements and HypoPG to surface slow queries, analyze execution plans, and recommend indexes without touching disk. You get tools for pulling workload stats, testing hypothetical indexes, checking cache hit ratios, monitoring vacuum progress, and analyzing I/O patterns across tables. It also ships with health scoring that checks connection utilization, lock contention, and autovacuum effectiveness. Useful when you're tuning queries interactively and want to ask Claude to explain why a sequential scan is happening or whether a proposed index would actually help. Requires pg_read_all_stats role and expects DATABASE_URI as an environment variable.

GitHub stars
24
tools
16
transport
STDIO
last updated
Dec 13, 2025

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.

Sponsors

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
Category
Databases
Package
pgtuner-mcp
Transport
STDIO
Registry
MCP registry, active

More from isdaniel

Related Databases MCP servers

View all
1sidd27 avatarInfrawisesidd27/infrawiseLive AWS, database & Kafka infrastructure context for AI coding assistants via MCP.22stars
2devopam avatarMcpgdevopam/mcpgProduction-grade PostgreSQL MCP server — 279 tools for query, tuning & ops, read-only by default.0stars
3snss10 avatarDBeast PostgreSQL MCPsnss10/dbeastPostgreSQL MCP server for schema, query, health, security, and performance analysis.9stars
4mkpvishnu avatarTerminal Mcpmkpvishnu/terminal-mcpMCP server for interactive terminal sessions — SSH, REPLs, database CLIs, TUI apps7stars
5florentine-ai avatarMcpflorentine-ai/mcpMCP server for Florentine.ai - Natural language to MongoDB aggregations0stars
6letoribo avatarMcp Graphql Enhancedletoribo/mcp-graphql-enhancedGraphQL gateway for LLMs. Handles huge GitHub GraphQL & @neo4j/graphql schemas without crashing6stars