PostgreSQL MCP: Documentation
Updated:
Connection
Docker: docker run -e DATABASE_URI=postgresql://... crystaldba/postgres-mcp (stdio), or add --transport=sse for SSE. Via pipx: pipx install postgres-mcp. Auth is a standard PostgreSQL connection string with a login and password — there's no separate API key. The --access-mode=restricted flag limits the agent to read-only operations.
Tools
9 tools: list_schemas, list_objects, get_object_details — explore the database structure; execute_sql — run queries (read-only/read-write mode is configurable); explain_query — break down an execution plan; get_top_queries — the heaviest queries by statistics; analyze_workload_indexes, analyze_query_indexes — index recommendations for the whole workload or a specific query; analyze_db_health — a health check on indexes, vacuum, buffers and replication.
Agent flow
"Why are queries against orders slow?", "show me the top 5 heaviest queries from the last hour", "what indexes should I add for this workload?", "check database health before peak load".
Important
Postgres MCP Pro is an independent project by Crystal DBA, not affiliated with the PostgreSQL Global Development Group. The official reference server, @modelcontextprotocol/server-postgres, is archived (no longer developed) but still works, exposing a single read-only query tool — for full functionality, use Postgres MCP Pro instead.
Pricing
Free, open source (license in the repo). You only pay for your own PostgreSQL infrastructure.