PostgreSQL

io.github.antonorlov/mcp-postgres-server

MCP server for PostgreSQL: local, Docker, RDS, Neon, Supabase, or behind an SSH bastion.

Connect this server

Add this to your MCP client config — claude_desktop_config.json (Claude Desktop) or .cursor/mcp.json (Cursor).Suits: Claude Desktop · Cursor.

{
  "mcpServers": {
    "mcp-postgres-server": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-postgres-server@0.3.1"
      ],
      "env": {
        "DATABASE_URL": "<your DATABASE_URL>",
        "PG_PORT": "5432",
        "PG_PASSWORD": "<your PG_PASSWORD>",
        "PG_ALLOW_WRITE": "false",
        "PG_ENABLE_RUNTIME_CONNECT": "false",
        "PG_MAX_RESULT_BYTES": "32768",
        "PG_STATEMENT_TIMEOUT": "30000",
        "PG_CONNECT_TIMEOUT": "10000",
        "PG_SSH_PORT": "22",
        "PG_SSH_PASSPHRASE": "<your PG_SSH_PASSPHRASE>",
        "PG_SSH_PASSWORD": "<your PG_SSH_PASSWORD>",
        "PG_SSH_KEEPALIVE_INTERVAL": "15000"
      }
    }
  }
}
Environment variables
  • DATABASE_URLsecretFull connection string (preferred). Supports sslmode in the URL.
  • PG_PORTDatabase port.
  • PG_PASSWORDsecretDatabase password.
  • PG_ALLOW_WRITEWhen true, execute performs writes and reads are sent directly. Off (default) is read-only: execute refuses writes and each read runs in a READ ONLY transaction.
  • PG_ENABLE_RUNTIME_CONNECTRegister the connect_db tool (runtime credential switching).
  • PG_MAX_RESULT_BYTESByte budget for a query result sent to the model. Whole rows are kept while they fit; over the budget returnedRows < rowCount and truncated is true.
  • PG_STATEMENT_TIMEOUTStatement timeout in milliseconds, applied to every session.
  • PG_CONNECT_TIMEOUTTimeout in milliseconds for a single connect attempt (raise it for slow links or SSH tunnels).
  • PG_SSH_PORTSSH bastion port.
  • PG_SSH_PASSPHRASEsecretPassphrase for the private key, if encrypted.
  • PG_SSH_PASSWORDsecretSSH login password. Opt-in; a key or agent takes precedence. Prefer keys, a bastion often disables password auth.
  • PG_SSH_KEEPALIVE_INTERVALSSH keepalive interval in ms; the tunnel drops after 3 unanswered keepalives, and the next call reconnects.

A starting point — check the repository for exact arguments and setup. Restart your client after editing the config.

Category
Databases
Version
0.3.1
Registry
active
Published
9/14/2026
Browse all Databases →

Add the badge to your site

Show visitors that PostgreSQL is listed here — it’s also the link we check for a free listing.

PostgreSQL — listed on Serverdex

HTML — for your website

<a href="https://serverdex.io/server/io-github-antonorlov-mcp-postgres-server?utm_source=badge"><img src="https://serverdex.io/brand/badge.svg" alt="PostgreSQL — listed on Serverdex" width="123" height="40" loading="lazy"></a>

Recommended. A dofollow link from your own domain is the one that counts for search engines, and it's the link we check for a free listing.

Markdown — for your README

[![PostgreSQL — listed on Serverdex](https://serverdex.io/brand/badge.svg)](https://serverdex.io/server/io-github-antonorlov-mcp-postgres-server?utm_source=badge)

Nice for visibility, but GitHub marks README links nofollow, so it doesn't pass authority. Use the HTML badge on your site as well.