Postgres MCP Server
Query and inspect a Postgres database from any MCP client.
The Postgres MCP server lets your AI client query and inspect a Postgres database with SELECT, EXPLAIN, and schema introspection. Read-only by design — it cannot mutate data — which makes it safe to point at a production database from a debugging session. Use it to answer questions like "how many users signed up last week", "what's the schema of the orders table", or "why is this query slow" without context-switching to psql.
Install in your client
Copy and paste — no manual config. Replace placeholder values for POSTGRES_URL.
run in any terminal
POSTGRES_URL="<your-postgres-url>" claude mcp add postgres npx -y @modelcontextprotocol/server-postgresCommon use cases
- Inspect schema, indexes, and constraints during code review
- Run analytical queries during a debugging session without leaving the IDE
- Generate SELECT statements from natural language, then EXPLAIN their plan before running them
- Document a table's purpose from its actual rows + foreign key relationships
Note
Point at a read-replica when querying production. The server is technically read-only at the SQL level, but a poorly-written query can still impact the database it runs against.