Pgmoat

io.github.Kitalon-Labs-LLC由 GitHub 账号 Kitalon-Labs-LLC 发布v0.1.2更新于 Nov 7, 2026

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

已验证STDIO仅桌面数据库安全与监控

概览

AI 生成的概览

一个让 AI 助手以受管控的只读方式访问 Postgres 数据库的 MCP 服务器,提供查询检查、隐藏列、预算限制和审计日志。

可以做什么
  • 对 Postgres 数据库执行只读 SQL,并限制返回行数和查询超时
  • 隐藏标记为隐藏的表和列,并标记敏感数据
  • 将行级安全绑定到调用者身份,并写入防篡改审计日志
  • 生成并校验配置文件、检查数据库角色是否存在不安全权限、验证审计哈希链,以及把可见表结构导出为 Markdown
适用场景
当助手需要基于生产或共享的 Postgres 数据库回答问题、且不应有任何写入路径,并希望获得限额、隐藏字段和审计记录而不是直接拿到数据库凭据时使用。
运行要求
需要 Node.js 22.12 或更高版本以及 Postgres 15 至 18,通过 stdio 在本地运行(npm 包或 Docker 镜像)。Postgres 连接 URL 通过 PGMOAT_DATABASE_URL 环境变量或命令行参数提供,建议使用专用只读角色。可选的 pgmoat.yaml 用于配置 schema、预算、描述和隐藏列。
安装前请注意
连接 URL 含数据库凭据;通过 PGMOAT_DATABASE_URL 传入可避免密码出现在进程列表中。应使用专用只读角色,因为零配置模式对不安全角色只会警告,而 --allow-unsafe-role 会跳过启动检查。它无法阻止提示注入,不能替代 Postgres 权限,也不会修正有缺陷的 RLS 策略;故障期间无法保证审计日志送达远程目标。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Pgmoat,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

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

来源:README.md,提交 5d4fabd

工具

0
SourceWeft 曾在隔离沙箱中以无凭据方式启动该软件包一次,以列出其工具,但未能完成:服务器未能启动。

版本历史

2
  1. v0.1.2最新Nov 7, 2026
  2. v0.1.1Oct 25, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分