Aggregate Card Field
crm_aggregate_card_fieldGroup cards by the value of a custom field and count each value (a group-by/tally). Use it for questions the built-in report cannot answer because the data lives in a custom field — e.g. "main loss reason" when the board has a select field like "motivo_perda" on the lost phase. Workflow: 1) crm_get_board_structure to find the field slug (and its options); 2) call this with the slug, optionally scoping by phaseId (e.g. the lost phase), date range or tags. Returns buckets [{ value, label, count }] sorted desc and topValue. Honors a maxCards scan cap (flags truncated).
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": {
"boardId": "<boardId>",
"fieldSlug": "<fieldSlug>"
},
"name": "crm_aggregate_card_field"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| tagIds | No | Optional: only cards carrying ANY of these tag documentIds. | |
| boardId | Yes | Board documentId whose cards will be scanned. | |
| phaseId | No | Optional: only cards CURRENTLY in this phase (e.g. the lost phase). | |
| maxCards | No | Safety cap on how many cards to scan (default 2000). Result flags truncated=true when exceeded. | |
| fieldSlug | Yes | Slug of the custom field to aggregate (discover it via crm_get_board_structure). E.g. "motivo_perda". | |
| createdAfter | No | Optional: only cards created at/after this ISO datetime. | |
| createdBefore | No | Optional: only cards created at/before this ISO datetime. |