Skip to main content
Glama

Compare Periods

compare_periods
Read-only

Compare two time periods and rank what changed — THE tool for "what changed in our bill?", "why is this month higher than last?", "what moved week over week?", "which team's spend went up?". Returns totals for both periods, the absolute and percentage delta, and a movers table ranked by the SIZE of the change (largest absolute swing first), each row flagged "new" (spend only in period_a), "gone" (only in period_b), or "changed". Deltas are period_a MINUS period_b — period_b is the baseline. Give explicit windows ({ "period_a": { "start_date": "2026-06-01", "end_date": "2026-06-15" }, "period_b": { … } }) or use preset: "mom" (this month-to-date vs the same day-range of the previous month — also the default when you pass nothing), "wow" (the last 7 days vs the 7 before), "yoy" (this month-to-date vs the same day-range 12 months ago). Break the change down with group_by. "service" (default) and "account" are the FAST path: one call, any window length. Also: "tag:" (any tag key), "subcategory" (usage type), "usage_family", "region", "cost_center", "service_category", "charge_type". Those run two DAILY cost pivots in parallel (never monthly columns, which would compare a partial month against a full one), so: each window must be 31 days or shorter (a longer one is refused); they need one scope — provider OR integration_id, not both — and default to AWS like the fast path, saying so in scopeNote; a tag key is checked against get_available_tag_keys first and a wrong one is refused with the valid keys (keys are case- and hyphen-sensitive); and if the backend serves a different window than requested the tool fails rather than compare clamped data. Tag rows include "untagged" for spend without that tag. If those pivots take longer than the call allows you get { "status": "pending", "jobIds", "resumeWith" }: call compare_periods again with the resumeWith arguments (they include job_ids) to finish — that collects the same jobs instead of starting new ones. Scope with provider and integration_id. cost_basis is applied identically to BOTH periods and echoed as costBasis; on the fast path you can set any subset of the five toggles (the rest keep the organization's saved values), but the pivot group_by values take all five or none, because a pivot can't layer a partial basis over the saved settings. limit caps the movers table (default 25). FOLLOW-UP: this tool tells you WHAT moved; investigate_anomaly tells you WHY for a service, and run_cost_pivot with the mover's dimension plus "service" shows what is inside a tag or usage-type mover. Read-only. Examples: { "preset": "mom", "group_by": "service", "limit": 10 } returns the 10 services that moved the most this month vs the same days last month; { "preset": "mom", "group_by": "tag:team" } does the same per team tag value; { "preset": "wow", "group_by": "subcategory", "provider": "aws" } ranks usage types week over week.

Tool call template

This tool declares no required parameters. Add optional parameters from the input schema as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {},
    "name": "compare_periods"
  }
}

Input Schema

NameRequiredDescriptionDefault
limitNoMax mover rows to return, ranked by the size of the change (default 25).
presetNoRelative windows instead of explicit dates. "mom" = this month-to-date vs the same day-range of the previous month (the default when nothing is given). "wow" = the last 7 days vs the 7 days before them. "yoy" = this month-to-date vs the same day-range 12 months ago. Ignored for whichever period you supply explicitly.
job_idsNoONLY to finish a pivot comparison that returned status "pending": pass back the `jobIds` it gave you, with the SAME group_by, windows and scope (the pending response lists them under `resumeWith`). The jobs are collected, not resubmitted. Not accepted with group_by "service" or "account", which never create jobs.
group_byNoWhat to break the change down by. "service" (default) and "account" are the FAST path (any window length). Also: "tag:<key>" (any tag key — case- and hyphen-sensitive, validated against get_available_tag_keys before running), "subcategory" (usage type), "usage_family", "region", "cost_center", "service_category", "charge_type". Those run two daily cost pivots, so each window must be 31 days or shorter.service
period_aNoThe RECENT window — the one you are asking about. Omit to use the preset (or the default: this month-to-date).
period_bNoThe BASELINE window to compare against. Deltas are period_a minus period_b. Omit to use the preset (or the default: the same day-range of the previous month).
providerNoProvider scope. OMIT = AWS when no integration_id is pinned; with integration_id the scope follows that integration's provider. Pass "azure", "gcp", "snowflake", "anthropic", or "openai" to compare that provider's spend. One provider per call.
cost_basisNoOptional cost-basis override — how cost is computed. LAYERED: each field you set overrides just that toggle for this call; every field you omit keeps the organization's SAVED value. Omit the whole object to use the org's saved settings unchanged. Finance/chargeback questions usually want { "use_amortized": true }; "what did we actually get billed" questions want { "use_amortized": false }. The effective basis is echoed back as `costBasis` in the response, including which toggles this request overrode.
integration_idNoScope to one or more provider connections (integration id). Omit for the whole organization.
response_formatNoconcise = totals, deltas and the top-N movers (default). detailed = additionally every row in both periods, unranked and uncapped (still bounded by the output-size guard).concise

