run_query
Execute one SQL statement on a saved database connection and get rows back as an aligned text table or JSON, with row and byte limits and cursor paging for large results.
Instructions
Runs one SQL statement on a connection and returns its rows as an aligned text table (or JSON with format=json, where integers beyond 2^53 are strings so that no JSON parser rounds them), saying when rows or long values were left out. In the text table SQL NULL is NULL, and a text that reads NULL shows quoted, 'NULL'. Defaults: 100 rows, 32768 bytes, 30 s timeout; max_rows, max_bytes and timeout_seconds raise them up to 10000 rows, 1048576 bytes and 300 s. On read_only connections only statements that change nothing run, in a read-only transaction; on read_write connections changes commit at once, and UPDATE or DELETE without WHERE is refused unless the user's safety settings allow it. Use the database's own SQL dialect. A result cut by max_rows or max_bytes returns a cursor (the cursor field in JSON) for next_page to read the rest.
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": {
"connection": "<connection>",
"sql": "<sql>"
},
"name": "run_query"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sql | Yes | One SQL statement. | |
| format | No | `text` (an aligned table, the default) or `json`. | |
| max_rows | No | Rows returned at most (default 100, up to 10000). | |
| max_bytes | No | Bytes of output at most (default 32768, up to 1048576). | |
| connection | Yes | The connection's name, as `list_connections` shows it. | |
| timeout_seconds | No | Seconds the statement may run before it is cancelled (default 30, up to 300). |