Read-only PostgreSQL over MCP. Writes refused at the parsed SQL, plus a READ ONLY transaction.
Copy the AI prompt to install this server into Claude Code, Cursor, or another agent β or use 1-click editor setup below.
We haven't yet run this listing's install command through our automated sandbox check. This isn't a red flag β we're steadily working through the catalog.
π‘ Paste the JSON block into your client's configuration file under mcpServers, then restart the application.
Inspect callable tools, capabilities, and parameters exposed to AI agents by PostgreSQL (hardened, read Only).
explain_queryCallable MCP tool function
analyzeCallable MCP tool function
database_healthCallable MCP tool function
analyze_indexesCallable MCP tool function
top_queriesCallable MCP tool function
pg_stat_statementsCallable MCP tool function
π§ Version 0.1.10 β the rest of an outside review, and a fix that was too blunt
Published: binaries for five platforms with checksums, Sigstore signatures and build provenance;
.mcpbbundles for one-click install; an image onghcr.iofor amd64 and arm64; a package on npm; and an entry in the official MCP registry.0.1.8 and 0.1.9 closed six bypasses that four independent reviewers found in 0.1.7, none of them found by us. Two days of our own adversarial work had come back mostly clean the day before. Passing the tests you thought to write is not the same as looking. The one that mattered most needs no privileges at all: with a column redacted, a join on it through
USINGanswered whether a given value was present, which is a complete equality oracle against the least-privilege reader this project tells you to configure.0.1.10 closes the three findings that were left open. With
MCP_ALLOW_SCHEMAS=public,SELECT * FROM secret.salarieswas refused whiledescribe_tablehanded over every column, type and default of that same table. An ordinary connection string carrying nosslmodeused the driver'sprefer, which sends everything in the clear whenever the server declines TLS, and anyone on the wire can make it decline. AndMCP_SSLROOTCERTadded a private certificate authority to 242 public ones instead of replacing them, so an operator who believed they had pinned trust to their own issuer had not.The first version of that TLS fix was wrong in a way worth reading about. It asked "is this loopback" and demanded TLS from everything else, which took down six PostgreSQL version jobs, the conformance run, the container check and the adversarial corpus in a single push. All of them reach the database the way ordinary deployments do:
postgres://user:pass@postgres:5432/db, a service name on a private network. Docker Compose and Kubernetes are not the public internet, and a server that demands TLS from a container on a bridge network is a server people switch off entirely. The question is now whether somebody untrusted can sit on the wire, not whether the address is loopback, and a real socket to a PostgreSQL reachable only by service name is in the test suite, because a rule about networks should be tested over a network.A resource limit is documented and not solved, in
THREAT_MODEL.md: 49 bytes of SQL make PostgreSQL fold a constant into 5.9 GB of backend memory during planning, and a five secondstatement_timeoutdoes not stop it. The obvious shapes are refused; the general problem is upstream of anything this server can do.Every change here was reproduced against a running server before being fixed, and each is in
CHANGELOG.mdwith the query.Everything here is 0.1.x because nobody outside this project has run it against their own data.
The official Postgres MCP server was deprecated in 2024 and still gets 391k downloads a month. Its entire defence is one database-level read-only transaction β and that alone does not stop every write. This is a maintained Rust replacement with defence in depth.
A drop-in Model Context Protocol server that lets an AI agent query PostgreSQL β read-only, enforced at the database level, with real SQL validation, timeouts, cost limits, OAuth 2.1, and an audit trail. Speaks Streamable HTTP and stdio, and negotiates the MCP revision: 2026-07-28 (current, and the default since upstream released it on 2026-08-03), 2025-11-25, and 2025-06-18 β what most shipping clients still speak today. A client asks for what it knows; it is not negotiated down.
The read-only guard has an offline mode. Hand it a statement and it says what it decided: no database, no configuration, nothing installed permanently.
If something that writes comes back ALLOW, that is the most valuable thing anyone can send us.
It needs no working exploit and no write-up β one line of SQL and "this should not be allowed" is a
complete report. Anything that gets past the guard goes through SECURITY.md;
everything else is an ordinary issue, and the bar for opening one is this looks wrong to me, not
I am certain.
The fuzzer is deterministic and prints its seed, so whatever it finds reproduces on a machine that has never seen yours β a million mutations take about a minute:
For the whole thing against a real database, docker compose -f examples/docker-compose.yml up -d
brings up PostgreSQL with sample data and the server in front of it, connecting as a role that holds
SELECT and nothing else.
Every bypass found so far lives in the MUST_REJECT corpus in src/validate.rs and runs on every
commit, recorded with what it cost rather than tidied away. Yours would join them.
@modelcontextprotocol/server-postgres is deprecated on npm (last publish December 2024) and
still sees 475,790 downloads in the 30 days to 9 August 2026. Credit where it is due: its approach is not naive β it
wraps each query in BEGIN TRANSACTION READ ONLY and always ROLLBACKs, which is a real defence
and one this server now adopts as well.
The problem is that it is the only defence, and it is not complete:
A read-only transaction does not block every write, and a rollback does not undo everything it lets through. Two separate facts, and the second is the one that matters.
gin_clean_pending_list() runs inside SET TRANSACTION READ ONLY and its work survives the
rollback: an index with 25 pending pages has 0 after the transaction is rolled back.
pg_backup_start() puts the session into backup state, survives DISCARD ALL, and with the
default fast => false waits for a spread checkpoint while forcing full_page_writes on, which
is a real cost on a busy server. pg_import_system_collations() also executes without raising
SQLSTATE 25006, but be careful how much weight you put on it: that one IS undone by a
rollback, so against a server that always rolls back it is a curiosity rather than a bypass.
Reproduce it, but read the two preconditions first, because without them you will see a zero or an error and conclude we made this up. All three need superuser or ownership of the object. And the import only restores collations that are missing, so something has to be removed first:
Both are writes, both are inside a read-only transaction, and one is refused while the other is not. That asymmetry is why this server does not treat the transaction as its only defence. It is also why the role matters more than any of this: every example above needs privileges a least-privilege reader does not have, and this server refuses to start as a network listener when the role it was given can write. What it cannot control is which connection string somebody pastes into a client config, and the usual answer is whichever one they already had.
No statement timeout, no cost guard, no row limit β one query can run until the server gives up.
No authentication, no audit trail, no handling of prompt injection through returned row data.
One source file of 143 lines, unmaintained since December 2024, no test suite.
This server keeps the rollback, adds AST validation in front of it, and adds the operational layers the original never had.
postgres-mcp-hardened vs the archived originalFactual signals from GitHub, npm, and our automated checks β not a rating.
No reviews yet β be the first to share how this listing worked for you.
Showcase your server listing on GitHub or your project documentation. Embed this dynamic SVG badge to highlight official listing status and live engagement.
[](https://allmcps.com/mcp/postgresql-hardened-read-only)<a href="https://allmcps.com/mcp/postgresql-hardened-read-only"><img src="https://allmcps.com/api/badge/postgresql-hardened-read-only?style=directory" alt="PostgreSQL (hardened, read Only) on AllMCPs" /></a>