Creativity · MCP — server
MCP Postgres Server
The MCP Postgres Server connects a Model Context Protocol client to a PostgreSQL database over a standard connection string. It is read-only by default — schema and table listings are exposed as MCP resources and a `query` tool runs parameterised SELECTs — making it a safe way to let Claude Desktop or Cursor answer questions about production data.
MCP facts
- Kind
- server
- Ecosystem
- anthropic-mcp
- Language
- TypeScript / Node.js
- Transports
- stdio
Capabilities
- Tools: query — runs a read-only SELECT and returns rows as JSON
- Resources: postgres://host/db/table for schema and sample rows
- Safety: transaction wrapped in READ ONLY mode by default
- Works with any libpq-compatible Postgres (Neon, Supabase, RDS, Cloud SQL)
Install
npx -y @modelcontextprotocol/server-postgres postgresql://user:pass@host:5432/db Configuration
{
"mcpServers": {
"postgres": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-postgres",
"postgresql://readonly:[email protected]:5432/appdb?sslmode=require"
]
}
}
} Frequently asked questions
Can the Postgres MCP server write to the database?
No — by design. The server opens each query inside a BEGIN READ ONLY transaction so INSERT/UPDATE/DELETE/DDL is rejected by Postgres. If you need writes, fork the server and scope a role with specific grants.
How should I secure the connection?
Use a dedicated readonly Postgres role (GRANT SELECT only on the tables you want exposed), require sslmode=require in the connection string, and store the DATABASE_URL in a secret manager — not committed to version control.
Does it work with Neon, Supabase, or Cloud SQL?
Yes — any libpq-compatible Postgres works. Use the connection string each provider issues; for Supabase, use the Session pooler or direct connection, not the Transaction pooler.
Sources
- modelcontextprotocol/servers — postgres — accessed 2026-04-20
- PostgreSQL READ ONLY transactions — accessed 2026-04-20