Skip to content

feat(mcp): summarize_orders aggregation tool #41

@dougborg

Description

@dougborg

Problem

Reporting workflows — counts by status, age in current status, count of overdue, top-N customers by order count — require paginating list_orders per status today and aggregating client-side. For a tenant with thousands of orders this is expensive and slow, and most of the data is thrown away after the count.

Proposed shape

A new MCP tool summarize_orders that returns aggregated views:

```python
summarize_orders(
group_by: Literal["status", "due_week", "customer", "tag"],
filters: dict | None = None, # same shape as list_orders filters
)
```

Returns counts (and optionally min/max/avg of relevant numeric fields) per group.

Two implementation paths (choice depends on #30 / F3)

Path A — server has an aggregation endpoint

Thin wrapper over the server endpoint. Cheap, fast.

Path B — server doesn't aggregate

Client-side aggregation: paginate list_orders filtering as requested, group in-process, return counts. Add hard caps:

  • Max items aggregated: 1000 (or whatever the auto-paginator's safety limit is)
  • Truncation flag in response if cap is hit
  • Warning in result UI

Path B is meaningful work and only makes sense if the user actually needs aggregations and Path A isn't coming. If F3 shows the server has nothing planned, this issue may be deferred indefinitely (workflow workaround: agent paginates and groups inline).

Acceptance

  • If Path A: tool wraps the endpoint, returns typed result, has Prefab UI showing the breakdown
  • If Path B: client-side aggregation with explicit caps + truncation flag + clear UI warning
  • At minimum supports group_by="status" (most common ask)
  • Help resource updated

Depends on

Tracking

Part of epic #31, Tier 3. Deferrable — only ship after Tier 1 and Tier 2 land.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/clientTouches statuspro_public_api_client/area/mcpTouches statuspro_mcp_server/ onlypriority/p2Nice-to-have / bigger featurestheme/tool-surface-redesignMCP tool surface redesign initiative

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions