query_range
Filter, project, sort, paginate, and aggregate spreadsheet ranges server-side, so agents read only the rows and columns they need instead of an entire sheet.
Instructions
Filter, project, sort, paginate, and aggregate a range SERVER-SIDE so an agent reads only the rows and columns it needs instead of a whole sheet.
location defaults to the sheet's true used range. With header=true the first row names the columns (otherwise the A1 letter does). where is a list of {column, op, value} predicates joined by match ('all' or 'any'); ops: eq, ne, gt, ge, lt, le, contains, startswith, endswith, regex, in, not_in, is_blank, not_blank. columns projects a subset; order_by is a list of {column, dir} specs (unknown directions refuse); offset and limit page; distinct dedupes. aggregate is a list of {column, func} (count, count_nonblank, count_distinct, sum, avg, min, max, first, last), optionally per group_by (records=true emits objects).
Semantics: predicates read CACHED and literal values (uncalculated formulas read as blank; recalc for exact results); gt/ge/lt/le compare numerically when both sides coerce, else case-folded text; blanks never satisfy ordered comparisons; regex is timeout-guarded. Aggregates follow Excel: sum/avg/min/max consume NUMERIC cells only (text and booleans ignored even when text looks numeric; exclusions are reported); count is the RAW row count, unlike Excel COUNT; min/max fall back to text when no numbers exist. Filter-hidden rows are read and aggregated like any other row, unlike SUBTOTAL; use where to drop them. Read-only.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | ||
| limit | No | ||
| match | No | all | |
| sheet | No | ||
| where | No | Filter predicates, {column, op, value}, joined by match. | |
| header | No | ||
| offset | No | ||
| values | No | cached | |
| columns | No | Columns to project: header names, letters, or 1-based numbers. | |
| records | No | ||
| distinct | No | ||
| group_by | No | One column to group by, or several. | |
| location | No | ||
| order_by | No | Sort specs, {column, dir}; unknown directions refuse. | |
| aggregate | No | Aggregations, {column, func}, optionally per group_by. |