Run Cost Pivot
run_cost_pivotBreak spend down by ANY combination of dimensions — THE tool for "cost by product", "by usage type", "by tag", "by region", "by cost center", "by charge type", or "which provider is this spend on". This is the ONLY tool that can do those pivots: query_costs view="detailed" returns just the pivot vocabulary (pivotsAvailable: false), and to compare two windows by any of these dimensions, use compare_periods with that group_by — it runs the two pivots for you. Group with dimensions (1-3, outermost first): "service", "account", "region", "provider", "service_category", "subcategory" (usage type), "usage_family", "charge_type", "charge_subtype", "tagged", "cost_center", "resource", or "tag:" for any tag key. ⚠ TAG KEYS ARE CASE- AND HYPHEN-SENSITIVE — call get_available_tag_keys first and copy the key exactly; a wrong key silently returns one "untagged" row (the untagged bucket is lowercase). Scope with EXACTLY ONE of provider, integration_id or integration_ids. Window: granularity "monthly" (default) / "weekly" / "daily", plus either explicit start_date/end_date or months_back (default 3, counted in units of the granularity). THE BACKEND CLAMPS SILENTLY — daily to ~30 days, weekly to ~55 days, monthly to ~6 months — so the response always echoes requestedWindow AND returnedWindow, and adds a windowNote when they differ. Report figures against the window that was SERVED. ASYNC: this runs an Athena job. Quick pivots come back with rows; a slow one returns { jobId, status, pollAfterMs } and you call get_cost_pivot with that job_id. Jobs expire 24 hours after creation. ⚠ THE MAIN FAILURE MODE IS RESPONSE_TOO_LARGE (413) on a wide pivot — this backend returns every row in one response and does not page. The fix is FEWER DIMENSIONS or a SHORTER WINDOW, never a different limit (which is applied here, after sorting by _total desc, and cannot shrink the server-side payload). WHICH SPECIFIC RESOURCES: add "resource" as the LAST dimension to break any pivot down to individual resources — "which instances is this service's spend actually on", "which volumes are driving this account". It has FOUR rules, all checked before the job is submitted so you get a sentence instead of an error code: (1) it must be LAST in dimensions; (2) the pivot must be scoped with integration_id — never provider or integration_ids, because resource ids are only meaningful inside one connection; (3) at most 2 other dimensions before it; (4) a monthly window covers at most 3 months, not the usual 6. ⚠ READING RESOURCE ROWS (verified on prod, and NOT what you would assume): _resource_id and _region are OPTIONAL AND INDEPENDENT — a row may have both, either, or neither, within one response. Check before you use them; a missing _resource_id means the backend did not attribute one, NOT that the resource has no id. The displayed resource value is sometimes the full ARN and sometimes just a short name, so prefer _resource_id for console links and fall back to naming the resource without one. resource can also be the EMPTY STRING "" — that is spend with no resource attribution at all (support, commitment fees, tax), not a bug. And rows valued "Others" are the backend's collapse bucket: match that literal string, because such a row can still carry _resource_id and _region when only one small resource was folded into it. RELATED: get_resource_breakdown is the better tool for the SINGLE-SERVICE, SINGLE-DAY question ("what resources drove AmazonRDS on 2026-09-04") — it takes a service and a date directly and needs no job. Use a "resource" pivot when you want resources ACROSS a grouping or over several time columns. Rows use the dimension name verbatim as the key, so a tag pivot row has a literal "tag:user_app" key alongside each time column and _total. Read-only. Examples: { "dimensions": ["tag:user_app"], "provider": "aws", "granularity": "daily", "months_back": 14 } for daily spend by that tag; { "dimensions": ["provider", "service_category"], "provider": "aws", "granularity": "monthly", "months_back": 3 } for a monthly cross-provider category breakdown; { "dimensions": ["cost_center", "service"], "provider": "aws", "limit": 50 } for which services each cost center is spending on; { "dimensions": ["service", "resource"], "integration_id": "", "granularity": "monthly", "months_back": 1 } for the individual resources behind each service on one connection.
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": {
"dimensions": "<dimensions>"
},
"name": "run_cost_pivot"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Max rows to return, applied AFTER sorting by `_total` desc (default 100, max 500). | |
| end_date | No | Window end. Defaults to today; billing data lags 2-3 days, so the last columns are often 0. | |
| provider | No | Pivot across ALL of this provider's connections. Exactly one of provider / integration_id / integration_ids is required. | |
| services | No | Filter to these provider-native service names (get_available_services lists them). | |
| cost_basis | No | Optional accounting basis. ⚠ ALL FIVE toggles are required when you use it: a pivot job applies cost_settings verbatim and does NOT layer a partial basis over the organization's saved settings the way query_costs does. Omit it entirely to use the saved settings. | |
| dimensions | Yes | How to group the spend, outermost first. 1-3 of: "service", "account", "region", "provider", "service_category" (FOCUS category), "subcategory" (usage type), "usage_family", "charge_type", "charge_subtype", "tagged" (Tagged/Untagged split), "cost_center", "resource" — or "tag:<key>" for any tag key. ⚠ TAG KEYS ARE CASE- AND HYPHEN-SENSITIVE: call get_available_tag_keys first and copy the key exactly ("tag:user_app", not "tag:User_App"). Each extra dimension multiplies rows, so start with one or two. ⚠ "resource" HAS ITS OWN RULES: it must be LAST, needs `integration_id` scope (never `provider`/`integration_ids`), allows at most 2 other dimensions, and caps a monthly window at 3 months. | |
| start_date | No | Window start. Omit to use `months_back` (which is translated into a start date for you). | |
| granularity | No | Column width. "monthly" (default) = one column per calendar month, max ~6 months. "weekly" = Monday-anchored weeks, max ~8. "daily" = one per day, max 30. The backend CLAMPS a longer window silently — the response tells you what it actually served. | monthly |
| months_back | No | Relative window size, in units of `granularity` (months / weeks / days). Default 3, and capped at 3 when a `resource` dimension is present. Converted to an explicit start date before submitting, so the window you ask for is the window that is requested. | |
| cost_centers | No | Filter to these cost-center ids. "UNALLOCATED" selects unattributed spend. | |
| wait_seconds | No | How long to wait for the job before handing back a handle (default 20, max 22). Most pivots finish in a few seconds; wide ones do not. | |
| account_names | No | Filter to these sub-account NAMES (get_available_linked_accounts lists them). | |
| integration_id | No | Pivot one connection. REQUIRED for a "resource" dimension, and for daily granularity with 3 dimensions. | |
| integration_ids | No | Pivot an explicit set of connections (they must share one provider). | |
| response_format | No | concise = dimensions, `_total` and the last two time columns per row (default). detailed = every column. | concise |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | No | Backend error code, e.g. RESPONSE_TOO_LARGE. | |
| note | No | What to do next. | |
| rows | No | Pivot rows, largest `_total` first. One key per dimension (named verbatim), one per time column, plus `_total`. On a `resource` pivot each row MAY also carry `_resource_id` and `_region` — both are optional and independent (a row can have both, either or neither), so check before using them; a missing `_resource_id` means the backend attributed none, not that the resource has none. The displayed `resource` value is sometimes the full ARN and sometimes a short name; it is the empty string "" for spend with no resource attribution (support, commitment fees, tax), and the literal "Others" for the backend collapse bucket — which can itself carry `_resource_id`/`_region`, so detect it by that string. | |
| tool | No | Which tool truncated (only on a truncated result). | |
| error | No | True on a backend error envelope. | |
| jobId | No | The pivot job. Pass to get_cost_pivot to pick it up later; expires 24h after creation. | |
| status | No | queued | running | succeeded | failed | cancelled | expired. | |
| columns | No | Time-column labels (YYYY-MM monthly, YYYY-MM-DD weekly/daily). THE authority on the window served. | |
| details | No | Backend error details, when any. | |
| message | No | How to narrow the request (only on a truncated result). | |
| nextStep | No | How to recover from the error in `code`. | |
| rowsNote | No | Present when rows were capped client-side. | |
| expiresAt | No | When the job is discarded (24h after creation). | |
| totalRows | No | How many rows matched before `limit` was applied. | |
| truncated | No | Present and true when the result exceeded the output-size budget and was WITHHELD. When you see this, no data fields are present — narrow the request as `message` says and call again. | |
| dimensions | No | The group-by actually applied, in order. Row keys use these names VERBATIM (a tag dimension is a literal "tag:<key>" key). | |
| isLastPage | No | Always true — see `nextCursor`. | |
| nextCursor | No | Always null: this backend returns every row in one response (paging is disabled). | |
| windowNote | No | Present only when the served window differs from the requested one — the backend clamps silently. Quote it. | |
| emptyReason | No | Why the pivot returned no rows. | |
| grandTotals | No | Org-wide totals per time column plus `_total`, independent of `limit`. | |
| granularity | No | monthly | weekly | daily. | |
| pollAfterMs | No | How long to wait before calling get_cost_pivot (only on a not-yet-finished job). | |
| approx_chars | No | Approximate size of the withheld result (only on a truncated result). | |
| returnedRows | No | How many rows are in `rows`. | |
| collapsedNote | No | Present when the backend folded small rows into an `Others` bucket. | |
| returnedWindow | No | The window actually served, derived from `columns`. | |
| requestedWindow | No | The window asked for, `{start, end}`. |