Postgres (read-only) MCP server
Read-only Postgres: drop-in for the archived server-postgres, with schema context.
2 stars58 downloads/wk
Reviews
Write oneNobody has reviewed Postgres (read-only) yet.
If you have run it, two minutes of your experience saves the next person an afternoon.
Postgres (read-only) tools (4, 1 write)
write = sends, deletes, buys or postsRead from the package source without running it. The installed server may list more.
add_table_contextRecord a durable fact about a table or its columns that you learned from working with the
get_table_contextDescribe one or more tables: columns, types, nullability, primary keys, foreign key
list_tablesList the tables, views, and materialized views this connection can read, with their
querywrite actionRun a read-only SQL query against the Postgres database. Accepts a single SELECT
Public scan report
scanner v0.1.10 · 2026-09-28 · same rubric, same numbers if you re-run it
- Code scan41 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 year9/10
Install Postgres (read-only) in Claude Code, Cursor or VS Code
Runs npx -y @contextflo/postgres-mcp on your machine. Read the scan report first; the gateway never runs local packages.
claude mcp add postgres-mcp -- npx -y @contextflo/postgres-mcp
What the publisher says
From the Postgres (read-only) repository's README, as published. We do not edit it. Read it on GitHub
@contextflo/postgres-mcp
The analytics MCP server for Postgres. Read-only by construction, with a context file you and the agent both write to, so the model answers the way your team would.
Built and maintained by Contextflo.
A drop-in replacement for the archived @modelcontextprotocol/server-postgres, which shipped with a SQL injection vulnerability that let COMMIT; DROP SCHEMA public CASCADE walk straight out of its read-only transaction.
Watch the 100-second demo: setup, the agent working out that an events table is not what it looks like and saving that as a note, and a DROP the server refuses.
npx @contextflo/postgres-mcp postgresql://localhost/mydbWhy this one
Read-only that holds up. The archived server enforced read-only as a property of the SQL string. Here it is a property of the wire protocol, the connection, the Postgres parser, and the database role: four independent layers, each of which stops that payload on its own. The exploit is a test case in this repo.
Answers that make sense. A model that does not know fctordersv2 is the table your team actually uses, or that revenue is gross rather than net, writes confident, wrong SQL. .contextflo/context.md is a markdown file you edit and this server hands to the model, with nothing behind it but the file. The agent adds to it too: when it learns something the schema does not say, addtablecontext appends a note, which you review in a diff like any other change.
Setup
1. Create a read-only role. Run this as the database owner, in psql or your provider's SQL editor. Use your database name and a real password, and repeat the schema lines for each schema the agent should see:
CREATE ROLE mcp_readonly LOGIN PASSWORD 'change-me';
GRANT CONNECT ON DATABASE mydb TO mcp_readonly;
GRANT USAGE ON SCHEMA public TO mcp_readonly;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO mcp_readonly;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO mcp_readonly;This makes read-only a property of the database, not just of this server's code.
2. Put that role's connection string in .env in your project folder:
DATABASE_URL='postgresql://mcp_readonly:change-me@db.example.com:5432/mydb'Keep the quotes: hosted providers add ?sslmode=require&..., and the & needs them. The server reads DATABASE_URL from .env in the directory it starts in, so the connection string never appears on a command line.
Point it at a read replica or a branch rather than your primary if you can. Read-only stops writes, not load: an agent exploring your data can run a full-table scan or a heavy join, and on the primary that competes with your application. Neon and Supabase can branch or replicate a database in a few clicks, and RDS, Cloud SQL, and most other hosts offer read replicas. The statement timeout (30 seconds by default, --statement-timeout) and the row cap limit how long one query runs and how much it returns; they do not make it cheap.
3. Generate the context file:
npx @contextflo/postgres-mcp initThat writes .contextflo/context.md, seeded from your COMMENT ON values. Edit it: the business definitions section is where the value is.
4. Add it to your client. Claude Code starts servers in your project folder, so it finds .env and the context file on its own:
claude mcp add postgres --scope project -- npx -y @contextflo/postgres-mcp--scope project writes .mcp.json into the folder instead of your global config.
Cursor, Claude Desktop, VS Code
Shortened. The full README is on GitHub.
Nothing above is checked by us. What we check is on the safety report.
Postgres (read-only): common questions
- Is Postgres (read-only) MCP server safe?
- Yes, by our scan: it is graded A (85/100). Read the Postgres (read-only) safety report
- How do I install Postgres (read-only)?
- It runs on your machine. Copy the Claude Code, Cursor, VS Code or Claude Desktop config from the install section.
- Does Postgres (read-only) need an API key?
- Yes. The registry entry asks for
DATABASE_URL. - Is Postgres (read-only) maintained?
- The last commit was 15 days ago (2026-09-28). The latest release is v0.1.4.
- What can I use instead of Postgres (read-only)?
- Servers from other publishers that do the same job: PostgreSQL MCP Server, Airtable MCP server and Run402 MCP server. Compare all Postgres (read-only) alternatives.
Alternatives to Postgres (read-only)
Same job from other publishers: the closest match first, then the best rated.
- PostgreSQL MCP ServerPostgreSQL MCP server - query, schema introspection, explain, and health checks for AI assistantsnot reviewedEstablishedB
AirtableRead and write access to Airtable database schemas, tables, and records.not reviewedEstablishedB- Run402x402 pay-per-call infra for agents: $0.03 image generation, Postgres, auth, storage, functions.not reviewedEstablishedB
- NeonOfficial Neon MCP server for managing Neon projects and Lakebase Postgres databases.not reviewedEstablishedA
- LINQ to DBInspect database schemas and execute SQL queries across multiple database providers with LINQ to DB.not reviewedEstablishedA