LabscoMCP early access ↗
pugltdMCP SERVER

MCP Postgres Secure

Explore a PostgreSQL database and run SELECT, WITH, EXPLAIN and SHOW — with writes absent from the tool surface rather than blocked by convention.

by pugltd ↗Relational SQL DatabasesCommunity

LABSCO SUMMARY

Read-only by default, and enforced twice: the write tool is not registered and the database session refuses writes.

Plenty of database servers offer a read-only mode. Here readonly is the default and it holds at two levels: the write tool, execute, is not registered at all, and the PostgreSQL session itself runs with default_transaction_read_only on. Writes come back only when someone starts it with --access-mode dml or full, or sets PG_ACCESS_MODE — so that flag, and a least-privilege database role for each mode, are what to check before a model that will eventually try to fix a problem by writing gets near production. The three introspection tools are what make the read side actually usable — an agent that can read the schema writes a query that runs, and one that cannot writes a query about columns it imagined.

What it is

A PostgreSQL client that starts in read-only mode with five tools: connect, query, and three that describe the database — schemas, tables and a single table's structure. A sixth, execute, is registered only in dml or full mode.

What you get

  • query accepts SELECT, WITH, EXPLAIN and SHOW, and nothing else; in the default readonly mode there is no write tool at all.
  • list_schemas, list_tables and describe_table give an agent the structure it needs to write a correct query instead of guessing at column names.
  • connect_db is documented as being for the case where no default connection exists, so the normal path is configured rather than passed per call.

Requirements

A PostgreSQL connection, normally configured as the default rather than supplied per call.

Setup effort

One command plus credentials — npx mcp-postgres-secure --access-mode readonly, then supply credentials