Databases / PostgreSQL

PostgreSQL

io.github.antonorlov/mcp-postgres-server · v0.3.1

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

Description supplied by the publisher in the MCP Registry. We have not tested this server.

Ranks #46 of 196 Databases servers on Socketlist by score, with 25 GitHub stars and a last code push 2mo ago.

Install

npx -y mcp-postgres-server

Assembled from the package metadata in the official MCP Registry (including any subcommand or flag the publisher lists). Some publishers do not list the subcommand that starts MCP mode, so confirm the command in the README, along with any required configuration and credentials, before connecting it to real data.

Connect PostgreSQL to Claude Code, Cursor or VS Code

Built from what the publisher declared in the official MCP Registry (the launch command above). We have not run this server. Replace anything in <angle brackets>, and keep keys and tokens in your environment, not in a shared file.

Claude Code

Run in a terminal. Adds the server at local scope; add --scope project or --scope user to share it. Secret variables the publisher declares are included; drop any the README says are optional. Claude Code setup guide.

claude mcp add --env DATABASE_URL=<database_url> --env PG_PASSWORD=<pg_password> --env PG_SSH_PASSPHRASE=<pg_ssh_passphrase> --env PG_SSH_PASSWORD=<pg_ssh_password> --transport stdio postgresql -- npx -y mcp-postgres-server

.mcp.json (Claude Code project scope, VS Code with Copilot)

Put this in a .mcp.json file at the project root. ${NAME} reads the value from your environment, so no secret is written to the file. VS Code and .mcp.json guide.

{
  "mcpServers": {
    "postgresql": {
      "type": "stdio",
      "command": "npx",
      "args": [
        "-y",
        "mcp-postgres-server"
      ],
      "env": {
        "DATABASE_URL": "${DATABASE_URL}",
        "PG_PASSWORD": "${PG_PASSWORD}",
        "PG_SSH_PASSPHRASE": "${PG_SSH_PASSPHRASE}",
        "PG_SSH_PASSWORD": "${PG_SSH_PASSWORD}"
      }
    }
  }
}

Cursor

Put this in .cursor/mcp.json in the project, or ~/.cursor/mcp.json for every project. Cursor mcp.json guide.

{
  "mcpServers": {
    "postgresql": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-postgres-server"
      ],
      "env": {
        "DATABASE_URL": "${env:DATABASE_URL}",
        "PG_PASSWORD": "${env:PG_PASSWORD}",
        "PG_SSH_PASSPHRASE": "${env:PG_SSH_PASSPHRASE}",
        "PG_SSH_PASSWORD": "${env:PG_SSH_PASSWORD}"
      }
    }
  }
}

Configuration the publisher declares

Environment variableRequiredSecretPublisher's note
DATABASE_URLNoYesFull connection string (preferred). Supports sslmode in the URL.
PG_HOSTNoNoDatabase host (fallback when DATABASE_URL is not set).
PG_PORTNoNoDatabase port.
PG_USERNoNoDatabase user.
PG_PASSWORDNoYesDatabase password.
PG_DATABASENoNoDatabase name.
PG_ALLOW_WRITENoNoWhen 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_SSLMODENoNoTLS 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 se
PG_SSL_CANoNoPath to a CA certificate file. Setting it by itself implies verify-full.
PG_ENABLE_RUNTIME_CONNECTNoNoRegister the connect_db tool (runtime credential switching).
PG_MAX_RESULT_BYTESNoNoByte 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_TIMEOUTNoNoStatement timeout in milliseconds, applied to every session.

10 more are listed in the registry entry; see the README for the full set.

"Required" and "secret" are the publisher's own flags in the registry, and many publishers leave them unset, so check the README too.

Allowlist entry

If your organisation restricts MCP servers, this is the entry an admin adds to allowedMcpServers in Claude Code managed settings or a GitHub Copilot enterprise managed-settings.json. A serverCommand entry must match the configured command and arguments exactly, so change both together.

{
  "allowedMcpServers": [
    {
      "serverCommand": [
        "npx",
        "-y",
        "mcp-postgres-server"
      ]
    }
  ]
}

How allowlists work in each client: MCP server allowlists for Claude Code, GitHub Copilot and Cursor. Before you connect it to real data: 10 security checks for MCP servers.

Signals

GitHub stars25
npm weekly downloads983
Last push2mo ago
LicenceMIT
Open issues1
SECURITY.mdYes
LanguageTypeScript
Latest version published2026-09-14

Signals captured from GitHub, npm and the official MCP Registry on November 11, 2026. See the scoring method.

Similar servers compare all →

read-only-local-postgres-mcp-server

Score 76

MCP server for read-only PostgreSQL database queries in Claude Desktop

★ 2MITpushed 26d ago
Databases

Mnemosyne

Score 93

Evidence-tracked local memory MCP server: one SQLite file; corrections retire dependent memories.

★ 159↓ 774/wkMITpushed 18d ago
DatabasesAI & media

dbmcp

Score 90

Database MCP server for MySQL, MariaDB, PostgreSQL & SQLite with PII redaction and write-prevention

★ 33↓ 570/wkMITpushed 18d ago
Databases

Five MCP servers worth your time, every week

The Plug Weekly is a free email picked from these scores. About a 3-minute read. Unsubscribe any time.

Subscribe free