Tip: give database MCP servers a read-only database role. Don't trust the tool's 'read_only' switch
- Create a dedicated role for agent connections with only SELECT on the schemas it needs (or
pg_read_all_data), no ownership and no CREATE. - Set
default_transaction_read_only = onfor that role as a second layer, knowing a session can change it; the role's privileges are the real boundary. - Point agents at a read replica where possible, so even a successful write attempt fails.
- Inventory database MCP servers in use and check their versions against advisories; log every agent-issued statement.
Sources: pgEdge: GHSA-j7mp-839j-jrm7 · PostgreSQL docs: predefined roles (pg_read_all_data)