▌BestMCPTools.org
PostgreSQL MCP logo

PostgreSQL MCP

Postgres access for AI: the archived reference server and maintained options

DatabaseOpen SourceClients with local stdio MCP supportEasy✓ Verified✦ Featured

Last verified: November 17, 2026

Maintenance status

Archived
License: MITChecked November 17, 2026

Archived: modelcontextprotocol/servers-archived was archived by its owner on May 29, 2025 (read-only, no fixes promised). Datadog Security Labs (August 21, 2025) documents a read-only bypass in the published package. Maintained options: crystaldba/postgres-mcp (MIT), googleapis/genai-toolbox (Apache-2.0). Read November 17, 2026.

How to Install PostgreSQL MCP

$claude mcp add --env DATABASE_URI=postgresql://user:pass@localhost:5432/db --transport stdio postgres -- docker run -i --rm -e DATABASE_URI crystaldba/postgres-mcp --access-mode=restricted

Compatible with: Clients with local stdio MCP support.

About PostgreSQL MCP

PostgreSQL MCP here means the original read-only Postgres reference server, @modelcontextprotocol/server-postgres, plus the options that replace it. That reference server now lives in modelcontextprotocol/servers-archived, which the owner archived on May 29, 2025. The repository page points to the maintained modelcontextprotocol/servers repository and says no security updates or bug fixes will be provided for archived servers. Security researchers have also documented a flaw in the published package, so this page is mostly about what to use instead.

Quick facts (as of November 17, 2026)

PostgreSQL MCP (reference server)
Package@modelcontextprotocol/server-postgres (also Docker image mcp/postgres)
Repositorymodelcontextprotocol/servers-archived, archived May 29, 2025, MIT
Transportstdio
Tool1: query (read-only SQL)
ResourcesTable schemas at postgres://<host>/<table>/schema
AuthA Postgres connection URL passed as an argument
PriceFree, open source; you pay for your own database

Status and a known security flaw

The reference server wraps each query in a READ ONLY transaction. Datadog Security Labs, in an article dated August 21, 2025, showed that this could be bypassed: the query function accepts several statements separated by semicolons, so an input that issues COMMIT; ends the read-only transaction and later statements run outside it. The article says the flaw was introduced in v0.1.0 (November 19, 2024), that Anthropic fixed it in an unreleased version on May 29, 2025, and that the published npm package (v0.6.2) and Docker image stayed unpatched. Its advice is to avoid the deprecated server where writes must be prevented, in particular in production. It names a Zed Industries fork, @zeddotdev/postgres-context-server v0.1.4, as fixed, and recommends a restricted-privilege Postgres user plus prepared statements.

This is the researchers' account, and we cite it so you can read it.

What to use instead

There is no single official Postgres server from the PostgreSQL project in the pages we read, so these are the maintained options we found in their repositories.

Postgres MCP Pro (crystaldba/postgres-mcp). MIT licensed and not shown as archived. Its README lists nine tools: list_schemas, list_objects, get_object_details, execute_sql, explain_query, get_top_queries, analyze_workload_indexes, analyze_query_indexes and analyze_db_health. It has an unrestricted mode (read and write, intended for development) and a restricted mode (read-only transactions with an execution time limit, intended for production). Install with docker pull crystaldba/postgres-mcp, pipx install postgres-mcp or uv pip install postgres-mcp. Transports are stdio (default) and SSE. The README says it focuses on Postgres 15, 16 and 17, with 13 through 17 planned.

MCP Toolbox for Databases (googleapis/genai-toolbox, renamed mcp-toolbox). Apache-2.0. Supports PostgreSQL, AlloyDB and Cloud SQL for PostgreSQL. Run it with --prebuilt=postgres (or postgres/data for SQL tools only). Its README shows npx -y @toolbox-sdk/server --prebuilt=postgres --stdio for client configs and an HTTP address of http://127.0.0.1:5000/mcp. It names list_tables and execute_sql as examples; the full tool list is in its prebuilt tools reference.

