Run SQL
execute_queryRun ad hoc SQL on one connection and return the rows as JSON objects keyed by column name, plus column names, rowCount, duration in ms and a truncated flag. Use it to answer a one-off question. If a saved query already answers it, use run_saved_query instead; to hand the data on as a file, use export_query_results. Read-only: only a single SELECT, WITH or EXPLAIN statement is accepted, and anything else is rejected without running. Refused on an approved_queries connection; use run_saved_query there. A repeated identical query may return a result cached for up to 5 minutes. Each call counts against the company's monthly query quota and a limit of 30 queries per minute (the team can set a lower one per connection). Needs the execute scope and a member role that can edit; viewers get an error. A database error is returned as an error with the database's message. The team can require a person to approve some requests: the call then fails with code APPROVAL_REQUIRED and an approvalUrl. Show the user that link, wait until they say it is approved, then repeat the exact same call with approvalId. An approval works once, for that SQL, within 30 minutes.
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": {
"connectionId": "<connectionId>",
"sql": "<sql>"
},
"name": "execute_query"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sql | Yes | The SQL to run, in the connection's own dialect. | |
| limit | No | Maximum rows to return, 1 to 10000. Defaults to 1000. The team can set a lower limit per connection. The result's truncated flag is true when rows were cut. | |
| approvalId | No | Only when repeating a call that came back with APPROVAL_REQUIRED, after the user approved it. Send the same arguments again. | |
| connectionId | Yes | Connection id from list_connections. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | No | ||
| success | No |