provides AI-powered PostgreSQL performance tuning capabilities.
PostgreSQL Performance Tuner MCP server exists for a simple reason — assistants are far more useful when they can act on PostgreSQL Performance Tuner directly instead of describing what you should do. provides AI-powered PostgreSQL performance tuning capabilities.
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.
Installation goes through your MCP client rather than a global install: point it at pgtuner_mcp on PyPI and it is fetched when the client starts. The copy-paste blocks for Claude Desktop, Claude Code and Cursor are further down this page.
Once PostgreSQL Performance Tuner is connected, these are the calls the assistant has available:
get_slow_queries — Retrieve slow queries from pg_stat_statements with detailed stats (total time, mean time, calls, cache hit ratio). Excludes system catalog queriesanalyze_query — Analyze a query's execution plan with EXPLAIN ANALYZE, including automated issue detectionget_table_stats — Get detailed table statistics including size, row counts, dead tuples, and access patternsanalyze_disk_io_patterns — Analyze disk I/O read/write patterns, identify hot tables, buffer cache efficiency, and I/O bottlenecks. Supports filtering by analysis type (allget_index_recommendations — AI-powered index recommendations based on query workload analysisexplain_with_indexes — Run EXPLAIN with hypothetical indexes to test improvements without creating real indexesmanage_hypothetical_indexes — Create, list, drop, or reset HypoPG hypothetical indexes. Supports hide/unhide existing indexesfind_unused_indexes — Find unused and duplicate indexes that can be safely droppedcheck_database_health — Comprehensive health check with scoring (connections, cache, locks, replication, wraparound, disk, checkpoints)get_active_queries — Monitor active queries, find long-running transactions and blocked queries. By default excludes system processesanalyze_wait_events — Analyze wait events to identify I/O, lock, or CPU bottlenecks. Focuses on client backend processesreview_settings — Review PostgreSQL settings by category with optimization recommendationsYou will need 2 environment variables: DATABASE_URI, PGTUNER_EXCLUDE_USERIDS. Keep credentials in your client's env block or a secrets manager rather than in a file you might commit.
Among the database access options, the useful question is rarely "what can it do" but "what does it cost you to run" — permissions, credentials, and how much of your context its toolset consumes. PostgreSQL Performance Tuner's toolset — get_slow_queries, analyze_query, get_table_stats and 11 more — is a fair guide to whether it matches your workflow. It is maintained by isdaniel; worth a glance at recent repository activity before you build anything load-bearing on it.
SyncDev reviews every entry in this directory against the project's own documentation before publishing, and revisits them as servers change.
| Tool | What it does |
|---|---|
| get_slow_queries | Retrieve slow queries from pg_stat_statements with detailed stats (total time, mean time, calls, cache hit ratio). Excludes system catalog queries. |
| analyze_query | Analyze a query's execution plan with EXPLAIN ANALYZE, including automated issue detection |
| get_table_stats | Get detailed table statistics including size, row counts, dead tuples, and access patterns |
| analyze_disk_io_patterns | 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). |
| get_index_recommendations | AI-powered index recommendations based on query workload analysis |
| explain_with_indexes | Run EXPLAIN with hypothetical indexes to test improvements without creating real indexes |
| manage_hypothetical_indexes | Create, list, drop, or reset HypoPG hypothetical indexes. Supports hide/unhide existing indexes. |
| find_unused_indexes | Find unused and duplicate indexes that can be safely dropped |
| check_database_health | Comprehensive health check with scoring (connections, cache, locks, replication, wraparound, disk, checkpoints) |
| get_active_queries | Monitor active queries, find long-running transactions and blocked queries. By default excludes system processes. |
| analyze_wait_events | Analyze wait events to identify I/O, lock, or CPU bottlenecks. Focuses on client backend processes. |
| review_settings | Review PostgreSQL settings by category with optimization recommendations |
| analyze_table_bloat | Analyze table bloat using pgstattuple extension. Shows dead tuple counts, free space, and wasted space percentage. |
| analyze_index_bloat | Analyze B-tree index bloat using pgstatindex. Shows leaf density, fragmentation, and empty/deleted pages. Also supports GIN and Hash indexes. |
Or Streamable HTTP Mode
```json
{
"mcpServers": {
"pgtuner_mcp": {
"type": "http",
"url": "http://localhost:8080/mcp"
}
}
}Configuration as documented by the project. Restart the client after saving.
| Variable | Description | Required |
|---|---|---|
| DATABASE_URI | Configuration value read at startup. | Optional |
| PGTUNER_EXCLUDE_USERIDS | Configuration value read at startup. | Optional |
Read-only SQL access to Postgres — let your assistant inspect schemas and answer questions from real data.
Manage your whole Supabase project in conversation — database, auth, storage, Edge Functions and branches.
Query, modify and analyse local SQLite databases in conversation — the fastest way to chat with a data file.
Metabase ships its own MCP endpoint — search your BI content, build and run queries, and save questions and dashboards without leaving the chat.
Official MongoDB server covering data, schemas and Atlas management — from find queries to spinning up clusters.
Serverless Postgres with database branching — point your assistant at Neon and let it work on disposable copies.