PostgreSQL
MCP server for PostgreSQL: local, Docker, RDS, Neon, Supabase, or behind an SSH bastion.
Documentation & Preview
{ "mcpServers": { "mcp-mcp-postgres-server": { "command": "npx", "args": [ "-y", "--package", "mcp-postgres-server@0.3.1", "mcp-postgres" ], "env": { "DATABASE_URL": "${ENV_DATABASE_URL}", "PG_HOST": "${ENV_PG_HOST}", "PG_PORT": "${ENV_PG_PORT}", "PG_USER": "${ENV_PG_USER}", "PG_PASSWORD": "${ENV_PG_PASSWORD}", "PG_DATABASE": "${ENV_PG_DATABASE}", "PG_ALLOW_WRITE": "${ENV_PG_ALLOW_WRITE}", "PG_SSLMODE": "${ENV_PG_SSLMODE}", "PG_SSL_CA": "${ENV_PG_SSL_CA}", "PG_ENABLE_RUNTIME_CONNECT": "${ENV_PG_ENABLE_RUNTIME_CONNECT}", "PG_MAX_RESULT_BYTES": "${ENV_PG_MAX_RESULT_BYTES}", "PG_STATEMENT_TIMEOUT": "${ENV_PG_STATEMENT_TIMEOUT}", "PG_CONNECT_TIMEOUT": "${ENV_PG_CONNECT_TIMEOUT}", "PG_SSH_HOST": "${ENV_PG_SSH_HOST}", "PG_SSH_PORT": "${ENV_PG_SSH_PORT}", "PG_SSH_USER": "${ENV_PG_SSH_USER}", "PG_SSH_PRIVATE_KEY": "${ENV_PG_SSH_PRIVATE_KEY}", "PG_SSH_PASSPHRASE": "${ENV_PG_SSH_PASSPHRASE}", "PG_SSH_AGENT": "${ENV_PG_SSH_AGENT}", "PG_SSH_PASSWORD": "${ENV_PG_SSH_PASSWORD}", "PG_SSH_FINGERPRINT": "${ENV_PG_SSH_FINGERPRINT}", "PG_SSH_KEEPALIVE_INTERVAL": "${ENV_PG_SSH_KEEPALIVE_INTERVAL}" } } }, "setup": { "fields": [ { "id": "ENV_DATABASE_URL", "label": "DATABASE_URL", "description": "Full connection string (preferred). Supports sslmode in the URL.", "required": false, "secret": true, "default": "" }, { "id": "ENV_PG_HOST", "label": "PG_HOST", "description": "Database host (fallback when DATABASE_URL is not set).", "required": false, "secret": false, "default": "" }, { "id": "ENV_PG_PORT", "label": "PG_PORT", "description": "Database port.", "required": false, "secret": false, "default": "5432" }, { "id": "ENV_PG_USER", "label": "PG_USER", "description": "Database user.", "required": false, "secret": false, "default": "" }, { "id": "ENV_PG_PASSWORD", "label": "PG_PASSWORD", "description": "Database password.", "required": false, "secret": true, "default": "" }, { "id": "ENV_PG_DATABASE", "label": "PG_DATABASE", "description": "Database name.", "required": false, "secret": false, "default": "" }, { "id": "ENV_PG_ALLOW_WRITE", "label": "PG_ALLOW_WRITE", "description": "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.", "required": false, "secret": false, "default": "false" }, { "id": "ENV_PG_SSLMODE", "label": "PG_SSLMODE", "description": "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.", "required": false, "secret": false, "default": "" }, { "id": "ENV_PG_SSL_CA", "label": "PG_SSL_CA", "description": "Path to a CA certificate file. Setting it by itself implies verify-full.", "required": false, "secret": false, "default": "" }, { "id": "ENV_PG_ENABLE_RUNTIME_CONNECT", "label": "PG_ENABLE_RUNTIME_CONNECT", "description": "Register the connect_db tool (runtime credential switching).", "required": false, "secret": false, "default": "false" }, { "id": "ENV_PG_MAX_RESULT_BYTES", "label": "PG_MAX_RESULT_BYTES", "description": "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.", "required": false, "secret": false, "default": "32768" }, { "id": "ENV_PG_STATEMENT_TIMEOUT", "label": "PG_STATEMENT_TIMEOUT", "description": "Statement timeout in milliseconds, applied to every session.", "required": false, "secret": false, "default": "30000" }, { "id": "ENV_PG_CONNECT_TIMEOUT", "label": "PG_CONNECT_TIMEOUT", "description": "Timeout in milliseconds for a single connect attempt (raise it for slow links or SSH tunnels).", "required": false, "secret": false, "default": "10000" }, { "id": "ENV_PG_SSH_HOST", "label": "PG_SSH_HOST", "description": "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.", "required": false, "secret": false, "default": "" }, { "id": "ENV_PG_SSH_PORT", "label": "PG_SSH_PORT", "description": "SSH bastion port.", "required": false, "secret": false, "default": "22" }, { "id": "ENV_PG_SSH_USER", "label": "PG_SSH_USER", "description": "SSH username.", "required": false, "secret": false, "default": "" }, { "id": "ENV_PG_SSH_PRIVATE_KEY", "label": "PG_SSH_PRIVATE_KEY", "description": "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).", "required": false, "secret": false, "default": "" }, { "id": "ENV_PG_SSH_PASSPHRASE", "label": "PG_SSH_PASSPHRASE", "description": "Passphrase for the private key, if encrypted.", "required": false, "secret": true, "default": "" }, { "id": "ENV_PG_SSH_AGENT", "label": "PG_SSH_AGENT", "description": "true to use the ambient agent (SSH_AUTH_SOCK), or an explicit socket path / Windows named pipe.", "required": false, "secret": false, "default": "" }, { "id": "ENV_PG_SSH_PASSWORD", "label": "PG_SSH_PASSWORD", "description": "SSH login password. Opt-in; a key or agent takes precedence. Prefer keys, a bastion often disables password auth.", "required": false, "secret": true, "default": "" }, { "id": "ENV_PG_SSH_FINGERPRINT", "label": "PG_SSH_FINGERPRINT", "description": "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.", "required": false, "secret": false, "default": "" }, { "id": "ENV_PG_SSH_KEEPALIVE_INTERVAL", "label": "PG_SSH_KEEPALIVE_INTERVAL", "description": "SSH keepalive interval in ms; the tunnel drops after 3 unanswered keepalives, and the next call reconnects.", "required": false, "secret": false, "default": "15000" } ], "requirements": [ "安装 Node.js / npm" ] }, "provenance": { "registryServer": "io.github.antonorlov/mcp-postgres-server", "registryVersion": "0.3.1", "registryUrl": "https://registry.modelcontextprotocol.io/v0.1/servers/io.github.antonorlov%2Fmcp-postgres-server/versions/0.3.1", "repository": "antonorlov/mcp-postgres-server", "sourceCommit": "d75a277848073248c1520045e1f2a8854ddd3eaf", "namespaceRepositoryOwnerMatched": true, "package": { "registry": "npm", "identifier": "mcp-postgres-server", "version": "0.3.1", "integrity": "sha512-0FFBZlA/xc8A/JIQVfMD+jFZovmk6amYovuF+YfBEwZRpooc7Q4pDi3QRSMCPWYdUGWnAEGBhKGKBUzMAyK+FQ==", "packageRepositoryMatched": true, "checkedAt": "2026-10-21T01:04:45.326Z" }, "scope": "Install configuration verified; dependency implementation and remote behavior have not been audited" } }