Postgres (read Only) logo

Postgres (read Only)

Read-only Postgres access with schema discovery, safe SQL queries, and editable table context for MCP clients.

Install Postgres (read Only)

Pick your client, then add it in one click or paste the config.

STDIONode.js
~/Library/Application Support/Claude/claude_desktop_config.json
claude_desktop_config.json
{
  "mcpServers": {
    "postgres-read-only": {
      "command": "npx",
      "args": [
        "-y",
        "@contextflo/postgres-mcp"
      ],
      "env": {
        "DATABASE_URL": "YOUR_VALUE_HERE"
      }
    }
  }
}

Settings → Developer → Edit Config, merge this into mcpServers, then fully quit and reopen Claude Desktop.

Values are written into the snippet above so you can paste it as is. They never leave your browser.

We couldn’t confirm it starts correctly

The install command started, but didn't respond the way we expected when we tried to talk to it.

npx -y @contextflo/postgres-mcp

initialize succeeded but no response to tools/list.

This is an experimental automated check and can have false negatives — missing environment variables, a slow cold install, etc. It doesn’t necessarily mean something’s wrong. Last checked .

Overview

Postgres (read-only) MCP server gives agents read-only access to a PostgreSQL database through SQL queries and schema-aware tools. It supports table discovery, detailed table context, and shared Markdown notes that agents can update with business-specific gotchas. Reach for it when an agent needs analytics access without write capability and should understand curated database context. Setup uses a PostgreSQL read-only role, a DATABASE_URL connection string, and an optional generated context file.

Use cases

  • Query analytics data without permitting writes
  • Discover readable tables and schema relationships
  • Give agents curated business definitions for database fields
  • Record undocumented table and column behavior
  • Inspect PostgreSQL metadata with generated SQL

Key features

  • Read-only SELECT, EXPLAIN, SHOW, and CTE queries
  • Table listing with name and description matching
  • Schema context with keys, types, enums, and foreign keys
  • Editable Markdown context file
  • Read-only transaction and parser validation
  • PostgreSQL schema resources

Tools4

What Postgres (read Only) lets your agent do. Expand a tool for its parameters.

Self-reported~111 tokens of context

Security & health

What it can reach and how reliably it runs — from our own checks, not the maintainer’s claims.

ActiveLast checked

Recent health check succeeded.

12/12 checks healthy over the last 54d

Supply-chain signal

No high-severity advisories surfaced by our automated scan.

Critical 0High 0Medium 0Low 0

Scanned 8d ago via OSV.dev · @contextflo/postgres-mcp (npm)

Adoption & maintenance

Factual signals from GitHub, npm, and our automated checks — not a rating.

GitHub stars4Stargazers on the source repository.
npm downloads1kPackage downloads in the last 30 days.
Last commit1mo agoMost recent push to the default branch.
Install checkInconclusiveStarted but did not complete the MCP handshake in our test.
Tools exposed4Callable tools this server registers over MCP.
Directory activity2 viewsConfig copies, upvotes, and views on AllMCPs.

How Postgres (read Only) works

What Postgres (read-only) MCP server does

Postgres (read-only) MCP server exposes PostgreSQL data and schema information to MCP clients for analytics and investigation tasks. Agents can run permitted read-only SQL, find readable tables, inspect their structure, and record notes about details that are not represented in the database schema.

The server is designed as a replacement for the archived @modelcontextprotocol/server-postgres package. Its read-only behavior is reinforced through the PostgreSQL protocol, connection settings, SQL parsing, and database permissions rather than relying on a single string check.

How it works

The query tool accepts one statement from the supported read-only categories: SELECT, WITH ... SELECT, EXPLAIN, or SHOW. Statements run through PostgreSQL's extended query protocol inside an explicit read-only transaction that is rolled back after execution.

Before execution, the SQL is parsed with a PostgreSQL parser compiled to WebAssembly. The server walks the complete parse tree, including nested data-modifying expressions, and rejects unsupported or unknown constructs. Function calls are checked against PostgreSQL metadata; volatile functions and security-definer functions are generally refused, with a small allowlist for harmless functions needed by analysis.

