Run a read-only SQL query
run_sqlExecutes one read-only SELECT query against the database and returns rows; unsafe or failed queries are rejected with the reason so you can correct them and rerun.
Instructions
Run one read-only SQL query and return its rows.
The query is parsed and checked first: only SELECT on this database's tables, no functions that read files, URLs or settings. A refused or failed query returns the reason, so you can fix it.
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_sql"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sql | Yes | One SELECT (or WITH ... SELECT) query in the database's dialect (see list_tables). | |
| max_rows | No | Maximum rows to return (1-1000). |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sql | Yes | The query that actually ran (normalised by the guard, with the row cap applied). | |
| rows | Yes | ||
| columns | Yes | ||
| row_count | Yes | ||
| truncated | Yes | True if more rows exist than were returned. |