Pgmoat

io.github.Kitalon-Labs-LLCPublished by GitHub account Kitalon-Labs-LLCv0.1.2Updated Nov 7, 2026

Governed, read-only Postgres access for AI agents: SQL safety, RLS, budgets, tamper-evident audit.

VerifiedSTDIODesktop onlyDatabasesSecurity & Monitoring

Overview

AI-generated overview

An MCP server that gives AI assistants governed, read-only access to a Postgres database, with query checks, hidden columns, budgets and an audit log.

What you can do
  • Run read-only SQL against a Postgres database, with row limits and query timeouts
  • Hide marked tables and columns, and label sensitive data
  • Bind Row-Level Security to the caller's identity and record a tamper-evident audit log
  • Generate and validate a configuration file, check the database role for unsafe privileges, verify the audit hash chain, and export the visible schema as Markdown
When to use it
Use it when an assistant should answer questions from a production or shared Postgres database without any write path, and you want limits, hidden fields and an audit trail rather than raw database credentials.
Requirements
Node.js 22.12 or newer and Postgres 15 to 18, run locally over stdio (npm package, or a Docker image). A Postgres connection URL is supplied through the PGMOAT_DATABASE_URL environment variable or as a command argument; a dedicated read-only role is expected. An optional pgmoat.yaml configures schemas, budgets, descriptions and hidden columns.
Before you install
The connection URL contains database credentials; passing it via PGMOAT_DATABASE_URL keeps the password out of process listings. Use a dedicated read-only role, since zero-config mode only warns about unsafe roles and --allow-unsafe-role overrides startup checks. It does not stop prompt injection, does not replace Postgres permissions, and does not fix flawed RLS policies; audit delivery to a remote destination is not guaranteed during outages.

Installation

In SourceWeft

  1. Open Pgmoat in the dashboard and add it to a workspace.
  2. Enable the server for the chats that should use its tools.

Desktop only via STDIO. STDIO servers start a local process, so they need the SourceWeft desktop host.

Other MCP clients

Follow the launch instructions in the repository.

README

pgmoat

[CI] [npm version] [License: MIT]

Governed Postgres access for AI agents.

pgmoat is an open-source MCP server that gives AI agents read-only access to Postgres. It checks every query with the real Postgres parser, hides the tables and columns you mark hidden, applies row limits and timeouts, binds Row-Level Security to the caller's identity, and writes a tamper-evident audit log.

Requires Node.js 22.12 or newer and Postgres 15 to 18.

Quickstart

Run it against your database with safe defaults, no config file needed:

bash
npx -y pgmoat postgresql://readonly_user:password@localhost:5432/mydb

Add it to Claude Code:

bash
claude mcp add pgmoat -- npx -y pgmoat postgresql://readonly_user:password@localhost:5432/mydb

Or to Claude Desktop (claude_desktop_config.json):

json
{  "mcpServers": {    "pgmoat": {      "command": "npx",      "args": ["-y", "pgmoat", "--url-env", "PGMOAT_DATABASE_URL"],      "env": { "PGMOAT_DATABASE_URL": "postgresql://readonly_user:password@localhost:5432/mydb" }    }  }}

Passing the URL through --url-env keeps the password out of process listings.

Use a dedicated read-only role. pgmoat checks the role at startup. With a pgmoat.yaml, it refuses to start if the role is a superuser (PGM-701), has BYPASSRLS while row-level security is configured (PGM-702), or owns a protected table without FORCE ROW LEVEL SECURITY (PGM-703), unless you pass --allow-unsafe-role; every audit entry then records the override. In zero-config mode (a URL and no config file) it warns and continues.

Add descriptions and hide sensitive data

bash
export PGMOAT_DATABASE_URL=postgresql://readonly_user:password@localhost:5432/mydbnpx pgmoat init          # writes pgmoat.yaml; auto-hides columns like password_hash and token_hashnpx pgmoat validate      # checks the file against the schema and the databasenpx pgmoat doctor        # checks the role for unsafe privilegesnpx pgmoat start         # starts the server with ./pgmoat.yaml

A pgmoat.yaml looks like this:

yaml
version: 1server:  name: mydbconnection:  url: ${PGMOAT_DATABASE_URL}  schemas: [public]mode: read-onlybudgets:  max_rows: 200  max_query_ms: 5000tables:  users:    description: "One row per login account"    columns:      password_hash: { hidden: true }      email:         { sensitive: high }

Commands

CommandWhat it does
pgmoat <postgres-url>Start with safe defaults (no config file)
pgmoat initCreate pgmoat.yaml from your database
pgmoat startStart the MCP server from pgmoat.yaml
pgmoat validateCheck pgmoat.yaml against the schema and the database
pgmoat doctorCheck the database role for unsafe privileges
pgmoat audit verifyVerify the audit log hash chain
pgmoat schema-exportWrite the visible schema as Markdown

Run pgmoat --help for all options.

What pgmoat does not do

  • It does not stop prompt injection. It removes the write path, hides what you mark hidden, and labels returned data as untrusted, but an agent with other tools (web access, email) can still be tricked into sending readable data elsewhere.
  • It does not replace Postgres permissions. The strongest control is a dedicated role with only the grants it needs.
  • It does not make RLS policies correct. It sets the session variables your policies read. A flawed policy stays flawed.
  • It does not guarantee audit delivery to a remote destination during an outage. It buffers, alarms, and records drops.

Docker

bash
docker run -i --rm \  -e PGMOAT_DATABASE_URL="postgresql://readonly_user:[email protected]:5432/mydb" \  ghcr.io/kitalon-labs-llc/pgmoat:latest

Contributing

See CONTRIBUTING.md. Report vulnerabilities privately as described in SECURITY.md.

Links

License

MIT (c) 2026 Kitalon Labs

Source: README.md at commit 5d4fabd

Tools

0
SourceWeft started this package once in an isolated sandbox, without credentials, to list its tools. That failed: the server did not start.

Version history

2
  1. v0.1.2LatestNov 7, 2026
  2. v0.1.1Oct 25, 2026

Score

50% of the applicable checks met

How complete this listing is, computed from the registry entry, the endpoint and public sources. Not a rating of the server and not a statement that it is safe or working today: reachability is a dated check, and no installs or reviews go into the score.

  • Reached in the last 30 days25 pts

    Keep the endpoint answering the MCP handshake; SourceWeft probes it every 30 days.

  • Auth declared10 pts

    Declare the credential headers in the registry entry, or keep the endpoint answering the probe so its auth can be classified.

  • Tools listed15 pts

    Answer tools/list without a credential, or ship a package that starts in a sandbox without one.

  • DescriptionRequired15 pts
  • Logo10 pts
  • Documentation15 pts
  • License10 pts