How to Configure Windsurf Postgres Read Only Access
You set up windsurf postgres read only access by creating a restricted database role. Then you link that role to the editor through a Model Context Protocol server or terminal tool. Many teams start by giving their AI coding assistant a standard developer login. When those database permissions are too broad, an agent can change or delete live data. It can also pull sensitive customer rows into its prompt context. How windsurf postgres read only access works in native setups In June 2026, Cogn
Your coding agents run with your access.
Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.
You set up windsurf postgres read only access by creating a restricted database role. Then you link that role to the editor through a Model Context Protocol server or terminal tool. Many teams start by giving their AI coding assistant a standard developer login. When those database permissions are too broad, an agent can change or delete live data. It can also pull sensitive customer rows into its prompt context.
How windsurf postgres read only access works in native setups
In June 2026, Cognition renamed Windsurf to Devin Desktop, while keeping the same IDE features. Its agent, known as Cascade, can run terminal commands in a dedicated shell with user permission. That shell loads the user profile, so existing shell aliases and variables are open to the agent. The agent also connects to external Model Context Protocol servers to inspect databases and other systems.
To lock down PostgreSQL, admins build a dedicated group role for read tasks. You assign specific user logins to this group role to keep management simple. Next, you grant the SELECT privilege on chosen tables, views, or materialized views. PostgreSQL also lets you grant SELECT on specific columns rather than a whole table. Keep in mind that the SELECT privilege also allows bulk data export through COPY TO.
You must also check the built-in PUBLIC role during your database setup. Every role on a PostgreSQL server gets PUBLIC privileges by default. By default, PUBLIC allows database logins, temporary table creation, and function execution. On servers created before PostgreSQL 15, PUBLIC also allowed object creation in the public schema. An admin must revoke those default privileges from PUBLIC so a read role cannot run unsafe functions.
Why native roles are not enough for AI agents
Native PostgreSQL privileges do a good job of stopping direct table writes and schema drops. Once you revoke write rights and lock down PUBLIC, the agent cannot run DELETE or UPDATE commands. This step prevents accidental data loss when the coding agent tests queries or explores table schemas.
Still, a database role only checks who logs in and which tables they can read. It does not inspect individual statements in flight or control what returns inside a query result. Because the agent shell loads local variables, any static database password stored on disk remains exposed. If a developer stores a high-privilege login in their shell profile, the agent can use it.
Auditor Read-Only Access + Customer Support Access to Production: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Column grants are also hard to maintain across hundreds of changing app tables. If a table holds emails, phone numbers, card numbers, or national IDs, SELECT returns them in plain text. The coding agent reads those raw values and sends them straight to the language model provider. A read role also cannot block an agent from running a massive table scan that slows production.
What to check before connecting an AI coding agent
Before you let an editor query a live database, review how the agent reaches your network. Verify that the agent terminal does not inherit admin credentials from local shell startup files. Check every function on the server to confirm the PUBLIC role cannot execute state-changing code. Finally, plan how you will handle sensitive columns like emails and card numbers during read queries.
Run guardrails and masking on the Postgres connection
Role grants and firewall rules are needed setup. Setup alone cannot check single SQL statements or mask sensitive rows in a response. By design, hoop.dev sits inline in the Postgres protocol beside Postgres, RDS, or Aurora as a sidecar for your Postgres. On every production query from an engineer or AI agent, hoop.dev decides whether to pass, mask, block, or hold it for approval.
First, hoop.dev guardrails refuse disallowed drops or deletes before they run, and risky statements can pause for human review. Next, hoop.dev data masking rewrites sensitive fields in returned rows in memory. Furthermore, hoop.dev holds SOC 2 Type II and logs every statement and verdict per resource. Check out the project on GitHub.
Frequently asked questions
Does a PostgreSQL SELECT grant only allow standard read queries?
No, the SELECT privilege in PostgreSQL also allows the role to run COPY TO exports. It lets the user read from tables, views, materialized views, or specific columns you select.
Why can a read-only PostgreSQL user still run functions or make temp tables?
PostgreSQL grants default rights to a special group called PUBLIC, which includes every user role. By default, PUBLIC allows temporary table creation and function execution unless an admin revokes them.
How does the Windsurf or Devin Desktop agent reach a PostgreSQL database?
The agent connects through configured Model Context Protocol servers or runs commands in its built-in terminal. Because that terminal loads the user shell profile, it can use local database tools and variables.
Short role checks help teams work fast. Simple rules make each review clear. Good logs keep every team safe. Scoped keys stop bad changes early.
Related guides
In this post