The PostgreSQL MCP server connects Claude to a database so it can inspect the schema and run read-only queries. One important caveat: the official reference server (@modelcontextprotocol/server-postgres) has been moved to the archived repository and is no longer actively maintained. So this guide covers both using the archived official server and the better-maintained alternatives.
What you can do
This server provides read-only access — it exposes your table structures (schema) as resources and runs queries for reading. It is meant for "let Claude understand my DB and answer questions about it," not for changing data.
Option 1 — The archived official server (use with care)
The package is @modelcontextprotocol/server-postgres, and you pass a connection string as an argument. A claude_desktop_config.json example:
{
"mcpServers": {
"postgres": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-postgres",
"postgresql://localhost/mydb"
]
}
}
}
Replace the last argument postgresql://localhost/mydb with your own connection string. Note that because this server is archived, its security and compatibility updates may have stopped — keep that in mind.
Option 2 — Maintained alternatives (recommended)
You can find actively maintained database MCP servers in the registries and directories covered in where to find MCP servers. And if you use managed Postgres, consider a vendor-provided server (such as Supabase's official MCP), which is generally safer.
Staying safe — databases need extra care
DB connections are sensitive, so: first, create and connect with a read-only, least-privilege account. Second, the connection string contains a password, so keep it from being exposed (MCP connector security). Third, prefer a copy or read replica over your production database.
Troubleshooting
If the server does not appear or you get connection errors, see the troubleshooting guide. Connection-string format, firewalls, and permissions are common causes.
Related
For other servers see Filesystem server and GitHub MCP server; for picks by use case see recommended MCP servers; for the full map see the connector & MCP catalog. The official source is modelcontextprotocol/servers-archived (postgres).