PostgreSQL MCP Server: Connect a Database to Claude (2026)

Connect Claude to PostgreSQL for schema inspection and read-only queries. Covers the archived official server, recommended alternatives, and safe setup.

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.

PostgreSQL MCP — 4 stepsPostgreSQL MCP — 4 steps1. Read-only userleast privilege2. Connection stringpostgresql://…3. Registernpx or Docker4. Queryschema · read queries

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.

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.

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).

Written/current as of June 2026. The official PostgreSQL reference server lives in the archived repo and may no longer be maintained. Check the official docs and registry for setup and alternatives. This is an unofficial guide.

Keep reading

Discuss this topic in the community

Be the first to post in 'Claude Coding'. This is where readers of this topic gather.