PostgreSQL MCP Server
## what it does
tl;dr: Anthropic’s @modelcontextprotocol/server-postgres is archived (read-only since 2025-05-29). The original is a one-tool, read-only server over any postgresql:// URL. For new work, crystaldba/postgres-mcp (3.3k stars) is the strongest generic community option; for managed Postgres, supabase/mcp or AWS Labs’ RDS / Aurora DSQL MCPs fit better.
Status of the original
The Anthropic reference lives at modelcontextprotocol/servers-archived/src/postgres. It exposes one tool, query, which runs SQL inside a read-only transaction, and resource templates postgres://<host>/<table>/schema for schema discovery. The npm package still installs; the source is read-only.
Pick one
| Use case | Server | Why |
|---|---|---|
| Self-hosted PG, want explain plans / tuning / health checks | crystaldba/postgres-mcp | 9 tools: execute_sql, get_object_details, explain_query, list_objects, list_schemas, get_top_queries, analyze_workload_indexes, analyze_query_indexes, analyze_db_health |
| Supabase project | supabase/mcp | remote OAuth at https://mcp.supabase.com/mcp; project-scoped tools |
| AWS RDS / Aurora PostgreSQL | uvx awslabs.postgres-mcp-server@latest | part of awslabs/mcp; IAM auth via AWS_PROFILE |
| Aurora DSQL (serverless PG) | uvx awslabs.aurora-dsql-mcp-server@latest | AWS Labs; IAM token-auth |
Quick stdIO over any postgresql:// URL | uvx mcp-server-postgres (archived) | Original one-tool, read-only; still works |
Embedded pg-mem / local-only | mcp-server-mysql analog (@modelcontextprotocol/server-postgres) | n/a — there’s no PG equivalent of the SQLite one |
Install — crystaldba/postgres-mcp (default recommendation)
uvx postgres-mcp --access-schema=public --access-mode=unrestricted
Claude Desktop:
{
"mcpServers": {
"postgres": {
"command": "uvx",
"args": ["postgres-mcp", "--access-schema=public", "--access-mode=unrestricted"],
"env": {
"DATABASE_URI": "postgresql://user:pass@localhost:5432/mydb"
}
}
}
}
Flags worth knowing: --access-schema (limit the agent to one schema) and --access-mode=restricted (block any DDL/DML). The server supports both stdio and SSE transports — pass --transport=sse (with --port) to share one server across multiple MCP clients. The README also has an OPT-30K-style prompt budget hint for limiting how much of the schema it introspects.
Install — the archived one (still works)
npx -y @modelcontextprotocol/server-postgres postgresql://user:pass@localhost:5432/mydb
{
"mcpServers": {
"postgres": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-postgres", "postgresql://user:pass@localhost:5432/mydb"]
}
}
}
For Docker on the same host as the DB, use host.docker.internal instead of localhost. The original is locked to one tool: query running inside a read-only transaction.
Safety
Any of these servers will execute SQL the model generates. The original is read-only by design; crystaldba/postgres-mcp defaults to restricted mode and you can scope it to one schema. For production:
- Use a dedicated, read-only DB user.
- Restrict to one schema with
--access-schema. - Lock the network path (security group, VPC, or SSH tunnel).
- Enable statement logging in
postgresql.confand forward logs.
Gotchas
- The archived Anthropic package is no longer maintained. Issues stay open but no fixes land.
host.docker.internalis macOS/Windows; on Linux, point at the host’s actual IP or run the MCP on the host instead of in a container.- Connection-pool exhaustion: each MCP session is one PG connection. Long-lived clients with many parallel tools can hit
max_connections.
Related
- Supabase MCP — managed Postgres
- AWS MCP — for RDS / Aurora DSQL
- SQLite MCP — local DB
- MCP Servers Explained
## compatibility
## exposed tools
## embed this badge