Hosted database platforms. If your Postgres is on Supabase or Neon, their own servers are an alternative: see Supabase MCP (https://mcp.supabase.com/mcp, with read_only=true and project_ref options) and Neon MCP (https://mcp.neon.tech/mcp, with ?readonly=true). Neon's docs recommend its server for development and testing, not production.

Setup

Postgres MCP Pro in Claude Desktop (Docker). From the project README:

{
  "mcpServers": {
    "postgres": {
      "command": "docker",
      "args": ["run", "-i", "--rm", "-e", "DATABASE_URI", "crystaldba/postgres-mcp", "--access-mode=restricted"],
      "env": {
        "DATABASE_URI": "postgresql://username:password@localhost:5432/dbname"
      }
    }
  }
}

The README example uses --access-mode=unrestricted; we changed it to restricted because the README describes restricted as the production mode. The config file is ~/Library/Application Support/Claude/claude_desktop_config.json on macOS and %APPDATA%/Claude/claude_desktop_config.json on Windows.

Claude Code. Claude Code's docs give this form for local stdio servers: claude mcp add --env KEY=value --transport stdio name -- command args. For example:

claude mcp add --env DATABASE_URI=postgresql://user:pass@localhost:5432/db --transport stdio postgres -- docker run -i --rm -e DATABASE_URI crystaldba/postgres-mcp --access-mode=restricted

Legacy reference server. Only if you accept the risk above, the README config is npx -y @modelcontextprotocol/server-postgres postgresql://localhost/mydb, with the URL format postgresql://user:password@host:port/db-name. With Docker on macOS use host.docker.internal rather than localhost.

Security guidance

  • Connect with a dedicated database role that has only SELECT on the tables you want exposed. The Datadog article says this is advisable but does not stop the session-state attack on the old server.
  • Point the server at a read replica or a copy, not production, while you evaluate it.
  • Do not rely on a "read-only" label alone. Treat any server that accepts free-form SQL as able to run what the role allows.
  • Keep tool approval on, and check generated SQL, since query results can contain untrusted text.

Pricing

All the servers above are free and open source. Your database costs, and any Supabase or Neon plan costs, are set by those providers. The Supabase docs page we read states that branching needs a paid plan; Neon's page does not state which plans include its MCP server. Status as of November 2026.

Pros and cons

Pros

  • The reference server is tiny: one query tool and automatic table schema resources.
  • Postgres MCP Pro adds explain plans, index analysis and health checks.
  • MCP Toolbox covers Postgres, AlloyDB and Cloud SQL under Apache-2.0.

Cons

  • The original package is archived and has a documented unpatched read-only bypass.
  • Maintained alternatives are third-party or platform-specific; none is run by the PostgreSQL project in the pages we read.
  • Unrestricted modes can change data and schema.

Who it is for

A good fit if: you want an assistant to explore a schema and write queries against a development or analytics copy of Postgres. For other engines see MySQL MCP or MongoDB MCP, and for an embedded file database SQLite MCP.

Not the right tool if: you would point the archived package at a production database and count on its read-only claim.

What we don't know

  • Whether the Zed fork or any other fork is still maintained today.
  • The complete prebuilt tool list for MCP Toolbox's Postgres mode.
  • Rate limits or performance of any option.
  • Behavior in practice. This page compares documentation and published research only.

How this page was put together

We read the archived Postgres README, the servers-archived and servers repository pages, the Datadog Security Labs article, the Postgres MCP Pro and MCP Toolbox repositories, and the Supabase and Neon MCP docs on November 17, 2026.

Sources

Pricing

Open Source: from Free (open source, as of November 2026); you pay for your own database

Our Take on PostgreSQL MCP

Do not use the archived reference package on production data; a maintained server with a restricted mode and a read-only role is the safer route.

Alternatives to PostgreSQL MCP

SQLite MCPDatabase

Query SQLite databases directly from your AI

View SQLite MCP →
Supabase MCPDatabase

Connects AI tools to your Supabase projects

View Supabase MCP →

Frequently Asked Questions

Tags