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_URLEnv var· optional· secretFull connection string (preferred). Supports sslmode in the URL.PG_PASSWORDEnv var· optional· secretDatabase password.PG_SSH_PASSPHRASEEnv var· optional· secretPassphrase for the private key, if encrypted.PG_SSH_PASSWORDEnv var· optional· secretSSH login password. Opt-in; a key or agent takes precedence. Prefer keys, a bastion often disables password auth.PG_HOSTEnv var· optionalDatabase host (fallback when DATABASE_URL is not set).PG_PORTEnv var· optionalDatabase port.Default:5432
Show 16 moreShow fewer
PG_USEREnv var· optionalDatabase user.PG_DATABASEEnv var· optionalDatabase name.PG_ALLOW_WRITEEnv var· optionalWhen 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:falsePG_SSLMODEEnv var· optionalTLS 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_CAEnv var· optionalPath to a CA certificate file. Setting it by itself implies verify-full.PG_ENABLE_RUNTIME_CONNECTEnv var· optionalRegister the connect_db tool (runtime credential switching).Default:falsePG_MAX_RESULT_BYTESEnv var· optionalByte 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:32768PG_STATEMENT_TIMEOUTEnv var· optionalStatement timeout in milliseconds, applied to every session.Default:30000PG_CONNECT_TIMEOUTEnv var· optionalTimeout in milliseconds for a single connect attempt (raise it for slow links or SSH tunnels).Default:10000PG_SSH_HOSTEnv var· optionalSSH 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_PORTEnv var· optionalSSH bastion port.Default:22PG_SSH_USEREnv var· optionalSSH username.PG_SSH_PRIVATE_KEYEnv var· optionalPath 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_AGENTEnv var· optionaltrue to use the ambient agent (SSH_AUTH_SOCK), or an explicit socket path / Windows named pipe.PG_SSH_FINGERPRINTEnv var· optionalPinned 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_INTERVALEnv var· optionalSSH keepalive interval in ms; the tunnel drops after 3 unanswered keepalives, and the next call reconnects.Default:15000
Links
Listed in the official MCP Registry since Sep 14, 2026. Mirrored daily; last checked Nov 26, 2026.