Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

pgbrake: an undo button for Postgres when an AI agent is driving

说明与用途

pgbrake 允许 AI 代理撤销对 PostgreSQL 的写入,阻止危险操作直到人工批准,并将所有操作记录在本地日志中。

问题

AI agents can execute destructive SQL on development databases, and existing safeguards like client‑side permission prompts are insufficient.

结果

pgbrake provides an undo mechanism for writes performed by AI agents, blocks potentially destructive operations until human approval, and logs all activity locally.

工作流

  • 1. Install pgbrake and configure it as an MCP server. 2. Point the AI agent to pgbrake instead of the database. 3. Agent submits SQL through pgbrake. 4. pgbrake parses the statement with pglast. 5. For UPDATE/DELETE, pgbrake saves affected rows locally and returns a change id. 6. If the agent wants to revert, run pgbrake undo <id>. 7. For DDL, UPDATE/DELETE without WHERE, or operations affecting >100 rows, pgbrake pauses and requires a human prompt or pgbrake approve <id> in a terminal with a TTY. 8. All statements and approvals are written to a local audit log; nothing leaves the machine.

证据

pgbrake is a small MCP server the agent uses in place of direct database access. Every statement goes through the real Postgres parser (pglast).

来源

Before an UPDATE or DELETE it saves the affected rows locally, so pgbrake undo <id> puts them back, and it refuses if those rows changed since.

来源

DDL, UPDATE/DELETE without WHERE, and anything touching more than 100 rows wait for a human: the client's own prompt, or pgbrake approve <id> in a terminal. That command refuses to run without a TTY, so the agent can't approve its own SQL.

来源

  • 记录日期: 2026-11-01T09:29:13.299Z