io.github.lexang/pgbrake is an MCP server that postgres brake for AI agents: risky SQL waits for approval, UPDATE/DELETE get one-command undo. Its tool list has not been published yet over stdio, requires no API key, and scores 61/100 on MCPpedia's security, maintenance and efficiency rubric.
Config is the same across clients - only the file and path differ.
{
"mcpServers": {
"io-github-lexang-pgbrake": {
"args": [
"pgbrake"
],
"command": "uvx"
}
}
}Are you the author?
Add this badge to your README to show your security score and help users find safe servers.
Postgres brake for AI agents: risky SQL waits for approval, UPDATE/DELETE get one-command undo.
Run this in your terminal to verify the server starts. Then let us know if it worked - your result helps other developers.
uvx 'pgbrake' 2>&1 | head -1 && echo "✓ Server started successfully"
After testing, let us know if it worked:
Five weighted categories - click any category to see the underlying evidence.
No known CVEs.
Checked pgbrake against OSV.dev.
Be the first to review
Have you used this server?
Share your experience - it helps other developers decide.
Sign in to write a review.
Others in data / ai-ml
Manage Supabase projects — databases, auth, storage, and edge functions
Token-efficient database MCP server for PostgreSQL, MySQL, MariaDB, SQL Server, Oracle, SQLite
Codebase knowledge graph for AI agents — 162 languages, sub-ms queries, 99% fewer tokens.
An open-source AI agent that brings the power of Gemini directly into your terminal.
MCP Security Weekly
Get CVE alerts and security updates for io.github.lexang/pgbrake and similar servers.
Start a conversation
Ask a question, share a tip, or report an issue.
Sign in to join the discussion.
An undo button for your database when an AI agent is driving.
pgbrake is a local MCP server that sits between Claude Code / Codex / Cursor and your Postgres. Every write the agent makes gets a change id you can reverse with one command. Risky SQL waits for a human. Everything is logged. Nothing leaves your machine.

agent> DELETE FROM users WHERE created_at < '2025-01-01'
pgbrake> held: DELETE would touch 4,812 rows (limit 100) — approval apv_3f9c21aa
agent> DELETE FROM users WHERE id = 42
pgbrake> 1 row affected; undo with change id chg_8e01b7d2
you$ pgbrake undo chg_8e01b7d2
undid delete on "users": 1 row(s) restored
Claude Code checkpoints rewind files, not databases. Client-side permission prompts and hooks can be skipped or misfire for MCP calls, and a tool's own "destructive" label is just a hint. pgbrake enforces its rules inside the server, so they hold no matter which agent or client calls it.
DROP, ALTER, TRUNCATE...), UPDATE/DELETE without WHERE,
any write over the row limit (default 100), upserts and MERGE.ALTER SYSTEM, role/database creation and drops, COPY ... PROGRAM, DO blocks.UPDATE/DELETE, the affected rows are saved locally; inserts are
tracked by primary key. Undo refuses if the rows changed since, unless you --force.pgbrake approve <id>
in an interactive terminal. Approvals are one-shot, expire in 15 minutes, and are bound to the exact SQL.~/.pgbrake/journal.db.pip install pgbrake # or: uvx pgbrake serve
Claude Code:
claude mcp add pgbrake --env PGBRAKE_DSN="postgresql://me@localhost/app" -- uvx pgbrake serve
Codex (~/.codex/config.toml):
[mcp_servers.pgbrake]
command = "uvx"
args = ["pgbrake", "serve"]
env = { PGBRAKE_DSN = "postgresql://me@localhost/app" }
Then remove any other database MCP / psql access from the agent, so pgbrake is the only way in.
In Claude Code, add "Bash(psql:*)" and "Bash(pgbrake approve:*)" to permissions.deny.
pgbrake pending # SQL waiting for you
pgbrake approve <id> # approve (interactive terminal only)
pgbrake deny <id>
pgbrake changes # undoable changes
pgbrake undo <change-id> # reverse one
pgbrake log # audit log
| Variable | Default | |
|---|---|---|
PGBRAKE_DSN | — | connection string (falls back to DATABASE_URL) |
PGBRAKE_MAX_ROWS | 100 | writes touching more rows need approval |
PGBRAKE_ALLOW_DDL | 0 | set 1 to let schema changes through (still logged) |
PGBRAKE_READ_ONLY | 0 | set 1 to refuse every write |
PGBRAKE_STATEMENT_TIMEOUT_MS | 15000 | |
PGBRAKE_JOURNAL | ~/.pgbrake/journal.db |
TRUNCATE, DDL, upserts and MERGE are held for approval but cannot be undone.$29 one-time for the first 100 licenses (then $39). No subscription. 14-day refund. Buy pgbrake Pro
PreToolUse hook catches
prisma migrate reset --force, drizzle-kit push --force, alembic downgrade base and friends,
takes a pg_dump snapshot first (when PGBRAKE_DSN is set), checks pg_restore can read it, then asks you. If