Skip to content

Put Deedglass in front of Postgres

Agents run SQL through the Postgres connector: one statement per action, as the role deedglass_agent, with every write witnessed in Postgres’s own change log.

Before you start

  • PostgreSQL 16, 17 or 18 with wal_level = logical (needed for L2; L0 and L1 work without it).
  • An admin connection string for setup: a superuser, or a role with CREATEROLE such as the RDS master user. Deedglass reads it once and never stores it.
  • A Deedglass server and an org admin key. After npx -y deedglass init on this machine, connect finds both from any directory; otherwise set DEEDGLASS_SERVER and DEEDGLASS_API_KEY.
Terminal window
npx -y deedglass connect "$DATABASE_URL" # read-only checks and the plan
npx -y deedglass connect "$DATABASE_URL" --apply --confirm <database>

The first run tells Supabase, Neon and plain Postgres apart, warns when the URL goes through a pooler, and checks, on a session that can’t write, the version, wal_level, replication slots, whether the user can create roles, and which tables lack REPLICA IDENTITY FULL. Then it prints the plan. --apply does steps 1 to 4 below for every table in public (or --schema, or --tables), enforces postgres-safe scoped to this connector’s tools (--policy postgres-check lets writes run and checks each one at Proven), creates an agent with a key in a 0600 file, sends one read through the Gate, and prints the MCP line. --confirm is needed for a remote database. The password in the URL is never printed or stored. Guides: Supabase, Neon.

The steps it runs are below, for when you want each one by hand.

postgres.yaml
type: postgres
name: orders
description: The orders database.
config:
mode: sql
allowed_schemas: [public]
writable_tables: [public.orders, public.refunds]
row_limit: 500
max_rows_affected: 1000
statement_timeout_ms: 5000
witness:
enabled: true
watched_tables: [public.orders, public.refunds, public.customers]
sensitive_columns: [public.customers.email]

writable_tables is the only place an agent can write. watched_tables is what the Witness reads in the change log. sensitive_columns are compared by digest and never stored.

Terminal window
deedglass connector create --config postgres.yaml
export DEEDGLASS_INIT_DSN='postgres://postgres:…@db.internal:5432/orders?sslmode=require'
deedglass connector postgres init --connector orders
deedglass connector postgres init --connector orders --apply

The first init prints the plan (roles, the deedglass schema, grants, replica identity on the watched tables, the publication) and writes the exact SQL to .deedglass/plans/ for you to review. --apply runs it in one transaction. Passwords are generated on your machine and reach Postgres only as SCRAM verifiers.

Terminal window
deedglass connector postgres check --connector orders

It ends with Ready for Proven checks · … passed · 0 failed, or names what is missing and the SQL that fixes it.

The postgres-safe starter lets reads run, sends writes to a person, and never runs schema changes. Your first policy shows how to edit and activate it.

  • L2 sees what Postgres commits in the watched tables. Effects outside Postgres, and writes to tables outside the publication, are not witnessed.
  • Managed services differ: some don’t allow logical replication on every plan. The reference lists RDS, Supabase and Neon specifics.
  • It doesn’t migrate your schema. Schema changes through agents are refused; ship them as reviewed migrations.