MCP.Market

PostgreSQL MCP server

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

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

B83/100grade B
What users say
No reviews yet
Be the first
Safety scan
B83/100

full report

Adoption
Established

23 stars1.2k downloads/wk

Reviews

Write one

Nobody has reviewed PostgreSQL yet.

If you have run it, two minutes of your experience saves the next person an afternoon.

PostgreSQL tools (6, 1 write)

write = sends, deletes, buys or posts

Read from the package source without running it. The installed server may list more.

  • connect_db

    Switch the server to a different PostgreSQL database at runtime, replacing the current connection.

  • describe_table

    Show the structure of one table: column names, data types, nullability, defaults, and primary-key membership. Call this before writing non-trivial queries against a table.

  • executewrite action
  • list_schemas

    List every schema in the connected database. Start here when exploring an unfamiliar database, then call list_tables for the schema you care about.

  • list_tables

    List all tables in a schema (default: 'public'). Use this before querying tables you have not seen yet, then call describe_table for column details.

  • query

Public scan report

scanner v0.1.10 · 2026-10-03 · same rubric, same numbers if you re-run it

no findings
  • Code scan4 source files scanned25/25
  • –Live reliabilityno gateway calls yet and no remote to proben/a
  • –Tool poisoningtools not inspected (local package is not executed); not countedn/a
  • Auth qualitystatic API keys via environment variables6/15
  • Maintenancelast push 17 days ago15/15
  • Maintainer identityregistry namespace matches repository owner; GitHub account older than a year8/10
Overall 83/100. Components that don't apply are left out of the denominator. Any critical finding is an F.RubricAppeal a findingJSON

How PostgreSQL compares

Against every graded Databases MCP server, from our own scans and uptime checks. Updated after each scan run.

Safety score
83/100
higher than 60% of 802 Databases servers
Tools
6
the typical Databases server has 8
Tools that change things
17%
typical: 10%. Fewer write tools means less an agent can break
GitHub stars
23
more than 85% of 602 Databases servers
Downloads a week
1,206
more than 91% of 328 Databases servers with a package

What its tools let an agent do: 5 read · 1 run or deploy

Install PostgreSQL in Claude Code, Cursor or VS Code

Runs npx -y mcp-postgres-server on your machine. Read the scan report first; the gateway never runs local packages.

claude mcp add mcp-postgres-server -- npx -y mcp-postgres-server
Add to Cursor

What the publisher says

From the PostgreSQL repository's README, as published. We do not edit it. Read it on GitHub

MCP PostgreSQL Server

A Model Context Protocol (MCP) server for PostgreSQL: local, Docker, RDS, Neon, and Supabase databases.

The server is small and auditable, with four runtime dependencies: the MCP SDK, pg, pg-connection-string, and zod (plus ssh2, an optional dependency used only for SSH tunneling).

Requires Node.js 20 or newer.

Quick start

The preferred way to configure the server is a single DATABASE_URL:

{
  "mcpServers": {
    "postgres": {
      "type": "stdio",
      "command": "npx",
      "args": ["-y", "mcp-postgres-server"],
      "env": {
        "DATABASE_URL": "postgres://user:password@localhost:5432/mydb",
        "PG_ALLOW_WRITE": "false"
      }
    }
  }
}

With PGALLOWWRITE set to "false" the server has read-only access to the database. This is the default; set it to "true" only if the model must write.

The same JSON works in any MCP client that speaks stdio: VS Code, Cursor, Claude Code, Codex, Windsurf.

Alternatively, set the individual PG variables; they are used when DATABASEURL is not set:

{
  "mcpServers": {
    "postgres": {
      "type": "stdio",
      "command": "npx",
      "args": ["-y", "mcp-postgres-server"],
      "env": {
        "PG_HOST": "your_host",
        "PG_PORT": "5432",
        "PG_USER": "your_user",
        "PG_PASSWORD": "your_password",
        "PG_DATABASE": "your_database",
        "PG_ALLOW_WRITE": "false"
      }
    }
  }
}

Manual Installation

npm install mcp-postgres-server

Or run directly with:

npx mcp-postgres-server

Connect to your database

Local Postgres:

DATABASE_URL=postgres://mcp_readonly:secret@localhost:5432/mydb

Postgres in Docker: if the database runs in a container with a published port, connect to localhost: as usual. If the MCP server itself runs inside a container and the database runs on your host machine, use host.docker.internal instead of localhost:

DATABASE_URL=postgres://mcp_readonly:secret@host.docker.internal:5432/mydb

Amazon RDS:

DATABASE_URL=postgres://mcp_readonly:secret@mydb.xxxxxx.us-east-1.rds.amazonaws.com:5432/mydb?sslmode=require

Neon:

DATABASE_URL=postgres://mcp_readonly:secret@ep-xxx-xxx.us-east-2.aws.neon.tech/mydb?sslmode=require

Supabase:

DATABASE_URL=postgres://postgres.xxxxxxxx:secret@aws-0-us-east-1.pooler.supabase.com:5432/postgres?sslmode=require

Tools

Tool availability depends on configuration:

1. query

Execute a read-only SQL statement. Accepts SELECT, WITH ... SELECT, EXPLAIN, and SHOW. One statement per call - multi-statement input is rejected by the extended query protocol. In read-only mode (the default) the statement runs as BEGIN READ ONLY, the query, and ROLLBACK - three commands, roughly two network round trips with pipelining - so the database itself refuses any write. With PGALLOWWRITE=true the statement is sent directly, without that wrapper, so a write run through query would execute - use execute for writes. Supports PostgreSQL-style $1, $2 prepared-statement parameters; values are bound by the driver and never spliced into the SQL text.

use_mcp_tool({
  server_name: "postgres",
  tool_name: "query",
  arguments: {
    sql: "SELECT * FROM users WHERE id = $1",
    params: [1]
  }
});

Shortened. The full README is on GitHub.

Nothing above is checked by us. What we check is on the safety report.

PostgreSQL: common questions

Is PostgreSQL MCP server safe?
Mostly: it is graded B (83/100). Read the PostgreSQL safety report
How do I install PostgreSQL?
It runs on your machine. Copy the Claude Code, Cursor, VS Code or Claude Desktop config from the install section.
Does PostgreSQL need an API key?
Yes. The registry entry asks for DATABASE_URL, PG_PASSWORD, PG_SSH_PASSPHRASE, PG_SSH_PASSWORD.
Is PostgreSQL maintained?
The last commit was 49 days ago (2026-09-16). The latest release is v0.3.1.
How does PostgreSQL compare with other Databases MCP servers?
safety score 83/100 (higher than 60% of 802 Databases servers); tools 6 (the typical Databases server has 8); tools that change things 17% (typical: 10%. Fewer write tools means less an agent can break). Full comparison.

Alternatives to PostgreSQL

Same job from other publishers: the closest match first, then the best rated.

All PostgreSQL alternatives →
  • Ekwo OS — open source accounting: ledger, invoices and VAT on your own Supabase or Postgres
    Double-entry books an agent keeps as the user: invoices, VAT returns, 174 country packs.
    A
  • Neon
    Official Neon MCP server for managing Neon projects and Lakebase Postgres databases.
    A
  • Postgres
    Enterprise PostgreSQL MCP server with NL queries, hybrid search (pgvector+BM25), and web UI
    A
  • Supabase
    MCP server for interacting with the Supabase platform
    A
  • DBHub
    Token-efficient database MCP server for PostgreSQL, MySQL, MariaDB, SQL Server, Oracle, SQLite
    A