Postgres AIops logo
Health: ActiveRecent health check succeeded.Last checked 8/7/2026, 10:35:55 PM

Postgres AIops

AIops-tools
View Repository

Governed PostgreSQL DBA operations โ€” slow-query, bloat, and blocking-lock RCA, index management, vacuum/analyze, and replication lag (35 tools) with unbypassable audit logging (MCP + CLI), budget/runaway guards, dry-run, and undo/rollback.

Quick Install

Automated & IDE Setup

Copy the AI prompt to install this server into Claude Code, Cursor, or another agent โ€” or use 1-click editor setup below.

Manual Client & Custom JSON ConfigExpand JSON โ–พ

Install Config Generator

claude_desktop_config.json
{
  "mcpServers": {
    "aiops-tools-postgres-aiops": {
      "command": "npx",
      "args": [
        "-y",
        "aiops-tools-postgres-aiops"
      ]
    }
  }
}

๐Ÿ’ก Paste into ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows)

Documentation Overview

Postgres AIops

Disclaimer: Community-maintained open-source project. Not affiliated with, endorsed by, or sponsored by the PostgreSQL Global Development Group or any vendor. "PostgreSQL" and the elephant logo are trademarks of the PostgreSQL Community Association; all product/trademark names belong to their respective owners. MIT licensed.

Governed AI-ops for PostgreSQL DBA operations โ€” connecting to a server with psycopg 3 and reading the system catalogs and pg_stat_* views โ€” with a built-in governance harness: unified audit log, token/runaway budget guard, undo-token recording, and descriptive risk-tier labels. Beyond the mock test suite, the reads, a governed write, and its undo have been exercised against a live PostgreSQL 16.14 instance โ€” see docs/VERIFICATION.md.

What it does

Three flagship signature analyses, plus the guarded reads and writes around them:

  • Slow-query RCA โ€” take the worst pg_stat_statements entry (plus an optional EXPLAIN plan) and map its numbers โ€” mean time, cache-hit ratio, temp spill, call count, plan node types โ€” to a cited cause and a concrete action. Every finding carries its measured number, not a black-box verdict.
  • Bloat & vacuum analysis โ€” combine per-table dead-tuple ratio and autovacuum recency into a ranked, cited recommendation (VACUUM / tune autovacuum).
  • Blocking lock-chain RCA โ€” build the wait-for tree from pg_blocking_pids, name the root blocker (blocks others, waits on none), and give the action; a cycle is flagged as a likely deadlock.

What works

  • CLI (postgres-aiops ...): init, overview, server, activity, query, index, table, repl, analyze, remediate, secret, doctor, mcp.
  • MCP server (postgres-aiops mcp or postgres-aiops-mcp): 35 tools (25 read, 10 write), every one wrapped with the bundled @governed_tool harness.
  • Encrypted credentials: the role password lives in an encrypted store ~/.postgres-aiops/secrets.enc (Fernet + scrypt) โ€” never plaintext on disk. Unlock with a master password from POSTGRES_AIOPS_MASTER_PASSWORD (MCP/CI) or an interactive prompt (CLI).
  • Reversibility: mutating writes fetch the real before-state first and record a faithful inverse โ€” create_indexโ†”drop_index; drop_index captures pg_get_indexdef so undo recreates it exactly; update_setting captures the prior value so undo sets it back. Irreversible ops (terminate_backend, cancel_query, run_vacuum, run_analyze, reindex, reset_query_stats) record prior stats for audit but declare no undo.
  • Safety: every state-changing CLI op supports --dry-run and requires double confirmation; every write MCP tool takes a dry_run preview. All identifiers that cannot be parameterised (table/index/GUC names) are validated and quoted; all values are bound query parameters.

Capability matrix (35 MCP tools)

DomainToolsCountR/W
Overviewoverview1read
Serverserver_version, show_settings, list_extensions, list_databases, list_roles5read
Activitylist_activity, long_running_queries, list_locks3read
Queriestop_queries, explain_query2read
Indexesunused_indexes, missing_index_hints, index_bloat, invalid_indexes4read
Tablestable_sizes, table_bloat, autovacuum_status3read
Replicationreplication_status, replication_slots, wal_status3read
Analysis (flagship)slow_query_rca, bloat_and_vacuum_analysis, blocking_lock_chain_rca3read
Writesterminate_backend, cancel_query, drop_index3write (high)
run_vacuum, run_analyze, create_index, reindex, update_setting, reset_query_stats6write (medium)
Undoundo_list1read
undo_apply1write (medium)

The flagship analyses accept injected records for pure/offline analysis, or pull live from a configured target. top_queries/slow_query_rca require the pg_stat_statements extension; the read role should have pg_monitor.

What this tool does, and does not, decide

It delivers PostgreSQL DBA operations โ€” reads and writes โ€” accurately and efficiently, and records every one of them. It does not decide whether a write is allowed to happen. That is the agent's judgement, or the permission of the account you connect it with: connect with a PostgreSQL role that has no write privileges (a read-only role, or one without INSERT/UPDATE/DELETE/DDL), and the writes fail at the server โ€” the place that actually owns the permission.

So there is no read-only switch, no policy file, no approval gate to configure. The one thing the tool guarantees is that nothing is silent: every call, over MCP and over the CLI alike, lands an audit row in ~/.postgres-aiops/audit.db, and destructive writes still capture their before-state and record an inverse where one exists.

