filter_resource
Filter and retrieve records from a cached open data file using SQL-like WHERE, SELECT, ORDER BY, and LIMIT conditions. Returns matching rows and total count.
Instructions
Run a typed WHERE/SELECT/ORDER BY/LIMIT against a cached resource.
First call downloads the file (up to 100 MB) and caches it as Parquet at ~/.cache/datosgobdo-mcp/. Subsequent calls hit cache (<1s). Returns requested columns + matching rows (capped at limit) plus the total count of matching rows. Use this when you need actual records, not aggregates.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes | Direct URL to the file (CKAN resource 'url' field). | |
| format | Yes | Format declared in CKAN. Accepts: csv, tsv, xlsx, json. | |
| filters | No | Optional list of filter conditions, AND-combined. Each item is {col, op, val}. Valid ops: =, !=, <, <=, >, >=, in, not_in, contains, starts_with, ends_with, is_null, is_not_null. Example: [{"col":"Año","op":"=","val":2026},{"col":"Mes","op":"=","val":"Abril"}]. | |
| columns | No | Columns to SELECT. None = all columns. | |
| order_by | No | List of {col, dir} where dir is "asc" or "desc". Example: [{"col":"Sueldo Bruto","dir":"desc"}]. | |
| limit | No | Max rows to return (1-1000). | |
| offset | No | Rows to skip (for paginating). |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| error | No | ||
| hint | No | ||
| source_url | No | ||
| format | No | ||
| cache | No | ||
| matching_rows_total | No | ||
| rows_returned | No | ||
| columns | No | ||
| limit | No | ||
| offset | No | ||
| rows | No |