MCP.Market

Pg Readonly MCP server

by les-k·io.github.les-k/pg-readonly-mcp·v0.1.1

A read-only Postgres MCP server that parses SQL rather than pattern-matching it.

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

full report

Adoption
New

0 stars

Reviews

Write one

Nobody has reviewed Pg Readonly yet.

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

Pg Readonly tools (1)

write = sends, deletes, buys or posts

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

  • query

Public scan report

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

no findings
  • Code scan5 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 0 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 Pg Readonly 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
1
the typical Databases server has 8
Tools that change things
0%
typical: 10%. Fewer write tools means less an agent can break

What its tools let an agent do: 1 read

Install Pg Readonly in Claude Code, Cursor or VS Code

claude mcp add pg-readonly-mcp -- uvx pg-readonly-mcp
Add to Cursor

What the publisher says

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

<!-- mcp-name: io.github.les-k/pg-readonly-mcp -->

pg-readonly-mcp

In plain terms: this lets an AI look at your database and do nothing else.

Not because it was told not to write — the database login it uses is physically

incapable of writing. The official version of this tool had a published flaw

that let a "delete everything" command slip past its safety check; this one is

tested against that exact attack.

A read-only Postgres MCP server that parses SQL rather than pattern-matching it — because the alternative has already failed in public, once, in a way that is worth being specific about.

The bypass this exists to close

Anthropic's reference Postgres MCP server enforced "read-only" by wrapping each query in a read-only transaction. It also accepted semicolon- delimited multi-statement input. That combination is exploitable:

SELECT 1; COMMIT; DROP SCHEMA public CASCADE;

The COMMIT ends the read-only transaction early. Everything after it runs at full session privilege. Datadog Security Labs disclosed this in 2026; the server was deprecated and archived — and the vulnerable package was still pulling 21,000 weekly downloads after that.

A read-only transaction is a property of how a query runs. It says nothing about what the query is, which is exactly why it was possible to talk your way out of it. This server checks the second thing instead.

Two independent layers

Either one alone would have stopped the disclosed bypass. Both exist because a flaw in one should not be the only thing standing between an agent and a write.

1. The SQL is parsed, not scanned. guard.py uses sqlglot to build a real syntax tree and applies three checks:

semicolons the way a driver would, so the payload above becomes three statements and is refused before any of them reach a connection.

  • Exactly one statement. sqlglot.parse splits on statement-terminating

EXCEPT, or a CTE built from those. DROP TABLE users is refused here.

  • The outer statement is a read shape — SELECT, UNION, INTERSECT,

other two cannot replace: Postgres allows a CTE to carry a data-modifying statement, so WITH x AS (DELETE FROM t RETURNING ) SELECT FROM x is, at the outer level, a SELECT. A check that only looks at the outer shape misses this completely. Walking every node finds the DELETE regardless of how many levels down it sits.

  • No write anywhere in the tree, walked in full. This is the check the

An unrecognised statement shape — anything sqlglot has no specific rule for — is refused by the same rule as everything else. Unfamiliar is not the same as safe.

2. The connection itself cannot write, independent of what it is asked to run. checkconnectionis_readonly refuses to start if the connected role is a superuser, can create databases or roles, can bypass row-level security, or holds any grant beyond SELECT on any table it can see. Not exhaustive — Postgres privilege can also arrive through ownership, PUBLIC grants, or RLS policies this check does not enumerate — but it catches the two ways a misconfiguration most commonly shows up, stated here rather than implied.

What it does not protect against

Shortened. The full README is on GitHub.

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

Pg Readonly: common questions

Is Pg Readonly MCP server safe?
Mostly: it is graded B (83/100). Read the Pg Readonly safety report
How do I install Pg Readonly?
It runs on your machine. Copy the Claude Code, Cursor, VS Code or Claude Desktop config from the install section.
Does Pg Readonly need an API key?
Yes. The registry entry asks for PG_READONLY_MCP_DSN.
Is Pg Readonly maintained?
The last commit was 33 days ago (2026-10-02). The latest release is v0.1.1.
What can I use instead of Pg Readonly?
Servers from other publishers that do the same job: DBHub MCP server, Appwrite MCP server and Motherduck MCP server.
How does Pg Readonly compare with other Databases MCP servers?
safety score 83/100 (higher than 60% of 802 Databases servers); tools 1 (the typical Databases server has 8); tools that change things 0% (typical: 10%. Fewer write tools means less an agent can break). Full comparison.

Alternatives to Pg Readonly

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

  • DBHub
    Token-efficient database MCP server for PostgreSQL, MySQL, MariaDB, SQL Server, Oracle, SQLite
    A
  • Appwrite
    Build and deploy backends: auth, Postgres/MySQL/vector databases, storage, functions, hosting, CDN
    A
  • Motherduck
    SQL analytics and data engineering for AI Assistants and IDEs
    A
  • Keboola
    Connect your AI assistants to Keboola and expose your data, transformations, SQL queries, ...
    A
  • 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

More from les-k →