Skip to main content
Glama
pg-perf-mcp

pg-perf-mcp

by dixitgurv

Server Configuration

Describes the environment variables required to run the server.

NameRequiredDescriptionDefault
PG_PERF_DSNYesPostgreSQL 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:

  1. database_overview to see cache hit rate, memory settings and connection load.

  2. slow_queries to find what costs the most time.

  3. explain_query on a suspect query: it returns the plan's hottest nodes and rule-based findings.

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

CapabilityDetails
tools
{
  "listChanged": false
}
prompts
{
  "listChanged": false
}
resources
{
  "subscribe": false,
  "listChanged": false
}

Tools

Functions exposed to the LLM to take actions

NameDescription
explain_queryA

Run EXPLAIN (ANALYZE, BUFFERS) on one SELECT query and diagnose the plan.

The query runs in a read-only transaction that is rolled back. Returns total time,
the nodes where time was actually spent, and findings such as wasteful sequential
scans, row misestimates, sorts spilling to disk and repeated nested-loop scans,
each with a suggested fix.

Args:
    sql: A single SELECT / WITH query.
    analyze_query: False shows the estimated plan without executing the query.
    timeout_ms: Abort the query after this many milliseconds.
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

NameDescription

No prompts

Resources

Contextual data attached and managed by the client

NameDescription

No resources

TDQS

B3.4/5.0

Scored across 7 tools

Disambiguation5/5

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.

Naming Consistency4/5

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.

Tool Count5/5

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.

Completeness4/5

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.