Pg Licht logo

Pg Licht

Read-only PostgreSQL MCP server for AI assistants: schema, statistics, plans, locks, replication and PgBouncer, read from the catalog. Never writes, never returns table rows.

Install Pg Licht

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

No confirmed install command yet

We only publish a config when the install details come from the project itself β€” its README, its docs, or a verified owner. We haven’t found those for pg_licht, and we’d rather show nothing than a guess you’d paste into your client.

Open setup steps on GitHub

Overview

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.

4/4 checks healthy over the last 15d

Adoption & maintenance

Factual signals from GitHub, npm, and our automated checks β€” not a rating.

GitHub stars11Stargazers on the source repository.
Last commit12d agoMost recent push to the default branch.

From the project README

pg-licht

A read-only PostgreSQL MCP (Model Context Protocol) server: it lets an AI assistant read a database's schema, statistics, plans, locks, replication and PgBouncer pools from the catalog. It never writes, and never returns rows from your tables.

Why another PostgreSQL MCP:

  • It answers from the catalog and the statistics views and never returns your rows, so there is far less to leak: the model sees structure, sizes, plans and counters.
  • Read-only is enforced, not promised: every call runs in its own READ ONLY transaction with a statement timeout, and no SQL is built from arguments. The one tool that executes a statement of yours refuses to when its plan writes or calls a volatile function.
  • One process serves the whole fleet. Any number of connections live in one file, and a question can be put to every database of an instance, a replication group or a label at once.
  • It answers what an operator asks β€” why is this slow, what is blocked, is the replica keeping up, does the pool keep up β€” and returns the evidence as PostgreSQL reports it.

Safety

Every catalog query is parameterized β€” no schema, table, or search-term argument is ever concatenated into SQL text. Every call to a database runs inside its own READ ONLY transaction, so even a bug that let a query attempt a write would fail rather than succeed silently. The pooler tools send a PgBouncer console only fixed SHOW commands, as the user you configure β€” one from its stats_users, which PgBouncer allows to run SHOW and nothing else. That guard is transaction-scoped rather than session-scoped, which is what makes it hold behind a connection pooler in transaction mode.

The same transaction sets statement_timeout, so no call can occupy a backend indefinitely. It defaults to two minutes and is per connection:

ini
[billing_prod]
service              = billing-prod
statement_timeout_ms = 600000      ; 0 removes the ceiling

Most operations are catalog reads that never approach it. The ones that can are those whose cost scales with the server rather than with the query β€” tableBloat with exact: true, indexBloat on a btree or hash index, bufferCacheContents, and listTableSizes on a wide schema β€” so raise it for a connection where such a scan is the point of the call. Reaching it is reported as the ceiling being reached, naming the value and the key to change, rather than as an error.

pg_licht never writes and never returns rows from your tables. Values from your data can still reach the caller in a few named places: live and recorded statement text (currentActivity, currentLocks, statementStats), column statistics (tableStats, columnHistogram), plans that repeat a statement's literals, definitions as written, and settings such as a standby's primary_conninfo. When an explained statement fails, PostgreSQL's message is returned only where it is about the statement as written, since a data error quotes the value that failed. explainQuery with analyze returns no row, and its row counts can still confirm a value the caller proposes. No password pg_licht itself holds is ever returned. Connect as the narrowest role that answers the question; checkPrivileges reports what it can reach.

Full rationale, including the guarded exception for explainQuery and the complete list of what reaches the caller, is in the SECURITY CONSIDERATIONS section of man pg_licht_mcp; SECURITY.md summarises it and says how to report a vulnerability.

Quick start

bash
brew tap sqlambda/pg-licht && brew install pg-licht

claude mcp add --transport stdio pg-licht \
  -e DATABASE_URL="postgresql://user:pass@host/dbname" \
  -- /usr/local/bin/pg_licht_mcp

man pg_licht_mcp

Other install channels β€” deb, rpm, tarball, source β€” are in INSTALL.md.

Remote databases

A tool call opens no connection of its own beyond the first: connections are held between calls and closed after 60 seconds idle, one per configured connection and at most 32 at a time. Startup opens none at all β€” the registry is validated without touching the network, so one unreachable database no longer prevents the server from starting.

The ceiling matters only above 32 configured databases, where the least recently used connection is dropped to make room and the next call to that database reconnects. It exists so a single wide sweep cannot hold one socket per member for a minute and exhaust a file-descriptor limit β€” macOS defaults to 256.

Fan-out sweeps visit up to 16 members concurrently, one connection per server. A thirteen-member replication group that took 449 ms sequentially takes 91 ms. The payload stays in configuration order regardless of which member answers first.

For databases across a WAN, a connection pooler in front of pg_licht is still worth running β€” it amortises the TLS handshake across restarts, and server_idle_timeout gives you the same idle policy at the pooler. Point every connections.ini entry at the local pooler and let its [databases] section carry the real hosts. Note that PgBouncer reads neither .pgpass nor service=, so that section has to be generated rather than shared, and in transaction mode it does not run server_reset_query at all by default.

Output format

