Pgtuner MCP logo

Pgtuner MCP

pgtuner_mcp MCP server analyzes PostgreSQL performance, queries, indexes, bloat, I/O, vacuum activity, and health.

Install Pgtuner MCP

Pick your client, then add it in one click or paste the config.

STDIOPython
~/Library/Application Support/Claude/claude_desktop_config.json
claude_desktop_config.json
{
  "mcpServers": {
    "pgtuner-mcp": {
      "command": "uvx",
      "args": [
        "pgtuner_mcp"
      ],
      "env": {
        "DATABASE_URI": "YOUR_VALUE_HERE"
      }
    }
  }
}

Settings → Developer → Edit Config, merge this into mcpServers, then fully quit and reopen Claude Desktop.

Values are written into the snippet above so you can paste it as is. They never leave your browser.

Claude Code command
claude mcp add --env DATABASE_URI=YOUR_VALUE_HERE --transport stdio pgtuner-mcp -- uvx pgtuner_mcp

Run in your terminal. Add --scope project to share it with your team through .mcp.json.

We couldn’t confirm it starts correctly

We ran the install command but it didn't respond within our test window — this can mean a slow first-time install rather than a real problem.

uvx pgtuner_mcp

No response to initialize.

This is an experimental automated check and can have false negatives — missing environment variables, a slow cold install, etc. It doesn’t necessarily mean something’s wrong. Last checked .

Overview

The pgtuner_mcp MCP server connects AI agents to PostgreSQL monitoring and tuning data through MCP tools. It inspects slow and active queries, execution plans, table and index statistics, wait events, disk I/O, configuration, bloat, vacuum activity, and overall database health. Reach for it when an agent needs read-oriented performance analysis or wants to test hypothetical indexes with HypoPG before making changes.

Use cases

  • Investigate slow PostgreSQL queries and execution plans
  • Recommend and test indexes with HypoPG
  • Monitor database health, locks, waits, and active sessions
  • Find table and index bloat requiring maintenance
  • Review vacuum progress and PostgreSQL settings

Key features

  • Slow-query and execution-plan analysis
  • Hypothetical index testing with HypoPG
  • Database health and active-query monitoring
  • Table, index, and bloat analysis
  • Disk I/O and wait-event diagnostics
  • Vacuum and configuration review

Tools16

What Pgtuner MCP lets your agent do. Expand a tool for its parameters.

Self-reported~543 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.

27/28 checks healthy over the last 117d

Supply-chain signal

No high-severity advisories surfaced by our automated scan.

Critical 0High 0Medium 0Low 0

Scanned 15d ago via OSV.dev · pgtuner_mcp (PyPI)

Adoption & maintenance

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

GitHub stars31Stargazers on the source repository.
Last commit6mo agoMost recent push to the default branch.
Install checkInconclusiveDidn't respond in our test window — often a slow first install.
Tools exposed16Callable tools this server registers over MCP.
Directory activity4 viewsConfig copies, upvotes, and views on AllMCPs.

How Pgtuner MCP works

What pgtuner_mcp MCP server does

The pgtuner_mcp MCP server gives an MCP client access to PostgreSQL performance diagnostics and tuning workflows. It reads statistics from PostgreSQL system views and supported extensions, then returns structured analysis for an AI agent to interpret. The tools cover query performance, index usage, table health, database status, configuration, I/O behavior, locking, and maintenance activity.

Query-oriented tools retrieve slow statements from pg_stat_statements, inspect active sessions, identify long-running transactions and blocked queries, and analyze execution plans with EXPLAIN ANALYZE. The server can also detect plan issues and produce index recommendations based on observed workload data.

How it works

The server uses a PostgreSQL connection string supplied through DATABASE_URI. Monitoring results normally exclude system processes, and slow-query collection excludes system catalog queries. A separate environment variable can exclude selected PostgreSQL user IDs from monitoring results.

HypoPG support lets agents create and inspect hypothetical indexes, compare query plans with those indexes, hide or unhide existing indexes, and reset the session’s hypothetical index state. These operations are session-scoped and do not create physical indexes in the database.

The database health checks examine connections, cache behavior, locks, replication, transaction ID wraparound, disk usage, checkpoints, and related indicators. I/O analysis can focus on buffer pools, tables, indexes, temporary files, or checkpoints. PostgreSQL 16 and later can provide enhanced pg_stat_io metrics.

Setup and configuration

Install the package with pip install pgtuner_mcp, use uv pip install pgtuner_mcp, or clone the repository and install it in editable mode.

Set DATABASE_URI to a PostgreSQL connection string such as postgresql://user:password@host:port/database. Optional settings control excluded user IDs, statement, idle-transaction, and lock timeouts, CORS origins, and disabled linter rules.

The monitoring account needs database and schema access, read access to application tables and statistics, and the pg_read_all_stats role for core functionality. pg_stat_statements is required for statement analysis. Bloat analysis uses pgstattuple, while hypothetical index features use hypopg; each extension requires its documented installation and grants.

Tools and capabilities

The pgtuner_mcp MCP server exposes tools for:

  • Retrieving slow-query statistics, including total time, mean time, calls, and cache hit ratio.
  • Analyzing execution plans and testing proposed indexes without creating real indexes.
  • Reviewing table size, row counts, dead tuples, access patterns, and table or index bloat.
  • Finding unused or duplicate indexes and generating workload-based index recommendations.
  • Checking connections, cache ratios, locks, replication, checkpoints, disk conditions, and wraparound risk.
  • Examining wait events, disk I/O, temporary files, checkpoint activity, and buffer efficiency.
  • Reviewing PostgreSQL settings and tracking manual or automatic vacuum progress.

Limitations and notes

Results depend on the PostgreSQL statistics, permissions, extensions, and server version available to the configured account. Bloat features require pgstattuple functions, and hypothetical index testing requires HypoPG.

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 Pgtuner MCP

pgtuner_mcp is an MCP server that connects AI agents to PostgreSQL performance data and tuning workflows. Its main tools analyze slow queries, execution plans, tables, indexes, database health, I/O, wait events, bloat, vacuum progress, and settings, with HypoPG support for testing hypothetical indexes without creating physical ones.

Install it with `pip install pgtuner_mcp` or `uv pip install pgtuner_mcp`. You can also clone the repository and run `pip install -e .`; the README identifies Claude Desktop as a client for the standard installation path.

Set `DATABASE_URI` to the target PostgreSQL connection string, using a format such as `postgresql://user:password@host:port/database`. The configured account also needs the documented database, schema, table, statistics, and extension permissions for the features you use.

Yes. Its HypoPG tools can create hypothetical indexes, run plans with them, list or remove them, and hide or restore existing indexes. Hypothetical index operations are session-scoped and do not affect the physical database.

The server uses `pg_stat_statements` for statement analysis, `pgstattuple` for table and index bloat analysis, and `hypopg` for hypothetical index testing. These extensions must be installed and granted to the monitoring account for their related features.

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 PreviewPgtuner MCP AllMCPs Directory Badge
Markdown (GitHub README)
[![AllMCPs](https://allmcps.com/api/badge/pgtuner-mcp?style=directory)](https://allmcps.com/mcp/pgtuner-mcp)
HTML Embed
<a href="https://allmcps.com/mcp/pgtuner-mcp"><img src="https://allmcps.com/api/badge/pgtuner-mcp?style=directory" alt="Pgtuner MCP on AllMCPs" /></a>