Query the database
db_queryRun SQL on the project's PostgreSQL 19 (env preview by default, or production: the live site's real data). Reads run directly, on production in a read-only transaction with a 5-second limit, and the result says it is live data. A statement that writes runs on preview after an automatic snapshot; on production it needs the db:production permission and confirm: true, and one that drops, truncates or alters, or updates or deletes without a WHERE clause (or about a thousand rows or more), waits for the owner's approval in the portal first. Prefer migration files (db migrate) for schema changes. Results are capped (max_rows, default 100); values come back as text. For a SELECT use db_read.
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": {
"project": "<project>",
"sql": "<sql>"
},
"name": "db_query"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| env | No | preview | |
| sql | Yes | ||
| confirm | No | ||
| project | Yes | Project slug or id. | |
| max_rows | No | ||
| idempotency_key | No | Any unique string; a repeated call with the same key has no second effect. |