A database role without write permissions provides an additional enforcement layer. This matters because read-only access limits what the connected identity can change, but it does not limit which permitted data the agent can read. The README also recommends using a replica or branch where possible because read-only queries can still consume substantial database resources.

The context file is shared between the team and the agent. It is seeded from table comments by the init command, can be edited manually, and can receive notes through add_table_context. Table schema resources using postgres://<host>/<table>/schema are also exposed for clients that use MCP resources.

Setup and configuration

Create a PostgreSQL login role with CONNECT on the database, USAGE on the relevant schemas, and SELECT on the tables the agent should access. Grant default SELECT privileges if new tables should be visible automatically. The server warns when it connects as a superuser, and initialization reports if the connected role can write.

Set DATABASE_URL in a .env file in the directory where the server starts. The connection string can include provider options such as SSL settings. Start the package with npx @contextflo/postgres-mcp postgresql://localhost/mydb, or configure the client to run npx -y @contextflo/postgres-mcp while supplying the environment variable.

Run npx @contextflo/postgres-mcp init to create .contextflo/context.md. Use --context-file when the client starts outside the project directory. A 30-second statement timeout is available by default and can be changed with --statement-timeout; a row cap also limits returned results.

Tools and capabilities

  • query runs one permitted read-only SQL statement.
  • list_tables returns readable tables and descriptions; pattern searches table names and descriptions.
  • get_table_context returns columns, types, keys, foreign-key targets, enum values, and curated descriptions.
  • add_table_context appends an agent-discovered note to the context file.
  • SQL against information_schema and pg_catalog can provide more specialized discovery without a separate search tool.

Limitations and notes

The Postgres (read-only) MCP server does not include a dedicated search tool. Agents must write SQL for searches such as locating columns by name. Read-only enforcement does not prevent expensive full-table scans or joins, so a replica or branch is preferable when available.

A user-defined function mislabeled as STABLE, or a side effect reached indirectly through a view, operator, or cast, may not be identified by the function checks. The read-only database role remains the recommended protection. Anything readable by that role is potentially readable by the agent.

Written by AllMCPs with AI assistance from the project’s README and listing data. How we build listings

Reviews

No reviews yet — be the first to share how it worked for you.

Frequently Asked Questions about Postgres (read Only)

Postgres (read-only) is an MCP server that connects AI clients to PostgreSQL databases for safe analytics access. Its main tools run one read-only query, list readable tables, describe table structure, and save schema or business-context notes in a shared Markdown file. It is intended for agents that need database visibility without write access.

Install and run it with `npx @contextflo/postgres-mcp`, then provide a PostgreSQL connection and configure the MCP client to launch the package. Create a database role with only the required read permissions, set `DATABASE_URL` in `.env`, and run `npx @contextflo/postgres-mcp init` to generate the context file.

Yes, Postgres (read-only) works with Cursor through `.cursor/mcp.json`. Configure Cursor to run `npx -y @contextflo/postgres-mcp`, pass `DATABASE_URL` in the environment, and provide `--context-file` if Cursor starts the process outside the project directory.

Postgres (read-only) blocks writes through several layers: extended-protocol execution, read-only transactions, PostgreSQL parse-tree validation, and a database role without write privileges. It also rejects disallowed functions and security-definer functions, while the database role provides protection if server-side checks miss an indirect side effect.

Related MCP servers

Add a badge to your READMEShow it’s listed — live SVG, Markdown or HTML.

AllMCPs Directory Badge

Full Badge Customizer

Showcase your server listing on GitHub or your project documentation. Embed this dynamic SVG badge to highlight official listing status and live engagement.

Badge Style:
Live Dynamic SVG PreviewPostgres (read Only) AllMCPs Directory Badge
Markdown (GitHub README)
[![AllMCPs](https://allmcps.com/api/badge/postgres-read-only?style=directory)](https://allmcps.com/mcp/postgres-read-only)
HTML Embed
<a href="https://allmcps.com/mcp/postgres-read-only"><img src="https://allmcps.com/api/badge/postgres-read-only?style=directory" alt="Postgres (read Only) on AllMCPs" /></a>