How to Configure Goose Postgres MCP Server
You set up a goose postgres mcp server by linking your local agent to a database role. This setup lets your AI assistant run SQL queries on your database tables. Teams often start by reusing a broad developer account for quick testing. Broad permissions let an automated agent read or change sensitive rows by mistake. How the goose postgres mcp server setup works The agent runs a local server process that speaks the Model Context Protocol. This local process holds a database connection string
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 a goose postgres mcp server by linking your local agent to a database role. This setup lets your AI assistant run SQL queries on your database tables. Teams often start by reusing a broad developer account for quick testing. Broad permissions let an automated agent read or change sensitive rows by mistake.
How the goose postgres mcp server setup works
The agent runs a local server process that speaks the Model Context Protocol. This local process holds a database connection string and opens a session to PostgreSQL. When you ask the agent a question, it builds a SQL statement. The server sends that statement to the database using the assigned role.
To keep this setup safe, admins create a dedicated group role for the agent. In PostgreSQL, group roles manage privileges for multiple users through role membership. Admins grant the SELECT privilege to this role on specific tables or views. PostgreSQL also lets you grant SELECT on specific columns of a table. This column rule stops the role from reading unlisted columns on that table.
You must also check default privileges on the database before going live. The special PUBLIC role grants rights to every role on the system. By default, PUBLIC gets CONNECT and TEMPORARY rights on databases. It also gets EXECUTE rights on functions and procedures. The object owner can revoke these default PUBLIC privileges to lock down the agent.
In PostgreSQL 15 and later, users cannot create objects in the public schema by default. Older databases, or upgraded ones, may still allow this action. An admin fixes this by revoking CREATE on the public schema from PUBLIC.
What native database roles solve and what keeps the session active
Native database roles control which user logs in and which objects they can touch. Column grants and schema locks stop an agent from dropping tables or reading secret columns. This setup works well when every table and column has a static security level.
Kubernetes API Server Access + End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Still, static roles do not inspect individual queries while they run. Once a role has SELECT on a column, it can read every row inside by default. Also, the SELECT privilege also allows COPY TO operations on those permitted columns. An agent with read rights can pull an entire table of customer emails at once.
Native privileges also cannot rewrite sensitive values inside query results on the fly. If an agent needs to read a support table, it gets the raw text. The database does not redact phone numbers, card numbers, or national IDs in flight. Static credentials also sit on the local machine where the agent runs. If a developer shares a config file, those database keys can leak.
Securing agent database sessions in production
Production teams need controls that work at the query and result level. Instead of storing static database passwords on laptops, teams tie sessions to user identity. Each query from an agent should link back to the person who ran it. Teams also benefit from data masking that rewrites emails and card numbers in query results. Blocking risky commands in flight stops an agent from running huge data exports.
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 runs beside your database as a sidecar for your Postgres. It reads plain and prepared queries on the wire with no change to your users or drivers.
When a tool or agent sends SQL, hoop.dev Postgres controls check each statement against your deny rules. An AI Analyzer you configure can also score intent or hold a risky query for human review. 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
Can I restrict the goose postgres mcp server to specific columns?
Yes, PostgreSQL lets you grant the SELECT privilege on specific columns of a table. The database will reject queries that try to read other columns on that table.
Why can my read-only agent still run functions or create temp tables?
PostgreSQL grants CONNECT, TEMPORARY, and function EXECUTE rights to the PUBLIC role by default. The database owner must revoke these defaults from PUBLIC to block the agent.
Does a read-only PostgreSQL role hide sensitive text inside allowed columns?
No, native SELECT privileges return the exact data stored in the allowed columns. Rewriting emails, phone numbers, or card numbers in results requires dynamic data masking.
Related guides
In this post