Each tool declares a risk_level, carried into the audit row as a descriptive tier (none/confirm/review) โ€” so a reviewer can see at a glance that a row was a high-risk delete. It is a label, not a gate.

Running a smaller / local model? See agent-guardrails.md โ€” it lists the guardrails this tool now enforces for you (so you don't spend prompt budget restating them) and gives a ready-made system prompt for what's left.

Quick start

bash
uv tool install postgres-aiops             # or: pipx install postgres-aiops
postgres-aiops init                        # wizard: add a target + store the password (encrypted)
postgres-aiops doctor                      # verify config, secrets, connectivity
postgres-aiops overview                    # one-shot cluster health snapshot
postgres-aiops analyze slow-query          # RCA the worst pg_stat_statements entry
postgres-aiops table bloat                 # dead-tuple bloat proxy per table

Run as an MCP server (stdio):

server.ts
export POSTGRES_AIOPS_MASTER_PASSWORD=...  # unlock secrets non-interactively
postgres-aiops-mcp

Governance

Every MCP tool passes through the bundled @governed_tool harness:

  • Audit โ€” every call (params, result, status, duration, risk tier, and any operator-supplied approver/rationale) is logged to ~/.postgres-aiops/audit.db (relocatable via POSTGRES_AIOPS_HOME). The CLI writes the same row the MCP path does โ€” there is no unaudited entry point.
  • Runaway guard โ€” a safety backstop, not an authorization gate: the same call hammered in a tight loop trips a circuit breaker. Disable with POSTGRES_RUNAWAY_MAX=0; optional hard ceilings via POSTGRES_MAX_TOOL_CALLS / POSTGRES_MAX_TOOL_SECONDS.
  • Undo recording โ€” reversible writes record an inverse descriptor built from the fetched before-state.
  • Risk tier โ€” a descriptive label on the audit row derived from risk_level; it gates nothing.

Scope

This is the PostgreSQL DBA-ops member of the AIops-tools family (governed AI-ops with audit + budget + undo + risk tiers). Do NOT use it for OT / industrial edge (Modbus, OPC-UA, PROFINET) โ€” see the separate industrial-aiops line โ€” nor for application-schema migrations or ORM management.

Missing a capability?

Coverage is intentionally a curated subset of PostgreSQL's catalogs and maintenance surface. Missing a view, a metric, or a maintenance command? Open an issue or PR โ€” contributions welcome.

Status

The mock test suite is complemented by a live run: the catalog / pg_stat_* reads, the bloat_and_vacuum_analysis RCA, and the create_index / drop_index governed write path (audit + undo, with drop_index capturing pg_get_indexdef first) were exercised against a live PostgreSQL 16.14 instance running in Docker. docs/VERIFICATION.md records exactly what was and was not covered. postgres-aiops doctor is the fastest live check.

Related MCP Servers

View all alternatives

Frequently Asked Questions about Postgres AIops

How do I install the AIops-tools/Postgres-AIops MCP server?

Add the following block to your claude_desktop_config.json under mcpServers: "mcpServers": { "postgres-aiops": { "command": "npx", "args": ["-y", "AIops-tools/Postgres-AIops"] } }

What does AIops-tools/Postgres-AIops do?

Governed PostgreSQL DBA operations โ€” slow-query, bloat, and blocking-lock RCA, index management, vacuum/analyze, and replication lag (35 tools) with unbypassable audit logging (MCP + CLI), budget/runaway guards, dry-run, and undo/rollback.

Is the AIops-tools/Postgres-AIops MCP server free to use?

Yes. AIops-tools/Postgres-AIops is listed on AllMCPs as a free, open Model Context Protocol server you can install into Claude Desktop, Cursor, or any MCP-compatible client.

Technical Specs & Signals

TransportSTDIO
RuntimeNode.js
Health CheckActive
Views0
Installs0
GitHub stars0
40Quality signal: Fair ยท 40/100How this signal is calculated โ–พ
Server availabilityNot measured

Not scored for repo-hosted servers โ€” we can't reach the running server, only its GitHub page. Hosted MCP endpoints are health-checked live.

Verified ownership8/20
Documentation & tools22/30
Adoption0/15
Community engagement0/10

A guidance signal from public completeness & health data โ€” not a user rating. New listings start lower and rise as they add docs, get verified, and grow adoption. Signals we can't observe for a listing are skipped, not counted against it.

โ˜… FeaturedMoxie Docs MCP logo

Moxie Docs MCP

MCP & Agent Skills for Automated Documentation, and codebase conventions + context

Explore Server โ†’

Own this project?

This directory is pre-filled from public sources. Claim via GitHub README, site badge, or DNS TXT to get the verified badge and attach your website.

Free dofollow backlink: after claiming, verify your product site and place a dofollow AllMCPs badge โ€” we recheck it stays live.

Claim & get free dofollow

Promote this listing

Optional paid placement. Free listings stay free forever.

Featured boost7 days in the spotlight ยท from $12/wk
Weeks
1

โ†’ Runs until Aug 15, 2026

Category sponsorTop-of-category sponsorship ยท from $18/wk
Weeks
1

โ†’ Runs until Aug 15, 2026

Cancel anytime โ€” no long-term lock-in.

Share & Embed

Add our SVG badge (dark/light directory styles) or embeddable widget to your site.