PostgreSQL Performance (read Only) logo

PostgreSQL Performance (read Only)

Read-only MCP diagnostics for PostgreSQL slow queries, plans, indexes, locks, table health, and database functions.

Install PostgreSQL Performance (read Only)

Run the project’s own setup commands, in order.

Setup steps from the project

PostgreSQL Performance (read-only) installs with its own steps rather than a config we can generate, so these are copied as-is. Follow them in order and run the commands in a terminal. Source: github.com

  1. 1. Start the server
    docker compose up
    
  2. 2. Install
    docker pull ghcr.io/gouranshul/pg-perf-mcp:0.1.0
    
  3. 3. Install
    cat > pg-perf.env <<'EOF'
    PGPERF_DB_URL=jdbc:postgresql://host.docker.internal:5432/mydb
    PGPERF_DB_USER=mcp_readonly
    PGPERF_DB_PASSWORD=<the role's password>
    MCP_API_KEY=<32+ random characters>
    EOF
    
  4. 4. Start the server
    docker run --rm --env-file pg-perf.env -p 127.0.0.1:8080:8080 ghcr.io/gouranshul/pg-perf-mcp:0.1.0
    
  5. 5. Install
    git clone https://github.com/gouranshul/pg-perf-mcp && cd pg-perf-mcp
    
  6. 6. Configure
    cp .env.example .env        # then replace the placeholder secrets
    

Overview

PostgreSQL Performance (read-only) MCP server exposes PostgreSQL performance diagnostics through MCP tools, resources, and a guided troubleshooting prompt. It reads statistics, execution plans, catalogs, and lock data to analyze slow queries, index opportunities, table health, blocking sessions, and functions. Every call is guarded, run in a read-only transaction, capped, and rolled back, so it cannot modify data, execute DDL, create indexes, or terminate sessions. Use it when an AI assistant needs database-specific evidence instead of guessing from pasted SQL.

Use cases

  • Find statements consuming the most PostgreSQL execution time
  • Inspect an execution plan for scans, misestimates, and spills
  • Review hypothetical index recommendations without changing the database
  • Identify blocking sessions and root blockers
  • Diagnose slow work performed inside database functions

Key features

  • Read-only PostgreSQL performance diagnostics
  • Slow query and execution-plan analysis
  • Index recommendation and unused-index reporting
  • Table health and lock contention inspection
  • Database function timing and nested-plan analysis
  • Schema resources and guided diagnosis prompt

Tools8

What PostgreSQL Performance (read Only) lets your agent do. Expand a tool for its parameters.

Self-reported~399 tokens of context

Security & health

What it can reach and how reliably it runs — from our own checks, not the maintainer’s claims.

ActiveLast checked

Recent health check succeeded.

12/12 checks healthy over the last 48d

Adoption & maintenance

Factual signals from GitHub, npm, and our automated checks — not a rating.

Last commit12d agoMost recent push to the default branch.
Tools exposed8Callable tools this server registers over MCP.
Directory activity1 viewsConfig copies, upvotes, and views on AllMCPs.

How PostgreSQL Performance (read Only) works

What PostgreSQL Performance (read-only) does

PostgreSQL Performance (read-only) MCP server gives AI assistants a controlled interface for investigating PostgreSQL performance. It gathers data from pg_stat_statements, PostgreSQL catalogs, execution plans, lock views, and function statistics. The server is intended for diagnosis rather than remediation: it can recommend an index or report a blocking session, but it does not apply changes, drop indexes, cancel sessions, or terminate backends.

The server also exposes two schema resources. pg://schema/overview reports table estimates, sizes, and indexes, while pg://schema/{table} returns columns, indexes with scan counts, and foreign keys that lack indexes. The diagnose_slow_database prompt provides a staged investigation covering queries, plans, indexes, table condition, functions, and a prioritized conclusion.

How it works

Requests arrive over MCP using streamable HTTP and bearer-key authorization. Tool execution passes through an SQL guard, an audited runner, and a read-only PostgreSQL executor. The guard accepts one plain SELECT and rejects writes, DDL, multiple statements, data-changing CTEs, locking clauses, dangerous functions, and other unsafe constructs.

