Skip to main content

PostgreSQL

io.github.antonorlov/mcp-postgres-server

v0.3.1Updated Sep 14, 2026stdio · npm

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

Install

Nothing to fill in: copy and run.

Run in your terminal

claude mcp add mcp-postgres-server -e PG_PORT=5432 -e PG_ALLOW_WRITE=false -e PG_ENABLE_RUNTIME_CONNECT=false -e PG_MAX_RESULT_BYTES=32768 -e PG_STATEMENT_TIMEOUT=30000 -e PG_CONNECT_TIMEOUT=10000 -e PG_SSH_PORT=22 -e PG_SSH_KEEPALIVE_INTERVAL=15000 -- npx -y [email protected]

Configuration

22 settings.

  • DATABASE_URL
    Env var· optional· secret
    Full connection string (preferred). Supports sslmode in the URL.
  • PG_PASSWORD
    Env var· optional· secret
    Database password.
  • PG_SSH_PASSPHRASE
    Env var· optional· secret
    Passphrase for the private key, if encrypted.
  • PG_SSH_PASSWORD
    Env var· optional· secret
    SSH login password. Opt-in; a key or agent takes precedence. Prefer keys, a bastion often disables password auth.
  • PG_HOST
    Env var· optional
    Database host (fallback when DATABASE_URL is not set).
  • PG_PORT
    Env var· optional
    Database port.Default: 5432
Show 16 more
  • PG_USER
    Env var· optional
    Database user.
  • PG_DATABASE
    Env var· optional
    Database name.
  • PG_ALLOW_WRITE
    Env var· optional
    When 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.Default: false
  • PG_SSLMODE
    Env var· optional
    TLS mode. require/allow/prefer encrypt without verifying the certificate; verify-ca/verify-full verify it (supply a CA via PG_SSL_CA). Unlike libpq, allow/prefer do not fall back to plaintext, so a server without TLS needs disable.
  • PG_SSL_CA
    Env var· optional
    Path to a CA certificate file. Setting it by itself implies verify-full.
  • PG_ENABLE_RUNTIME_CONNECT
    Env var· optional
    Register the connect_db tool (runtime credential switching).Default: false
  • PG_MAX_RESULT_BYTES
    Env var· optional
    Byte 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.Default: 32768
  • PG_STATEMENT_TIMEOUT
    Env var· optional
    Statement timeout in milliseconds, applied to every session.Default: 30000
  • PG_CONNECT_TIMEOUT
    Env var· optional
    Timeout in milliseconds for a single connect attempt (raise it for slow links or SSH tunnels).Default: 10000
  • PG_SSH_HOST
    Env var· optional
    SSH bastion host. Setting it enables tunneling: the server reaches the database only through an SSH tunnel to this host. Needs the ssh2 optional dependency.
  • PG_SSH_PORT
    Env var· optional
    SSH bastion port.Default: 22
  • PG_SSH_USER
    Env var· optional
    SSH username.
  • PG_SSH_PRIVATE_KEY
    Env var· optional
    Path to a private key file. If unset, auth falls back like ssh: a running agent (SSH_AUTH_SOCK), then a default key (~/.ssh/id_ed25519, id_rsa, id_ecdsa).
  • PG_SSH_AGENT
    Env var· optional
    true to use the ambient agent (SSH_AUTH_SOCK), or an explicit socket path / Windows named pipe.
  • PG_SSH_FINGERPRINT
    Env var· optional
    Pinned host-key fingerprint (SHA256:...). Host-key verification is mandatory and set only this way: without it the tunnel refuses to connect. Get it with ssh-keygen -lF host.
  • PG_SSH_KEEPALIVE_INTERVAL
    Env var· optional
    SSH keepalive interval in ms; the tunnel drops after 3 unanswered keepalives, and the next call reconnects.Default: 15000

Listed in the official MCP Registry since Sep 14, 2026. Mirrored daily; last checked Nov 26, 2026.