pg_query
Run SQL statements on PostgreSQL using saved connection profiles, with read-only safety and optional row limits. Specify dev, qa, or default profile for one-off queries.
Instructions
Run SQL against the sticky session profile (or optional profile=dev|qa for one call). Read-only by default. Optional database name and maxRows. Do not ask the user for connection host/password — use profiles.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sql | Yes | SQL statement to execute | |
| maxRows | No | Max rows to return (default from PG_MAX_ROWS) | |
| profile | No | Connection profile: "dev" | "qa" | "default". Uses credentials from mcp.json (PG_DEV_* / PG_QA_*). Omit to use the sticky session profile from pg_set_profile / PG_PROFILE. | |
| database | No | Optional database name override |