# pgwarden

pgwarden is a Claude Code MCP server that connects assistants to Postgres using individual OIDC identities, database-level permissions, and human write approval.

- MCP server · `type=mcp` · Claude Code, Codex, Cursor, GitHub Copilot, Windsurf (Devin Desktop), Cline, Zed, Gemini CLI · ★ 36 repo stars
- Author: B0yko
- License: Apache-2.0 · policy=link-only · description only; the file stays with the author
- Source: https://github.com/B0yko/pgwarden
- Updated: 2026-11-21
- Security check: automated, 2026-11-24 (text) — no signs of malicious code found.
- HTML: https://affpapa.org/en/nevibecode/mcp/pgwarden

## What it does

The gateway proxies client queries to Postgres under each user's mapped login role. Row-level security, permissions, and masked views are evaluated directly by the database engine instead of external middleware filters.

Reads execute inside single-statement read-only transactions. Write requests trigger an email with a signed review link, requiring explicit approval from an assigned reviewer before a single run. Tool calls and admin actions are recorded in an append-only hash chain.

Running the demo stack locally requires Docker Compose v2. Direct integration requires Postgres 16 or 18.

## Requirements
- Needs: Docker
- Environment variables: `PGWARDEN_CONFIG`, `PGWARDEN_TARGET_DSN`, `PGWARDEN_STATE_DSN`, `PGWARDEN_ROLE_SECRET_FILE`, `PGWARDEN_SIGNING_KEY_FILE`, `PGWARDEN_SESSION_SECRET_FILE`, `PGWARDEN_OIDC_CLIENT_SECRET_FILE` — keys and tokens: ask the human for the values, never commit them or put them in shared files.

## Install

### Claude Code (native platform)

**Install**
- The MCP registry has no launch command for it: see the repository README

## When to use it
- Postgres access control
- enforce database permissions per identity
- require human approval for writes
- track assistant queries in an audit chain

## Example prompts
- List all database tables available to my account
- Run a select query on the customers table
- Propose a write query to update user status

## Similar
- [sql-injection-prevention](https://affpapa.org/en/nevibecode/skills/sql-injection-prevention.md) — skill · 537 installs
- [supabase-security-audit](https://affpapa.org/en/nevibecode/commands/supabase-security-audit.md) — command · 1020 installs
- [infisical-secret-rotation](https://affpapa.org/en/nevibecode/skills/infisical-secret-rotation.md) — skill · 255 installs
- [neon-auth-specialist](https://affpapa.org/en/nevibecode/agents/neon-auth-specialist.md) — subagent · 387 installs
- [oauth-oidc-misconfiguration](https://affpapa.org/en/nevibecode/skills/oauth-oidc-misconfiguration.md) — skill · 4100 installs
- [404-frameworks-quarkus-security](https://affpapa.org/en/nevibecode/skills/404-frameworks-quarkus-security.md) — skill · 294 installs

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