Each operation runs in a read-only transaction with statement and lock timeouts, then rolls back. Results are limited to a default maximum of 200 rows. The connection role is expected to have monitoring and statistics access, including pg_read_all_stats or pg_monitor as described by the project. Audit records store a hash and short preview of SQL rather than the complete statement, and errors omit stack traces and connection details.

For function analysis, the server can enable auto_explain only within the current transaction. It combines transaction-level function statistics with statement statistics to show time spent inside nested function statements and identify patterns such as a function executed once per result row.

Tools and capabilities

The PostgreSQL Performance (read-only) MCP server provides these tools:

  • top_slow_queries ranks statements by total time, mean time, calls, or rows and includes execution, cache, and workload-share metrics.
  • explain_query summarizes costly plan nodes, large sequential scans, row-estimate errors, disk spills, and expensive nested loops. Optional analysis adds measured timings.
  • suggest_indexes proposes index candidates from scans, joins, and ordering patterns. When hypopg is available, hypothetical indexes can be used to compare planner estimates; no index is created.
  • unused_indexes lists zero-scan indexes while excluding primary, unique, and constraint indexes, and supplies a drop statement for review only.
  • table_health reports tuple condition, vacuum and analyze history, table sizes, and sequential versus index scans.
  • blocking_sessions identifies blocked and blocking pairs, wait information, lock details, blocker state, and root blockers.
  • slow_functions ranks user-defined functions using PostgreSQL function statistics and includes language and volatility.
  • explain_function inspects statements executed within called functions, their plans, timing, and related findings.

Setup and configuration

The documented architecture connects the MCP service to PostgreSQL through a read-only role and expects PostgreSQL statistics features such as pg_stat_statements. Function diagnostics require track_functions. Hypothetical index validation requires the optional hypopg extension. The project identifies PostgreSQL 18, Java 25, and Spring Boot 4.1 in its repository badges.

The service is shown communicating with clients through streamable HTTP and a bearer API key.

Limitations and notes

Results depend on the statistics and extensions available in the target database. explain_query uses generic plans for $1 placeholders, and analyzed plans run under the same timeout and rollback protections. Function analysis cannot successfully inspect functions that write because execution remains read-only. Recommendations are review material: index creation, index removal, vacuum changes, and session termination must be performed separately by an authorized operator.

Written by AllMCPs with AI assistance from the project’s README and listing data. How we build listings

Reviews

No reviews yet — be the first to share how it worked for you.

Frequently Asked Questions about PostgreSQL Performance (read Only)

PostgreSQL Performance (read-only) is an MCP server that connects AI assistants to PostgreSQL for safe performance diagnosis. Its main tools inspect slow queries, explain plans, index recommendations, unused indexes, table health, blocking sessions, slow functions, and function internals without executing writes or DDL.

It shows the server running over streamable HTTP with bearer-key authorization and connecting to PostgreSQL through a read-only role, so consult the repository for deployment and configuration instructions.

No, it cannot create or drop indexes. The index tools return recommendations, and hypothetical indexes may be used for planner estimates when `hypopg` is installed, but changes are never executed.

The architecture also names Claude Desktop as an MCP client, with communication occurring over streamable HTTP.

It is designed around a read-only PostgreSQL role with `SELECT` and monitoring access such as `pg_read_all_stats` or `pg_monitor`. The role also uses read-only transaction defaults and timeouts; exact grants and configuration should be verified in the repository.

Related MCP servers

Add a badge to your READMEShow it’s listed — live SVG, Markdown or HTML.

AllMCPs Directory Badge

Full Badge Customizer

Showcase your server listing on GitHub or your project documentation. Embed this dynamic SVG badge to highlight official listing status and live engagement.

Badge Style:
Live Dynamic SVG PreviewPostgreSQL Performance (read Only) AllMCPs Directory Badge
Markdown (GitHub README)
[![AllMCPs](https://allmcps.com/api/badge/postgresql-performance-read-only?style=directory)](https://allmcps.com/mcp/postgresql-performance-read-only)
HTML Embed
<a href="https://allmcps.com/mcp/postgresql-performance-read-only"><img src="https://allmcps.com/api/badge/postgresql-performance-read-only?style=directory" alt="PostgreSQL Performance (read Only) on AllMCPs" /></a>