A client that negotiates MCP revision 2025-06-18 or later receives structuredContent; every client receives the text block as well.

Both are sent by default, because a client can advertise a revision it does not fully implement and this server cannot tell. Set PG_LICHT_STRUCTURED_ONLY=1 to send only the structured payload once you have confirmed your client reads it, or PG_LICHT_MAX_PROTOCOL=2025-03-26 to refuse to negotiate anything newer.

Every tool declares an outputSchema to clients that can use it. The schemas describe but never reject: payloads here are version-conditional, and any tool may answer {error, hint} when an extension is absent.

Results that the protocol marks cacheable carry ttlMs and cacheScope. tools/list is about 171 kB (138 kB before MCP 2025-06-18, which carries no output schemas) and changes only when the connections file is reloaded, so it is hinted at one minute and scoped private β€” it varies by negotiated revision and names the configured default connection, so it must not be served to another caller from a shared cache. Catalog-derived results are hinted at one minute too.

List operations accept an opaque cursor and return nextCursor. The page size is larger than anything this server lists today, so a client that ignores cursors still sees every tool; resources/list is the one that grows, being connections Γ— schemas.

Resources and prompts

Structure is also served as resources β€” documents a client can browse and pin into context without a tool call:

Code
pglicht://{conn}/schemas
pglicht://{conn}/schema/{schema}
pglicht://{conn}/schema/{schema}/table/{table}
pglicht://{conn}/schema/{schema}/{functions,enums,types}
pglicht://{conn}/server/{roles,extensions,settings}

Readings stay tools, because the model has to decide when to take them. resources/list enumerates connections and schemas and reaches tables through a template, so a 10 000-table database does not produce a 10 000-entry response.

Thirteen prompts encode an order of investigation that is easy to get wrong: diagnose-slow-query, triage-lock-contention, diagnose-deadlock, triage-active-sessions, triage-disk-space, bloat-and-vacuum-review, buffer-cache-review, capacity-check, replication-slot-review, plan-schema-change, review-clustering, check-role-access and explain-and-fix. The triage- ones are written for a page rather than an investigation: they establish how long there is before they propose anything. They are static text and touch no database until the model acts on them, and each one whose tools are privilege-gated opens by calling checkPrivileges.

triage-disk-space is the one that arrives at night, and diskUsage is what makes it answerable without a shell on the server: WAL size, the archive backlog, the temp files present now, the log directory, and sizes per tablespace and per database. Only the headroom is unreachable β€” PostgreSQL exposes no function for free space. The prompt leads with what makes the obvious response wrong: VACUUM FULL needs free space equal to the table and its indexes before it releases any, so it is not a disk-full action.

Counts: 59 of 73 database operations for a bare login role, 67 with pg_monitor β€” the pg_ls_* directory reads diskUsage uses are part of what that role grants.

triage-active-sessions is for a server running more sessions at once than it has cores. Its first move is to stop trusting the word active: a backend waiting on a lock or a disk read is executing a statement, so only the ones with no wait event are competing for CPU, and parallel workers collapse into their leaders before anything is counted. Its second is that concurrency is arrival rate times duration β€” so it rises when statements get slower even though the load did not change, and more cores treat the symptom.

check-role-access answers whether a role can use a table, view, function or procedure β€” walking the gates in order, since the one people forget is USAGE on the schema and the resulting error names the table. It treats row-level security as a second gate that opens after the grants already said yes: RLS enabled with no applicable permissive policy is deny-all, so every grant checks out and the table returns nothing.

Reviews

No reviews yet β€” be the first to share how it worked for you.

Frequently Asked Questions about Pg Licht

pg_licht is an MCP server that lets AI assistants inspect PostgreSQL catalogs and statistics without writing to the database or returning table rows. It provides read-only visibility into schema, query plans, locks, replication, PgBouncer pools, sizes, and performance counters. Each call uses a read-only transaction and statement timeout.

No, pg_licht never writes to PostgreSQL and never returns rows from application tables. Database calls run in their own READ ONLY transaction, and the server reads catalog, statistics, diagnostic, and pooler information instead.

pg_licht provides schema details, table and index sizes, query plans, activity and statement statistics, locks, replication status, buffer cache information, and PgBouncer pool data. These diagnostics help investigate slow queries, blocking, replica lag, and pool capacity.

pg_licht enforces read-only access with a transaction-scoped READ ONLY transaction and applies a statement timeout to each database call. Its guarded statement-execution tool rejects plans that write or call volatile functions, while the timeout defaults to two minutes and can be configured per connection.

Yes, one pg_licht process can serve multiple connections and send a question to every database of an instance, replication group, or label at once.

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 PreviewPg Licht AllMCPs Directory Badge
Markdown (GitHub README)
[![AllMCPs](https://allmcps.com/api/badge/pg-licht?style=directory)](https://allmcps.com/mcp/pg-licht)
HTML Embed
<a href="https://allmcps.com/mcp/pg-licht"><img src="https://allmcps.com/api/badge/pg-licht?style=directory" alt="Pg Licht on AllMCPs" /></a>