query
Run read-only DuckDB SQL across one or many Excel/CSV files to join, aggregate, and analyze data, list available tables, and save results to a new file or sheet.
Instructions
Answer questions with SQL across one or MANY spreadsheet files at once (joins, aggregates, window
functions, CTEs, PIVOT) using DuckDB. Read-only SELECT. Call without sql to see which tables exist.
Use output (+ output_sheet) to save results to a new file or a new sheet.
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "query"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sql | No | One DuckDB SELECT (leave empty to list every table name and its columns). Tables: files in the root by name (sales.csv -> sales; book.xlsx -> book / book__sheetname), tables= aliases, or FROM 'dir/file.xlsx#Sheet'. | |
| limit | No | Max rows to return (default from server config, usually 100). | |
| folder | No | Auto-register every file in this folder by name (default: the root). | |
| format | No | json = rows as arrays, records = list of objects, markdown = a table. | json |
| offset | No | Row offset for paging. | |
| output | No | Save the FULL result to this file (.xlsx/.csv/.parquet/.json/.md) instead of returning rows. | |
| tables | No | Optional aliases: {'s': 'data/sales.xlsx#2024', 'c': 'crm/customers.csv'}. A list auto-names by file. | |
| output_sheet | No | When output is an existing .xlsx: write into this sheet (replaced if it exists), keeping other sheets. |