Postgres AIops logo

Postgres AIops

by AIops-tools

Governed PostgreSQL DBA analysis and maintenance over MCP, with audit logging, dry-run controls, budgets, and undo recording.

Install Postgres AIops

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": {
    "aiops-tools-postgres-aiops": {
      "command": "uvx",
      "args": [
        "postgres-aiops"
      ],
      "env": {
        "POSTGRES_AIOPS_MASTER_PASSWORD": "YOUR_VALUE_HERE",
        "POSTGRES_AIOPS_HOME": "YOUR_VALUE_HERE",
        "POSTGRES_RUNAWAY_MAX": "YOUR_VALUE_HERE",
        "POSTGRES_MAX_TOOL_CALLS": "YOUR_VALUE_HERE",
        "POSTGRES_MAX_TOOL_SECONDS": "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 POSTGRES_AIOPS_MASTER_PASSWORD=YOUR_VALUE_HERE --env POSTGRES_AIOPS_HOME=YOUR_VALUE_HERE --env POSTGRES_RUNAWAY_MAX=YOUR_VALUE_HERE --env POSTGRES_MAX_TOOL_CALLS=YOUR_VALUE_HERE --env POSTGRES_MAX_TOOL_SECONDS=YOUR_VALUE_HERE --transport stdio aiops-tools-postgres-aiops -- uvx postgres-aiops

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 postgres-aiops

Process exited before answering 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

AIops-tools/Postgres-AIops MCP server exposes governed PostgreSQL DBA operations through 35 MCP tools backed by psycopg 3, system catalogs, and pg_stat_* views. It covers health inspection, slow-query, bloat, vacuum, blocking-lock, index, and replication analysis, along with guarded maintenance and remediation writes. Every MCP and CLI call is audited, while write operations support dry-run previews and reversible actions record their before-state when an inverse exists. Reach for it when an agent needs traceable PostgreSQL operations rather than application-schema migration or ORM management.

Use cases

  • Investigate slow PostgreSQL queries with cited metrics and optional plans
  • Rank table bloat and determine whether vacuum or autovacuum tuning is needed
  • Trace blocking lock chains and identify root blockers
  • Review replication, WAL, index, and activity status
  • Preview and audit guarded PostgreSQL maintenance operations

Key features

  • 35 MCP tools covering PostgreSQL reads, analyses, writes, and undo
  • Slow-query, bloat/vacuum, and blocking-lock RCA
  • Unified audit database for MCP and CLI calls
  • Dry-run previews and before-state undo recording
  • Encrypted credential storage with Fernet and scrypt
  • Runaway-call and optional budget guards

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.

18/18 checks healthy over the last 117d

Supply-chain signal

No high-severity advisories surfaced by our automated scan.

Critical 0High 0Medium 0Low 0

Scanned 17d ago via OSV.dev · postgres-aiops (PyPI)

Adoption & maintenance

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

Last commit1mo agoMost recent push to the default branch.
Install checkInconclusiveDidn't respond in our test window — often a slow first install.
Directory activity4 viewsConfig copies, upvotes, and views on AllMCPs.

How Postgres AIops works

What AIops-tools/Postgres-AIops MCP server does

AIops-tools/Postgres-AIops MCP server connects to PostgreSQL through psycopg 3 and reads system catalogs plus pg_stat_* views. Its 35 tools include 25 read operations and 10 write or undo operations. Read coverage includes server metadata, databases, roles, extensions, sessions, locks, query activity, indexes, table size and bloat, autovacuum, replication, WAL, and query plans.

Three analysis tools turn database measurements into cited findings: slow_query_rca examines the worst pg_stat_statements entry and can include an EXPLAIN plan; bloat_and_vacuum_analysis ranks tables using dead-tuple ratios and autovacuum timing; and blocking_lock_chain_rca constructs a wait-for tree, identifies the root blocker, and flags cycles as possible deadlocks. The analyses can use live database data or injected records for offline testing.

How it works

AIops-tools/Postgres-AIops MCP server runs over stdio using postgres-aiops-mcp, or through the postgres-aiops mcp command. Each call passes through a governance wrapper. The wrapper records parameters, result, status, duration, risk label, and optional operator rationale in ~/.postgres-aiops/audit.db; POSTGRES_AIOPS_HOME can relocate that data. CLI calls use the same audit path, so the command-line interface does not bypass logging.

State-changing tools accept a dry-run request. CLI mutations also require two confirmations. Identifiers such as table, index, and configuration names are validated and quoted, while values use bound parameters. Reversible operations fetch the actual prior state and save an inverse description. For example, dropping an index stores its definition for recreation, and changing a setting records the previous value. Backend termination, query cancellation, vacuum, analyze, reindex, and query-statistics reset are recorded but do not provide an undo operation.

The runaway guard can trip a circuit breaker when the same call is repeated rapidly. Optional ceilings limit total tool calls or execution time. Risk levels are descriptive audit labels, not permission gates. PostgreSQL permissions remain the enforcement point; connecting with a read-only role makes writes fail at the database.

Setup and configuration

Install the package with uv tool install postgres-aiops or pipx install postgres-aiops. Run postgres-aiops init to add a target and store its password in the encrypted ~/.postgres-aiops/secrets.enc store, then use postgres-aiops doctor to check configuration, secrets, and connectivity. The password store uses Fernet and scrypt rather than plaintext files.

For noninteractive MCP or CI use, provide POSTGRES_AIOPS_MASTER_PASSWORD; the CLI can instead request the master password interactively. Start the stdio server with postgres-aiops-mcp. The exported password is visible to child processes and may enter shell history, so a short-lived secret injection or interactive prompt is safer on shared hosts.

The top_queries and slow_query_rca tools require the pg_stat_statements extension. The read role should have the pg_monitor privilege. This project targets PostgreSQL DBA operations and is not intended for industrial protocols, application-schema migrations, or ORM management.

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 Postgres AIops

AIops-tools/Postgres-AIops is an MCP server that connects AI agents to PostgreSQL through psycopg 3, system catalogs, and pg_stat_* views. Its main tools inspect activity, queries, indexes, bloat, locks, replication, and settings, perform three cited RCA analyses, and provide governed maintenance writes with audit logging and dry-run support.

Install it with `uv tool install postgres-aiops` or `pipx install postgres-aiops`, then run `postgres-aiops init` to configure a target and encrypted password store. Use `postgres-aiops doctor` to verify connectivity, and start the stdio server with `postgres-aiops-mcp`.

Yes, read-only roles can use the read operations, while write tools fail when the connected PostgreSQL role lacks write privileges. The server has no separate read-only switch or approval gate; database permissions determine whether a mutation is allowed.

Reversible writes capture the real before-state and record an inverse that can be reviewed through `undo_list` and applied with `undo_apply`. Index creation and removal, and setting changes, support inverse actions; termination, cancellation, vacuum, analyze, reindex, and statistics reset do not.

Only query-statistics features require `pg_stat_statements`: `top_queries` and `slow_query_rca` depend on that extension. Other catalog, activity, lock, index, table, replication, and maintenance tools do not have that stated requirement.

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