pg-perf-mcp
Server Configuration
Describes the environment variables required to run the server.
| Name | Required | Description | Default |
|---|---|---|---|
| PG_PERF_DSN | Yes | PostgreSQL connection string (DSN) used by the server, e.g. postgresql://readonly@localhost/mydb. For production, connect as a role that has only pg_monitor and pg_read_all_data. |
Instructions
Guidance the server publishes about itself, which clients place ahead of the tool catalog so the model reads it before choosing anything.
Read-only PostgreSQL performance tools. A good order of work:
database_overview to see cache hit rate, memory settings and connection load.
slow_queries to find what costs the most time.
explain_query on a suspect query: it returns the plan's hottest nodes and rule-based findings.
table_health, unused_indexes and redundant_indexes for structural problems. Findings come from fixed rules in code. Explain them to the user and propose fixes, but present DDL as a suggestion to review, never as something already applied.
Capabilities
Features and capabilities supported by this server
Protocol revision2025-11-25
| Capability | Details |
|---|---|
| tools | {
"listChanged": false
} |
| prompts | {
"listChanged": false
} |
| resources | {
"subscribe": false,
"listChanged": false
} |
Tools
Functions exposed to the LLM to take actions
| Name | Description |
|---|---|
| explain_queryA | Run EXPLAIN (ANALYZE, BUFFERS) on one SELECT query and diagnose the plan. |
| slow_queriesB | Top queries from pg_stat_statements: total time, mean time, call count or disk reads. |
| table_healthC | Largest tables with seq-vs-index scan ratio, dead tuple share and last vacuum/analyze. |
| unused_indexesB | Non-unique indexes never used since stats were last reset, largest first. |
| redundant_indexesB | Indexes whose columns are a leading prefix of another index on the same table. |
| active_queriesB | Currently running queries with run time, transaction age and wait events. |
| database_overviewC | Cache hit rate, temp file usage, deadlocks, key memory settings and connection count. |
Prompts
Interactive templates invoked by user choice
| Name | Description |
|---|---|
No prompts | |
Resources
Contextual data attached and managed by the client
| Name | Description |
|---|---|
No resources | |
TDQS
Scored across 7 tools
Each tool targets a clearly distinct object: a single query plan (explain_query), historical stats (slow_queries), live activity (active_queries), table-level stats (table_health), index hygiene (unused_indexes vs redundant_indexes, clearly separated by 'never used' vs 'prefix duplicate'), and cluster-level stats (database_overview). No two tools can plausibly be confused for the same task.
All names are lowercase snake_case and uniformly descriptive, with no mixed conventions or stray prefixes. The only minor deviation is verb style: explain_query is verb_noun while the rest are adjective/noun phrases, but the pattern remains predictable.
Seven tools is tightly scoped to the performance-diagnostics domain, and each one covers a distinct angle (plan, history, live, table, index, cluster). Nothing looks like filler or a duplicate entry point.
Covers the core diagnostic loop: plan analysis, slow-query history, live activity, table health, index waste and instance overview. Minor gaps remain, such as explicit lock/blocking-chain analysis, missing-index recommendations (only unused/redundant are surfaced), and no write/DML plan analysis, but agents can work around these.