How to Configure Windsurf Postgres MCP Server

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up a windsurf postgres mcp server by adding your database details to the editor's MCP settings file. Then, you assign a dedicated database role so the coding agent can query tables. Note that Cognition renamed Windsurf to Devin Desktop in June 2026. The app keeps the same IDE and features under this new name. Teams often use a shared developer account when they first link their database. Broad roles create big risks when an AI agent can run queries on its own. A wide role lets the agent

Kubernetes API Server Access + End-to-End Encryption: the complete guide

Architecture patterns, implementation strategies, and security best practices. Delivered to your inbox.

Free white paper. No spam. Unsubscribe anytime.

You set up a windsurf postgres mcp server by adding your database details to the editor's MCP settings file. Then, you assign a dedicated database role so the coding agent can query tables. Note that Cognition renamed Windsurf to Devin Desktop in June 2026. The app keeps the same IDE and features under this new name. Teams often use a shared developer account when they first link their database. Broad roles create big risks when an AI agent can run queries on its own. A wide role lets the agent read sensitive rows or run heavy queries.

How a windsurf postgres mcp server works with database roles

The editor's Cascade agent connects to MCP servers listed in your local settings file. The agent can also run terminal commands on its own with user permission. It uses a dedicated terminal that loads your shell setup, aliases, and variables. Because the agent reads local settings, your database credentials often sit on your machine. When you prompt the agent, it sends SQL queries through the local MCP process.

PostgreSQL checks the assigned role when the MCP process logs in. You can create group roles to manage permissions for many users at once. Each user or agent then joins that group role. To limit what the agent reads, admins grant the SELECT privilege. This privilege lets a role read from whole tables, views, or specific columns. Note that SELECT also allows the COPY TO command on those objects.

Admins must also watch out for default permissions granted to the special PUBLIC role. Every role on the database gets PUBLIC privileges by default. Out of the box, PUBLIC gets permission to connect and create temporary tables. It also gets permission to run functions and procedures. The object owner can revoke these default rights to lock down the system. In PostgreSQL 15 and newer, regular users cannot create objects in the public schema by default. On older upgraded databases, an admin must revoke that create right from PUBLIC.

What native database roles solve and what they miss

Native database roles do a great job of controlling who can log in. They also define which tables or columns a specific role can read. Setting up a read-only role stops an agent from dropping tables or changing rows. Column grants let you block access to specific columns when you know the schema well.

Still, static roles cannot inspect what an individual query does while it runs. Once a role has read rights on a table, it can pull every row by default. If a table holds emails, phone numbers, card numbers, or national IDs, the agent gets them. You would have to maintain column grants across hundreds of tables to stop this. Even then, an agent might need to query a text column that mixes regular notes with emails.

Kubernetes API Server Access + End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Static roles also require you to store database keys in your local MCP setup. Since the editor loads your shell variables, any terminal command might read those keys. Native roles also do not tie a specific AI prompt to an exact SQL statement in an audit log. Everyone using the same role looks identical inside the database logs. Finally, a read-only role cannot require human approval before a massive query runs.

How to tighten your database setup before connecting an agent

Start by creating a separate database role just for your AI coding tool. Never reuse your personal admin account or your main app role. Revoke default PUBLIC rights on functions and procedures if the agent does not need them. Check if your database was upgraded from an older version before PostgreSQL 15. If so, remove the right for PUBLIC to create objects in the public schema.

Next, grant SELECT only on the specific tables and columns needed for coding tasks. Keep sensitive user tables out of this role's reach whenever you can. Review your local shell profile and remove extra database passwords stored in plain text. Remember that the editor's terminal loads your shell setup and can read those values.

Add query and result controls beside Postgres

Grants and pools govern who logs into PostgreSQL. Yet every query in an open session still runs with that role's full scope. In practice, hoop.dev sits inline in the wire protocol beside your database as a sidecar for your Postgres. For every plain or prepared query an agent or human runs against production, hoop.dev decides to pass, mask, block, or escalate it for review.

When a tool or agent sends SQL, hoop.dev Postgres controls block banned statements before execution or hold risky ones for human approval via an AI Analyzer you configure. Matched sensitive columns in result rows are masked in memory before they reach the caller. Each query and decision is logged per listener, which generates evidence for SOC 2, HIPAA, and GDPR audits. View the binary on GitHub.

Frequently asked questions

Did Windsurf change its name to Devin Desktop?

Yes, Cognition renamed Windsurf to Devin Desktop on June 2, 2026. The app keeps the same IDE features, terminal tools, and Cascade MCP support.

Does the PostgreSQL SELECT privilege only allow normal read queries?

No, the SELECT privilege lets a role read tables, views, or specific columns. It also allows the role to run COPY TO for exporting data.

Why can a new database role run functions without explicit grants?

PostgreSQL grants the special PUBLIC role permission to execute functions by default. Every new role inherits PUBLIC rights until the object owner revokes them.

Save the open-source gateway.

hoop is MIT-licensed infrastructure for controlling how AI agents reach production data. Star hoophq/hoop so you can inspect it, deploy it, or share it when your team starts governing agent access.