Read-only PostgreSQL over MCP. Writes refused at the parsed SQL, plus a READ ONLY transaction.
MCPpedia last refreshed this data
io.github.Eszetael/postgres-mcp-hardened is an MCP server that read-only PostgreSQL over MCP. Writes refused at the parsed SQL, plus a READ ONLY transaction. Its tool list has not been published yet over stdio and http, requires no API key, and scores 89/100 on MCPpedia's security, maintenance and efficiency rubric.
Config is the same across clients - only the file and path differ.
{
"mcpServers": {
"postgres": {
"env": {
"DATABASE_URL": "postgres://readonly_user:YOUR_PASSWORD@localhost:5432/mydb"
},
"args": [
"--stdio"
],
"command": "postgres-mcp-hardened"
}
}
}Are you the author?
Add this badge to your README to show your security score and help users find safe servers.
Read-only PostgreSQL over MCP. Writes refused at the parsed SQL, plus a READ ONLY transaction.
This server supports HTTP transport. Be the first to test it - help the community know if it works.
Five weighted categories - click any category to see the underlying evidence.
No known CVEs.
Checked postgres-mcp-hardened against OSV.dev.
Be the first to review
Have you used this server?
Share your experience - it helps other developers decide.
Sign in to write a review.
Others in data / finance
Token-efficient MCP server for PostgreSQL, MySQL, MariaDB, SQL Server, Oracle, ClickHouse, SQLite
DataForSEO API modelcontextprotocol server
Extract data from any website with thousands of scrapers, crawlers, and automations on Apify Store ⚡
Search, scrape, and crawl the web, plus Firecrawl Alexandria, our library of everything else.
MCP Security Weekly
Get CVE alerts and security updates for io.github.Eszetael/postgres-mcp-hardened and similar servers.
Start a conversation
Ask a question, share a tip, or report an issue.
Sign in to join the discussion.
A hardened, read-only Rust replacement for the deprecated @modelcontextprotocol/server-postgres: an MCP server that lets an AI agent query PostgreSQL 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.
Add it to your MCP client (Claude Desktop, Cursor, Claude Code) — there is no Node runtime at run time, the npm package is a launcher that fetches the native binary for your platform and verifies its checksum before running it:
{
"mcpServers": {
"postgres": {
"command": "npx",
"args": ["-y", "postgres-mcp-hardened", "--stdio"],
"env": { "DATABASE_URL": "postgres://readonly_user:PASSWORD@localhost:5432/mydb" }
}
}
}
The connection string goes in env, not in args, on purpose: arguments show up in ps output and
in shell history on a shared machine, and a database password does not belong there. Use a
least-privilege read-only role (--print-setup-sql writes the statements). Other ways in: Install.
To try the whole thing against a real database first, 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.
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.
npx postgres-mcp-hardened --validate "/* comment */ DROP TABLE users"
# REJECT: non-read-only statement: Drop
npx postgres-mcp-hardened --validate "SELECT 1; DROP TABLE users"
# REJECT: multiple statements are forbidden
npx postgres-mcp-hardened --validate "WITH d AS (DELETE FROM t RETURNING *) SELECT * FROM d"
# REJECT: non-read-only statement: non-read-only query (CTE / SELECT INTO / FOR UPDATE)
npx postgres-mcp-hardened --validate "SELECT * FROM orders WHERE id = 1"
# ALLOW
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:
npx postgres-mcp-hardened --fuzz 1000000
# fuzz: 1000000 iterations, seed 1592594996, slowest validation 8 ms
# RESULT: 0 invariant violations
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 hundreds of thousands of monthly downloads:
581,980 downloads in the 30 days to 28 November 2026 ([npm](https: