PostgreSQL MCP Server
A read-only reference MCP server that lets an agent inspect a Postgres database's schema and run SELECT queries — a safe way to give an agent database context without write access.
Add to Claude Code
claude mcp add postgres -- npx -y @modelcontextprotocol/server-postgres postgresql://user:pass@localhost/db
Source: https://github.com/modelcontextprotocol/servers/tree/main/src/postgres
About
The Postgres MCP server connects to any Postgres database via a connection string and exposes schema inspection plus read-only query execution as agent tools. There's no update, insert, or delete path — only SELECT statements are permitted.
It's designed for the common case of wanting an agent to understand your data model and answer questions about existing data, not to manage migrations or mutate records — pair it with your own migration tooling for schema changes.
Key features
- Read-only SELECT queries against any Postgres database
- Automatic schema and table introspection
- Works with any standard Postgres connection string
- No write, update, or delete capability by design
Use cases
- Let an agent explore an unfamiliar database schema before writing application code
- Answer ad-hoc data questions without opening a SQL client
- Give a debugging session read access to production data safely
Available tools
query
Runs a read-only SQL SELECT statement against the connected database.
Frequently asked questions
Can it modify data?
No — the server enforces read-only access at the tool level, exposing only SELECT-style querying.
Does it work with managed Postgres like RDS or Supabase?
Yes — any standard Postgres connection string works, including managed providers, as long as the network path is reachable.