pgops-mcp
Offers environment awareness around the database's containerized Docker stack, including topology inspection, container logs, resource statistics, and gated container restart actions.
Provides expert-level PostgreSQL database operations: schema inspection and diffing, guarded read/write queries, query execution planning with risk analysis, index advice, health checks, migration planning with lock-impact analysis, and rollback support.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@pgops-mcpCheck the health of the database and show me the current schema diff"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
pgops-mcp
A production-grade MCP server that gives AI agents safe, audited, expert-level control over a real PostgreSQL database and the Docker stack around it — no shell commands, no Python scripts, just tools.
Why
Existing Postgres MCP servers are thin query wrappers: introspect + SELECT. None handle
migrations with lock-impact analysis, none diagnose performance from EXPLAIN +
pg_stat_statements, none understand the containerized environment the database lives in.
Agents operating databases today are flying blind and unsafe.
pgops-mcp is the operations brain: schema intelligence → guarded queries → migration
engine → performance diagnosis → environment awareness, with a safety architecture that
makes every action classifiable, confirmable, and auditable.
Related MCP server: PostgreSQL MCP Server
Tool surface (v0.1)
Group | Tools |
Schema |
|
Queries |
|
Performance |
|
Migrations |
|
Environment |
|
Gated |
|
* Not registered at all unless the server runs with --approval-mode, and even then
each call needs a confirmation token. container.exec additionally enforces a read-only
diagnostic command allowlist — it does not offer a shell. The Docker socket is
root-equivalent on the host, so the default is read-only access.
Safety model (the core differentiator)
Separate read-only / read-write connection roles; tools bind to the right role
Statement classification before execution — unbounded
DELETE/UPDATEblockedDestructive actions require explicit confirmation tokens
Every executed statement lands in an append-only audit log with timing and verdict
Runaway-query cancellation with timeout tiers
MCP surface
Primitive | What's here |
Tools | 13 — schema, query, explain, advise, migrate, environment |
Resources |
|
Prompts |
|
Elicitation | Dangerous actions ask the user directly, not via the agent; confirmation tokens are the fallback |
Progress / logging | Best-effort notifications during long operations |
Remote access & agent tokens
stdio needs no auth — the server is a subprocess your client spawns, with no open port. HTTP does, so it refuses to start without a key:
pgops-mcp keygen # RS256 keypair
pgops-mcp issue-token --subject my-agent # read-only by default
pgops-mcp issue-token --subject deploy-bot --scope pgops:read --scope pgops:write
pgops-mcp scopes # which scope each tool needs
pgops-mcp --transport http --public-key ~/.pgops/keys/pgops_public.pemThe server holds only the public key, so it can verify tokens but never mint them.
Scopes (pgops:read / pgops:write / pgops:admin) map to the same danger tiers as the
guardrails, and a tool with no scope entry requires admin — deny by default. Binds
loopback unless you say otherwise.
Quickstart
uv sync
# point at your local Postgres in Docker:
export PGOPS_DSN="postgresql://user:pass@localhost:5432/mydb"
uv run pgops-mcp # stdio transport for Claude Desktop / Cursor / VS CodeAdd to Claude Desktop:
{
"mcpServers": {
"pgops": {
"command": "uv",
"args": ["run", "--directory", "/path/to/pgops-mcp", "pgops-mcp"]
}
}
}Docs
docs/PRD.md— what & why, goals, non-goalsdocs/SPEC.md— phased technical spec with hard gatesdocs/ARCHITECTURE.md— system design + trade-offsdocs/TOOLS.md— full tool catalog with schemas & examplesdocs/adr/— architecture decision recordsdocs/flow.md— living progress logdocs/interview_prep.md— growing interview Q&A
Status
Phases 0–6b complete (319 tests, every guardrail, verdict and lock-impact rule proven against real Postgres via testcontainers — no mocks — plus end-to-end suites driving the server as a real MCP subprocess over stdio and as an authenticated HTTP server).
Phase | State | Tools |
0 · Bootstrap | ✅ | seeded dev stack (1.2M-row |
1 · Connection core + read path | ✅ |
|
2 · Write path + safety | ✅ |
|
3 · Performance brain | ✅ |
|
4 · Migration engine | ✅ |
|
5 · Docker layer | ✅ |
|
6a · MCP completeness | ✅ | resources, prompts, elicitation, progress |
6b · Remote + auth | ✅ | HTTP transport, JWT, scoped agent tokens, keygen CLI |
6c · Packaging | next | PyPI, Smithery, MCP registry |
migration.rollback is deliberately still open — see docs/TOOLS.md.
Sample of what migration.plan returns for a type change on the 1.2M-row orders:
ALTER TABLE "orders" ALTER COLUMN "total_cents" TYPE bigint
op=table_rewrite risk=high estimate=4800ms confidence=medium
why: rewrites every row and rebuilds every index, holding AccessExclusiveLock
SAFER: add a new column of the target type, backfill in batches, sync with a
trigger, swap the names, then drop the old columnQuickstart the dev database (host port 5433, to avoid colliding with a local Postgres on 5432):
docker compose up -d
export PGOPS_DSN="postgresql://pgops:pgops_dev@localhost:5433/pgops_demo"
uv run pgops-mcp --selfcheckThis server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to interact with PostgreSQL databases through schema intelligence, query execution, and DBA tooling including index analysis and health monitoring. Features configurable access levels and audit logging for secure database operations.539MIT
- FlicenseNot gradedqualityDmaintenanceExposes PostgreSQL database operations as tools for AI assistants, allowing SQL queries and schema inspection.
- FlicenseNot gradedqualityDmaintenanceEnables AI assistants to interact with PostgreSQL databases through natural language queries, schema inspection, and safe SQL execution.91
- FlicenseNot gradedqualityDmaintenanceEnables AI assistants to safely interact with PostgreSQL databases, perform queries, inspect schemas, and analyze query performance.2
Related MCP Connectors
Query PostgreSQL databases in plain English — LLM-generated, safety-validated SQL.
Comprehensive PostgreSQL documentation and best practices, including ecosystem tools
Analytical memory for AI agents: a real Postgres queried in plain English over MCP. One command.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/arzharch/pgops-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server