Run a read-only SQL query
run-queryExecutes a single read-only PostgreSQL query and returns one page of rows, enforcing table allowlists, timeouts, and paging so agents can inspect data without writes.
Instructions
[PostgreSQL] Run one read-only SQL statement and return its rows. Exactly one statement — a second one after a semicolon is rejected by the database, not silently run. It executes inside a read-only transaction with a statement timeout, so nothing it does can change data, and every table it touches must be inside this connector's allowlist: the planner is asked which relations the query resolves to, through views and CTEs included, before a single row is read, and a query that reaches outside is refused with the offending table named. Functions this connector cannot see inside — anything outside pg_catalog — are refused too, so a query calling a helper function must be rewritten against the tables directly. Prefer describe-table over SELECT * on a wide table. The result is ONE PAGE of at most maxRows rows: when hasMore is true you have NOT seen the whole result — call again with page: nextPage. Each page re-runs the query, so pages only line up when it has an ORDER BY on a unique column; add one before paging. For very deep results a keyset predicate (WHERE id > ) is cheaper than a high page number. Long cells are clipped at 2000 characters unless you pass fullValues: true. Never summarise a hasMore: true result as if it were the full answer.
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": "run-query"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sql | Yes | One SQL query: SELECT, WITH … SELECT, VALUES or TABLE. Not a write. | |
| page | No | 1-based page of `maxRows` rows. Walk it up with nextPage while hasMore is true; pages are consistent only under an ORDER BY on a unique column. | |
| maxRows | No | Rows per page, at most 1000. For more rows, keep this and walk `page` with nextPage — add an ORDER BY on a unique column first so the pages line up. The query is stopped at this many rather than truncated afterwards. | |
| timeoutMs | No | Server-side statement timeout, in milliseconds | |
| fullValues | No | Return every cell whole instead of clipping each at 2000 characters. Set it only when you need a long text or JSON value in full: a page of large cells can make a very large response. |