mcpField
P
pgmoat

pgmoat

Local
github.com/Kitalon-Labs-LLCDatabases0Updated 4d ago

About pgmoat

pgmoat is an open-source MCP server that gives AI agents governed, read-only access to Postgres. It checks queries with the Postgres parser and combines row-level security, data hiding, budgets, and tamper-evident auditing.

Key features

  1. 01Allow read-only database access
  2. 02Check queries with the Postgres parser
  3. 03Hide selected tables and columns
  4. 04Apply RLS, row limits, and timeouts
  5. 05Write verifiable tamper-evident audit logs
  6. 06Check role privileges and export visible schema

Use cases

  1. 01Provide agents with governed database queries
  2. 02Hide sensitive columns from query results
  3. 03Apply row-level security for caller identity
  4. 04Verify the audit log hash chain

MCP support

pgmoat is an MCP server that exposes governed, read-only Postgres access to MCP clients through tools, applying query parsing, security controls, limits, and auditing.

Configuration

Local server config is the same for every client. Copy it into your client’s MCP config file.

mcp.json · Universal config
{
"mcpServers": {
"kitalon-labs-llc-pgmoat": {
"command": "npx",
"args": [
"-y",
"pgmoat"
],
"env": {
"PGMOAT_DATABASE_URL": "<PGMOAT_DATABASE_URL>"
}
}
}
}
Run commandnpx -y pgmoat
Environment variables to set
PGMOAT_DATABASE_URLSecretPostgres connection URL (use a read-only role)

Local servers need a runtime on your machine (e.g. Node.js 18+). Config file locations differ by client; see your client’s docs.

Packages
npmpgmoat0.1.1

Tools

No tool list yet

Local servers expose tools only once running on your machine, and the maintainer has not provided a tool list.

Details

From the project 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:

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

Add it to Claude Code:

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

Or to Claude Desktop (claude_desktop_config.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 warns at startup if the role is a superuser or can write.

Add descriptions and hide sensitive data

export PGMOAT_DATABASE_URL=postgresql://readonly_user:password@localhost:5432/mydb
npx pgmoat init          # writes pgmoat.yaml; auto-hides columns like password_hash and token_hash
npx pgmoat validate      # checks the file against the schema and the database
npx pgmoat doctor        # checks the role for unsafe privileges
npx pgmoat start         # starts the server with ./pgmoat.yaml

A pgmoat.yaml looks like this:

version: 1
server:
  name: mydb
connection:
  url: ${PGMOAT_DATABASE_URL}
  schemas: [public]
mode: read-only
budgets:
  max_rows: 200
  max_query_ms: 5000
tables:
  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

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

Comments

Markdown supported

New to MCP?

From what the protocol is to installing your first server, these answers cover most first questions.

An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.