Skip to main content
Glama

Compare sales between periods

compare_sales
Read-onlyIdempotent

Shopify's sales breakdown (gross sales, discounts, returns, net sales, total sales, orders) for a span AND its comparison period, line by line with change and changePct, already worked out; compared with the days before, sameTimeLastYear also gives the same dates a year ago, so a seasonal fall shows — the tool for 'why did sales fall', 'what happened against last year', 'compare these weeks with the same weeks last year'. netSalesGap splits the change in net sales into fromGrossSales, fromDiscounts and fromReturns (they add up to the total; negative = that part pulled net sales down) with each part's share of the gap; returnsShareOfGross gives returns ÷ gross in both periods and the change in points; grossPerOrder is gross sales per order; refunds is the NUMBER of refunds issued; traffic gives sessions and the site's conversion rate in both periods (null = no traffic source); customers gives new customers, returning customers and returning customers' orders in both periods. byWeek adds the same per 7-day week, plus lossDays (days whose net sales were below zero: refunds above sales) and weakestDays (the three lowest days). Shares of the gap can add up to more than 100% when discounts moved the other way: say so. grossDrivers (online) splits the change in gross sales into trafficEffect, conversionEffect and valuePerOrderEffect, which add up to grossChange: quote them to say whether fewer people came, fewer bought or each order was worth less. headline is the diagnosis's opening table, already in order: render EVERY row (translate the line names; a rate row's change is in points). These are the store's sales-ladder totals: get_sales_by's product-line netSales can differ by a few euros — quote this tool for store totals. Quote these figures: never subtract the two periods yourself. Returns count in the period the refund was issued, not the period of the order — say so when returns drive the change. complete false = some orders lack the figures and every line understates. Optional from and to (inclusive YYYY-MM-DD, both or neither, never after today) read another span instead of the default period. A named month, a week or two dates the operator gave MUST be sent here: without them this reads the default period (the one on the operator's screen, else the last 30 days), which is not that month. When the operator names no period, send neither.

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_sales"
  }
}

Input Schema

NameRequiredDescriptionDefault
toNoLast day of the span, inclusive, as YYYY-MM-DD; not after today. Send together with `from`, or omit both to read the default period: the one on the operator's screen when the message names it, else the last 30 days.
fromNoFirst day of the span, inclusive, as YYYY-MM-DD. Send together with `to`, or omit both to read the default period: the one on the operator's screen when the message names it, else the last 30 days.
byWeekNoAlso split the span into 7-day weeks from its first day (start the span on a Monday for natural weeks), each compared with the same week of the comparison period. Up to 13 weeks.
compareNoWhat to compare the span with: previous (default, the same number of days just before), yoy (the same dates last year) or yoyWeekday (52 weeks back, the same weekdays — use it for natural Monday–Sunday weeks or whenever the operator says 'last year' over weeks).
compareToNoLast day of the named comparison period, YYYY-MM-DD.
compareFromNoFirst day of a NAMED comparison period, YYYY-MM-DD, with compareTo. For 'September with October': from/to October, compareFrom/compareTo the whole of September. Takes the place of compare.
salesChannelNoOnly online orders (the web shop) or only point-of-sale orders; omit for every channel. When the operator says 'solo web', 'online only' or 'sin POS', send online — and keep sending it for the rest of the conversation.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changed
    • changedInput schema / properties / from / description
      Previous value: -"First day of the span, inclusive, as YYYY-MM-DD. Send together with `to`, or omit both to read the default 30-day period."New value: +"First day of the span, inclusive, as YYYY-MM-DD. Send together with `to`, or omit both to read the default period: the one on the operator's screen when the message names it, else the last 30 days."
    • changedInput schema / properties / to / description
      Previous value: -"Last day of the span, inclusive, as YYYY-MM-DD; not after today. Send together with `from`, or omit both to read the default 30-day period."New value: +"Last day of the span, inclusive, as YYYY-MM-DD; not after today. Send together with `from`, or omit both to read the default period: the one on the operator's screen when the message names it, else the last 30 days."
  2. Changed2 schema fields changed
    • addedInput schema / properties / compareFrom
      Added value: +{
      +  "description": "First day of a NAMED comparison period, YYYY-MM-DD, with compareTo. For 'September with October': from/to October, compareFrom/compareTo the whole of September. Takes the place of compare.",
      +  "format": "date",
      +  "type": "string"
      +}
    • addedInput schema / properties / compareTo
      Added value: +{
      +  "description": "Last day of the named comparison period, YYYY-MM-DD.",
      +  "format": "date",
      +  "type": "string"
      +}
  3. Added

TDQS

A4.5/5.0
Behavior3/5

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

Annotations already declare readOnlyHint, idempotentHint, non-destructive and closed-world, so the safety profile is covered. The description adds substantial behavior the annotations cannot: 'complete false = some orders lack the figures and every line understates', returns are counted in the refund-issue period, gap shares can exceed 100% when discounts moved the other way, and negative decomposition parts mean that part pulled net sales down. It stops short of describing pagination or row-count limits, so this sits between adequate and strong rather than a full 5.

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?

The purpose and the sibling distinction are front-loaded, and nearly every clause carries operational information (quote these figures, never subtract the periods yourself, render every headline row). It is nonetheless a dense semicolon-chained block of roughly 350 words that is harder to scan than it needs to be; the output-field inventory could be grouped more tightly.

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?

This is a complex, seven-parameter analytical tool with no output schema, and the description compensates by enumerating the returned lines (netSalesGap components, returnsShareOfGross, grossPerOrder, traffic, customers, byWeek extras, grossDrivers) and instructing how to quote them. Nothing an agent needs in order to call or interpret it appears to be missing.

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

Parameters5/5

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

Schema coverage is 100%, yet the description still adds real meaning beyond it: from/to must be sent together or both omitted and never after today, the default period is 'the one on the operator's screen, else the last 30 days', compareFrom/compareTo replace compare for named periods with a concrete 'September with October' example, byWeek starts on a Monday and caps at 13 weeks, and salesChannel should persist for the rest of the conversation. These are cross-parameter constraints the schema does not express.

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 description names a specific verb and resource ('sales breakdown ... for a span AND its comparison period, line by line with change and changePct') and explicitly distinguishes itself from get_sales_by by scoping ('get_sales_by's product-line netSales can differ by a few euros — quote this tool for store totals'). An agent can tell what it produces and what it does not without opening the schema.

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?

It gives explicit trigger phrasings ('why did sales fall', 'what happened against last year', 'compare these weeks with the same weeks last year'), states when from/to MUST be sent for a named month or operator-given dates, and states the when-not case ('When the operator names no period, send neither'). It also names the sibling for product-line totals and gives a persistence rule for salesChannel.

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