Output Schema

NameRequiredDescriptionDefault
noteNoStates the delta direction and the ingest lag caveat.
toolNoWhich tool truncated (only on a truncated result).
countsNoEntity counts per period plus how many are `new` and `gone`.
jobIdsNoPivot path: the `{ period_a, period_b }` job ids. Pass back as `job_ids` to finish a pending comparison.
moversNoMovers — `name`, `periodACost`, `periodBCost`, `delta`, `deltaPct`, `status` ("new" | "gone" | "changed") — ranked by the ABSOLUTE size of the change.
presetNo"wow" | "mom" | "yoy" | "explicit".
sourceNo"cost_dashboard" (service/account fast path) or "daily_pivot" (two daily cost pivots).
statusNo"pending" when the pivot jobs had not finished; absent on a completed comparison.
totalsNo`periodA`, `periodB`, `delta` and `deltaPct` for the whole scope.
allRowsNoEvery mover row, uncapped (detailed only).
groupByNoThe pivot the change was broken down by.
messageNoHow to narrow the request (only on a truncated result).
periodANoThe recent window { start_date, end_date }.
periodBNoThe baseline window { start_date, end_date }.
currencyNoThe organization's display currency — every amount is in it.
followUpNoThe tool to call next to explain a mover.
costBasisNoThe accounting basis these numbers were computed on: `source` ("organization_defaults" or "organization_defaults+overrides"), an `overrides` array naming the toggles this request pinned, the five resolved toggles (null = kept the org's saved value, which this server cannot read), and a one-line `summary` to quote when reporting the figures.
jobStatusNoPending only: each job's status.
scopeNoteNoPresent when the scope defaulted to AWS on the pivot path.
truncatedNoPresent 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.
moverCountNoHow many movers exist in total.
resumeWithNoPending only: the exact arguments (including `job_ids`) to call compare_periods with to finish.
lastUpdatedNoservice/account path: when this response was generated (NOT a data-ingest time); null on the pivot path. Use get_data_freshness for how current the data is.
approx_charsNoApproximate size of the withheld result (only on a truncated result).
providerScopeNoThe provider these numbers cover.
returnedMoversNoHow many were returned after `limit`.
integrationScopeNoThe integration(s) scoped to, or null.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.8/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Goes far beyond the readOnlyHint/openWorldHint annotations: it discloses the pending-job/resumeWith contract, the hard 31-day refusal on pivots, the fail-rather-than-clamp backend behavior, tag-key validation against get_available_tag_keys, untagged row handling, and that cost_basis is echoed back. For a complex analytic tool with an annotation-only safety profile, this is exactly the missing operational context.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Front-loaded with the value proposition and the fast-path/pivot split, and every major claim is tied to an observable consequence. It is long and re-states schema-level detail (preset meanings, the group_by enumeration), which costs it a point, but density is largely earned by the tool's complexity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

With 10 parameters, nested objects, an output schema, and a two-phase job model, this description covers everything an agent needs: defaults, scope rules, sign convention (period_a minus period_b), failure modes, resume procedure, and follow-up tools. Nothing material is left to inference.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is already 100%, but the description still adds meaning the schema doesn't carry — notably that pivot group_by values require all five cost_basis toggles or none, while the fast path accepts any subset. It also ties limit/group_by/preset defaults to concrete outcomes, though it repeats some enum documentation verbatim.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The opening sentence names a specific verb and resource (compare two periods, rank what changed) and anchors it to concrete user questions ("what changed in our bill?", "why is this month higher than last?"). It also names the outputs (totals, delta, movers table) and distinguishes itself from siblings like investigate_anomaly and run_cost_pivot.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicitly states when to use the fast path (service/account, any window length) versus the pivot path (31-day cap, single scope, tag validation) and when to hand off to investigate_anomaly (why) or run_cost_pivot (what is inside a mover). Presets, defaults, and refusal conditions are all spelled out with worked examples.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources