Skip to main content
The Sidecar runs in your infrastructure, between your Postgres clients and the Supabase connection pooler. Clients change only the host and port of their connection string. Every statement from an AI agent, from a developer in psql, or from an application then passes through your guardrails, masking rules and audit trail.
AI agents, developers in psql, and applications connect to the Hoop Sidecar in your infrastructure. The Sidecar applies guardrails, data masking and audit, then connects over verified TLS to the Supabase session pooler and Postgres. Network Restrictions allow only the Sidecar's IP. supabase-js reaches the Supabase HTTPS APIs and does not pass through the Sidecar.AI agents, developers in psql, and applications connect to the Hoop Sidecar in your infrastructure. The Sidecar applies guardrails, data masking and audit, then connects over verified TLS to the Supabase session pooler and Postgres. Network Restrictions allow only the Sidecar's IP. supabase-js reaches the Supabase HTTPS APIs and does not pass through the Sidecar.
The Sidecar sees Postgres connections only. Supabase’s HTTPS APIs (PostgREST and supabase-js, Storage, Auth, Realtime) and the dashboard SQL editor reach the database inside Supabase, so their traffic does not pass through the Sidecar.

Requirements

  • A Supabase project. The free plan works.
  • Docker on a host with outbound IPv4 access.
  • A Postgres client, such as psql.

Setup

1

Copy the session pooler host

In the Supabase dashboard, click Connect, open the Direct tab and select Session pooler.
Supabase Connect dialog with Session pooler selected
The URI below the options holds the two values you need:
  • Host: aws-0-<region>.pooler.supabase.com. Copy it exactly, because some projects use aws-1.
  • User: postgres.<project-ref>.
2

Download the Supabase root certificate

Open Database, then Settings. In SSL configuration, click Download certificate and save the file as certs/supabase-root.crt.
Supabase SSL configuration with the Download certificate button
The pooler presents a certificate signed by Supabase’s own CA (Supabase Root 2021 CA). That CA is not in public trust stores, so the Sidecar needs this file to verify the pooler.
3

Write the config

Save this as config.yaml next to the certs folder. Replace the upstream host with yours.
config.yaml
  • guardrails blocks DROP, DELETE and TRUNCATE.
  • mask replaces email addresses in results.
  • audit writes every statement to stdout as JSON lines, and query_sessions turns on the /api/sessions endpoint.
  • upstream_tls encrypts the hop to Supabase and verifies it against the root certificate.
  • admin serves health checks and the audit API. It has no authentication, so the next step publishes it on loopback only.
The config holds no database password. The Sidecar relays the login from the client to Supabase.
4

Validate and start the Sidecar

--validate prints config OK: 1 listener(s) and the rule counts. Versions are on the releases page.
5

Point your clients at the Sidecar

Change the host and port. The user, password and database stay the same. Every client takes the same change: the MCP server or psql an AI agent uses, a developer’s psql, and application drivers.
sslmode=disable applies only to the hop from the client to the Sidecar on the same host. When clients reach the Sidecar over a network, turn on downstream_tls and connect with sslmode=require.

Verify

Create a test table through the Sidecar:
A select returns the email masked:
A destructive statement is refused with your message:
The audit lists each session with its principal and counts (fields trimmed):

Allow only the Sidecar with Network Restrictions

Supabase Network Restrictions limit which IP addresses can connect to Postgres and the pooler. Allow only the Sidecar’s egress IP, and no client with another IP can connect to Supabase directly and skip your rules. Workloads that share the Sidecar’s host or NAT gateway keep that access, so give the Sidecar a static egress IP of its own.
  1. Open Database, then Settings, and find Network Restrictions.
  2. Click Add restriction, then add the Sidecar’s IP as <ip>/32.
Supabase Network restrictions with one IPv4 address allowed
Or with the Supabase CLI:
A connection from any other IP fails before it reaches the database:
Network Restrictions cover Postgres only, so Supabase’s HTTPS APIs keep working. Edge Functions lose direct database access and must use supabase-js.

Name who ran each statement

By default every client connects as postgres.<project-ref>, so the audit shows one shared user. Two ways give each statement a name. A role per person. Create a Postgres role for each person and connect as <role>.<project-ref>. The audit records that role as the principal.
A tag on the connection. Send a custom setting in the startup options. The Sidecar records it on every event of the session, and Supabase accepts it.
See trace ids from the startup packet to choose which options the Sidecar records.
The audit records the full statement text. Run CREATE ROLE ... PASSWORD from the Supabase SQL editor, so the password does not go through the Sidecar.

Behavior to know

  • A denied statement closes the connection. The client reads the message as FATAL 42501, and Postgres rolls back the open transaction. Connection pools open a new connection. See denials the user can read.
  • Supabase errors reach the client unchanged. A login or Network Restrictions failure reads the same with or without the Sidecar.
  • The Sidecar removes channel binding. It offers SCRAM-SHA-256 instead of SCRAM-SHA-256-PLUS, with the same password. See TLS on each leg.

Free and Enterprise

Free tier: one Data Masking rule and one Guardrail per Sidecar are free, forever. Running more than one rule per feature, or managing rules centrally across Sidecars, requires Enterprise.
  • More rules: an Enterprise license with the guardrails and data-masking features lifts the one-rule caps, with or without a Control Plane. In Docker, pass it with -e HOOP_LICENSE="$(cat license.json)". See Licensing.
  • Reviews and central management: connect the Sidecar to a Control Plane, which also needs an Enterprise license. It adds reviews, shared rule sets and one view of many Sidecars.

Next

Guardrails

Write rules that block statements by operation, table or content.

Data Masking

Choose entity types, columns and masking strategies.

PostgreSQL

What the Postgres lane decodes, terminates and masks.

Config File Reference

Every section and field of config.yaml.