Pgops logo

Pgops

Guarded PostgreSQL operations over MCP, including schema inspection, query analysis, migration planning, audits, and container diagnostics.

Install Pgops

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": {
    "pgops": {
      "command": "uvx",
      "args": [
        "pgops-mcp"
      ],
      "env": {
        "PGOPS_DSN": "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 PGOPS_DSN=YOUR_VALUE_HERE --transport stdio pgops -- uvx pgops-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 hit an unexpected error while testing this listing automatically.

uvx pgops-mcp

Rate limit exceeded, please try again later - you have reached the maximum number of concurrent E2B sandboxes (20). If you need more, please visit 'https://e2b.dev/docs/billing'

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 pgops MCP server connects AI clients to PostgreSQL for schema inspection, guarded queries, migration planning, performance diagnosis, and environment checks. It classifies statements before execution, separates read-only and read-write roles, requires confirmation for dangerous actions, and records executed statements in an audit log. Use it when an agent needs operational access to Postgres with controls around destructive queries, migration locks, timeouts, and container access. It runs over stdio or authenticated HTTP and can be launched with uvx or Docker.

Use cases

  • Inspect PostgreSQL schemas through an AI client
  • Analyze slow queries with parsed EXPLAIN output
  • Plan migrations with lock-impact estimates
  • Run guarded database writes with human confirmation
  • Diagnose database containers and runtime health

Key features

  • Guarded read and write query tools
  • Migration planning with lock analysis
  • Parsed EXPLAIN diagnostics and index advice
  • Append-only statement audit logging
  • Authenticated HTTP access with scoped agent tokens
  • Container logs, statistics, and gated controls

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.

14/14 checks healthy over the last 66d

Supply-chain signal

No high-severity advisories surfaced by our automated scan.

Critical 0High 0Medium 0Low 0

Scanned 10d ago via OSV.dev · pgops-mcp (PyPI)

Adoption & maintenance

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

Last commit3mo agoMost recent push to the default branch.
Install checkInconclusiveWe hit an unexpected error running the automated check.

How Pgops works

What pgops MCP server does

The pgops MCP server gives an AI client structured access to PostgreSQL operations rather than exposing an unrestricted query shell. Its capabilities cover schema inspection, read queries, guarded writes, parsed EXPLAIN output, index advice, database health checks, migration planning and execution, migration history, and environment diagnostics.

The pgops MCP server also exposes tools for inspecting container logs and statistics. Container restart and command execution are optional gated capabilities: they are registered only in approval mode, require confirmation tokens, and remain constrained by the server's safety rules. Diagnostic command execution uses a read-only allowlist rather than providing a general shell.

How it works

Before a statement runs, the server classifies it and selects the appropriate database connection role. Unbounded DELETE and UPDATE statements are blocked, while destructive operations require explicit confirmation. Clients that support user elicitation can display the approval request to the human; otherwise, a single-use token is bound to the exact statement. The assistant cannot approve its own action.

Executed statements are written to an append-only audit log with timing and verdict information. Timeout tiers support cancellation of runaway queries. Migration planning performs dry-run and lock-impact analysis, including safer alternatives such as concurrent index creation. Query explanation returns a parsed plan and diagnostic guidance instead of only raw EXPLAIN data.

For remote access, the server supports HTTP with RS256 agent tokens. Tokens can carry read, write, or admin scopes, and tools without a scope mapping require admin access. HTTP startup requires a public key, while stdio runs as a client-spawned subprocess without opening a port.

Setup and configuration

Set PGOPS_DSN to the PostgreSQL connection string. A client can launch the server with uvx pgops-mcp, or run the published container image with Docker. A self-check command is available for testing the connection before adding the server to a client configuration.

The container option requires attention to networking and audit persistence. Use host.docker.internal or a Compose service name instead of localhost when the database is outside the container. Mount a volume at /var/lib/pgops if audit records must survive container removal.

Claude Desktop, Cursor, and VS Code configurations are shown in the project documentation. HTTP deployments additionally require generating an RS256 keypair, issuing agent tokens, and passing the public key to the server.

Tools and capabilities

The documented tool groups include:

  • schema.inspect for database structure
  • query.read, query.write, and query.explain for reads, guarded writes, and plan analysis
  • index.advise and db.health for performance and health checks
  • migration.plan, migration.describe, migration.apply, migration.rollback, and migration.history
  • env.topology, env.correlate, container.logs, and container.stats
  • Approval-gated container.restart and container.exec

Resources include schema views, health, migration, audit, and configuration data. Prompts support slow-query diagnosis, safe migration planning, incident triage, index-health review, and explanation of the safety model. migration.describe uses the connected model through MCP sampling and does not ship an API key. Table-name completion is available for schema resources.

Limitations and notes

The server is an MCP executable, not a Python library, and its pgops.* internals do not promise API stability. HTTP access must be authenticated with agent tokens; stdio does not require authentication because the client starts the process locally. Docker socket access is root-equivalent on the host, so container controls default to read-only behavior.

The pgops MCP server supports PostgreSQL extensions and custom types through catalog-based inspection, including the documented pgvector and HNSW index cases. It does not provide a general-purpose shell through container.exec, and dangerous operations still depend on client support for prompts or the fallback confirmation-token flow.

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 Pgops

pgops is an MCP server that connects AI clients to PostgreSQL and provides tools for schema inspection, guarded reads and writes, query explanation, migration planning, performance checks, and environment diagnostics. It classifies statements, requires confirmation for dangerous actions, and records executed statements in an audit log.

Run it with `uvx pgops-mcp` from your MCP client configuration, or use the published Docker image. Set `PGOPS_DSN` to the PostgreSQL connection string. A self-check command is available to verify connectivity before wiring the server into a client.

Yes, pgops works with Cursor. Add it as an MCP server using the `uvx pgops-mcp` command and provide `PGOPS_DSN` in the client environment. The project also documents configurations for Claude Desktop and VS Code.

It classifies statements before execution, blocks unbounded `DELETE` and `UPDATE` operations, and requires explicit confirmation tokens for destructive actions. Executed statements and refusals are recorded in the audit log, and query timeouts can cancel runaway operations.

Generate an RS256 keypair, issue an agent token with the required scope, and start the server with its public key. HTTP refuses to start without a key, binds to loopback by default, and supports read, write, and admin scopes.

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