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.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"sql": "<sql>"
},
"name": "pg_query"
}
}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 |