execute_adhoc_query
Run SQL SELECT queries directly against a data source for results without saving or leaving traces. Destructive SQL is blocked for safe ad-hoc exploration.
Instructions
Execute a SQL query directly against a data source. No query object is created in Redash — leaves no trace. Destructive SQL (INSERT/UPDATE/DELETE/DROP etc.) is blocked. For running queries this is the DEFAULT tool. Use create_query only when user explicitly asks to save a query to Redash web UI.
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": {
"query": "<query>"
},
"name": "execute_adhoc_query"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | SQL query to execute (SELECT only) | |
| format | No | Result format: 'json' returns data in response, 'csv' saves to file and returns file path | json |
| output_path | No | Custom file path for CSV output. If omitted, saves to cwd as adhoc_{timestamp}.csv | |
| data_source_id | No | Data source ID (from list_data_sources). Optional if REDASH_DEFAULT_DATA_SOURCE_ID is set. |