Skip to main content
Glama

Sales by product, collection or tag

get_sales_by
Read-onlyIdempotent

Product sales for the period grouped by product, product type, collection, tag or sales channel, optionally narrowed to some collections, product types, tags, title words or one sales channel. Use for any question the fixed product tools cannot answer: 'how much did the Special Prices collection sell this week', 'sales by tag', 'online vs in-store by product', 'how is product X doing' (search), or any product beyond the top ten. Per row: revenue (without VAT, before returns), returns (an ESTIMATE per group: each refund is split pro rata across its order's lines because Shopify's refund lines are not stored per product, so write 'unas', 'aproximadamente' or 'estimated' for a group's returns and its return rate, never as exact), netSales (= revenue − returns), units, orders, cost, grossProfit and marginPct (null = costs unknown, never zero), share of the filtered total, and previousNetSales with changePct against the comparison period. total counts every matching line ONCE; storeNetSales is every product line in the period, and filteredShare = total.netSales ÷ storeNetSales — that IS the answer to 'what part of sales came from X', quote it rather than dividing. overlapping true (collection, tag) = a product counts in each of its collections or tags, so rows can add up to more than the total: never sum them. A row with an empty label is 'none' (no collection, no tag, no type). collections.unmatched lists names that matched no collection and collections.available the store's real ones: retry with one, or say it does not exist. partialCollections = collections Nuira holds only part of the products of (Shopify lists more), so their figures are a floor: say so. Membership is the collection's current one, not as of each order. Revenue here is product line revenue, which is why it differs from get_summary's order revenue. 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

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": {
      "by": "<by>"
    },
    "name": "get_sales_by"
  }
}

Input Schema

NameRequiredDescriptionDefault
byYesHow to group the sales: product, productType (Shopify's product type), collection, tag, or salesChannel (online, pos, …). By product, every row also carries `stock`: unitsNow, variants, variantsOutNow (tracked variants at 0 now), untrackedVariants (not counted by Shopify, never 'sold out') and variantsOutDuring (variants seen at 0 during the span; observations start at stockObservedSince, null before) — the read for 'do the products that sell have stock?'.
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.
dirNodesc (default, biggest first) or asc (smallest first).
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.
sortNoRow order: netSales (default), units, orders, changePct, returns (dir desc lists what is returned most; estimates per product), or netSalesChange (with compare: the money change, so dir asc lists the biggest falls first and desc the biggest rises).
tagsNoOnly products with these tags, any of them.
limitNoRows to return, 1 to 50; default 20.
searchNoOnly products whose title contains these words.
compareNoCompare every row with this period: previous (default), yoy (same dates last year) or yoyWeekday (52 weeks back). When given, each row also carries lastPeriod (the comparison's revenue, returns, units and orders), netSalesChange, revenueChange, returnsChange and returnRate (returns ÷ revenue in both periods, change in points; null in a period where refunds passed sales, which moreReturnedThanSold names as current, previous or both), volumeEffect and priceEffect (revenueChange from selling more or fewer units, and from price, discounts and mix), and shareOfChange (the row's part of the whole set's change in net sales, can pass 100% or be negative when other rows moved the other way), and totalComparison compares the whole filtered set: revenue, returns, netSales, units, orders, pricePerUnit (revenue per unit sold), volumeEffect, priceEffect and returnRate — quote them instead of subtracting.
compareToNoLast day of the named comparison period, YYYY-MM-DD.
collectionsNoOnly products in these collections (titles or handles; a part of the title is enough), any of them.
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.
productTypesNoOnly these product types, any of them.
salesChannelNoOnly online orders, or only point-of-sale orders.

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. Changed2 schema fields changed
    • changedInput schema / properties / sort / description
      Previous value: -"Row order: netSales (default), units, orders, changePct, or netSalesChange (with compare: the money change, so dir asc lists the biggest falls first and desc the biggest rises)."New value: +"Row order: netSales (default), units, orders, changePct, returns (dir desc lists what is returned most; estimates per product), or netSalesChange (with compare: the money change, so dir asc lists the biggest falls first and desc the biggest rises)."
    • changedInput schema / properties / sort / enum
      Previous value: -[
      -  "netSales",
      -  "units",
      -  "orders",
      -  "changePct",
      -  "netSalesChange"
      -]New value: +[
      +  "netSales",
      +  "units",
      +  "orders",
      +  "changePct",
      +  "returns",
      +  "netSalesChange"
      +]
  4. Changed1 schema field changed
    • changedInput schema / properties / compare / description
      Previous value: -"Compare every row with this period: previous (default), yoy (same dates last year) or yoyWeekday (52 weeks back). When given, each row also carries the comparison period's revenue, returns, units and orders, netSalesChange, revenueChange, returnsChange and returnRate (returns ÷ revenue in both periods, change in points; above 1 means refunds of EARLIER sales exceeded this period's sales of that group — say that, never call it a rate over 100%), volumeEffect and priceEffect (revenueChange from selling more or fewer units, and from price, discounts and mix), and shareOfChange (the row's part of the whole set's change in net sales, can pass 100% or be negative when other rows moved the other way), and totalComparison compares the whole filtered set: revenue, returns, netSales, units, orders, pricePerUnit (revenue per unit sold), volumeEffect, priceEffect and returnRate — quote them instead of subtracting."New value: +"Compare every row with this period: previous (default), yoy (same dates last year) or yoyWeekday (52 weeks back). When given, each row also carries lastPeriod (the comparison's revenue, returns, units and orders), netSalesChange, revenueChange, returnsChange and returnRate (returns ÷ revenue in both periods, change in points; null in a period where refunds passed sales, which moreReturnedThanSold names as current, previous or both), volumeEffect and priceEffect (revenueChange from selling more or fewer units, and from price, discounts and mix), and shareOfChange (the row's part of the whole set's change in net sales, can pass 100% or be negative when other rows moved the other way), and totalComparison compares the whole filtered set: revenue, returns, netSales, units, orders, pricePerUnit (revenue per unit sold), volumeEffect, priceEffect and returnRate — quote them instead of subtracting."
  5. Changed1 schema field changed
    • changedInput schema / properties / compare / description
      Previous value: -"Compare every row with this period: previous (default), yoy (same dates last year) or yoyWeekday (52 weeks back). When given, each row also carries the comparison period's revenue, returns, units and orders, netSalesChange, revenueChange, returnsChange and returnRate (returns ÷ revenue in both periods, change in points; above 1 means refunds of EARLIER sales exceeded this period's sales of that group — say that, never call it a rate over 100%), and totalComparison compares the whole filtered set: revenue, returns, netSales, units, orders, pricePerUnit (revenue per unit sold) and returnRate — quote them instead of subtracting."New value: +"Compare every row with this period: previous (default), yoy (same dates last year) or yoyWeekday (52 weeks back). When given, each row also carries the comparison period's revenue, returns, units and orders, netSalesChange, revenueChange, returnsChange and returnRate (returns ÷ revenue in both periods, change in points; above 1 means refunds of EARLIER sales exceeded this period's sales of that group — say that, never call it a rate over 100%), volumeEffect and priceEffect (revenueChange from selling more or fewer units, and from price, discounts and mix), and shareOfChange (the row's part of the whole set's change in net sales, can pass 100% or be negative when other rows moved the other way), and totalComparison compares the whole filtered set: revenue, returns, netSales, units, orders, pricePerUnit (revenue per unit sold), volumeEffect, priceEffect and returnRate — quote them instead of subtracting."
  6. Changed4 schema fields changed
    • changedInput schema / properties / by / description
      Previous value: -"How to group the sales: product, productType (Shopify's product type), collection, tag, or salesChannel (online, pos, …)."New value: +"How to group the sales: product, productType (Shopify's product type), collection, tag, or salesChannel (online, pos, …). By product, every row also carries `stock`: unitsNow, variants, variantsOutNow (tracked variants at 0 now), untrackedVariants (not counted by Shopify, never 'sold out') and variantsOutDuring (variants seen at 0 during the span; observations start at stockObservedSince, null before) — the read for 'do the products that sell have stock?'."
    • changedInput schema / properties / compare / description
      Previous value: -"Compare every row with this period: previous (default), yoy (same dates last year) or yoyWeekday (52 weeks back). When given, each row also carries the comparison period's revenue, returns, units and orders, netSalesChange, revenueChange, returnsChange and returnRate (returns ÷ revenue in both periods, change in points) — quote them instead of subtracting."New value: +"Compare every row with this period: previous (default), yoy (same dates last year) or yoyWeekday (52 weeks back). When given, each row also carries the comparison period's revenue, returns, units and orders, netSalesChange, revenueChange, returnsChange and returnRate (returns ÷ revenue in both periods, change in points; above 1 means refunds of EARLIER sales exceeded this period's sales of that group — say that, never call it a rate over 100%), and totalComparison compares the whole filtered set: revenue, returns, netSales, units, orders, pricePerUnit (revenue per unit sold) and returnRate — quote them instead of subtracting."
    • changedInput schema / properties / sort / description
      Previous value: -"Row order: netSales (default), units, orders or changePct."New value: +"Row order: netSales (default), units, orders, changePct, or netSalesChange (with compare: the money change, so dir asc lists the biggest falls first and desc the biggest rises)."
    • changedInput schema / properties / sort / enum
      Previous value: -[
      -  "netSales",
      -  "units",
      -  "orders",
      -  "changePct"
      -]New value: +[
      +  "netSales",
      +  "units",
      +  "orders",
      +  "changePct",
      +  "netSalesChange"
      +]
  7. Changed1 schema field changed
    • addedInput schema / properties / compare
      Added value: +{
      +  "description": "Compare every row with this period: previous (default), yoy (same dates last year) or yoyWeekday (52 weeks back). When given, each row also carries the comparison period's revenue, returns, units and orders, netSalesChange, revenueChange, returnsChange and returnRate (returns ÷ revenue in both periods, change in points) — quote them instead of subtracting.",
      +  "enum": [
      +    "previous",
      +    "yoy",
      +    "yoyWeekday"
      +  ],
      +  "type": "string"
      +}
  8. Added

TDQS

A4.6/5.0
Behavior5/5

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

Annotations only declare readOnly/idempotent/non-destructive, so the description carries the real semantic burden and does it: returns are an ESTIMATE split pro rata with required hedging language ('unas', 'aproximadamente'), marginPct null means unknown never zero, overlapping collections/tags mean rows can exceed the total and must never be summed, partialCollections figures are a floor, and collection membership is current rather than historical. These are exactly the traps an agent would otherwise fall into.

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 purpose and routing before dropping into output-field semantics, and nearly every clause carries an operational rule. It loses a point for being one undivided block of long semicolon-chained sentences, with the from/to default-period rule stated twice, which hurts scannability for a 14-parameter tool.

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 no output schema, the description still enumerates every returned field (revenue, returns, netSales, units, orders, cost, grossProfit, marginPct, share, previousNetSales/changePct) and defines total vs storeNetSales vs filteredShare precisely enough to quote directly. Edge cases — empty labels as 'none', collections.unmatched vs .available, comparison-period fields — are all covered.

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

Parameters3/5

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

Schema description coverage is 100% and the schema already documents enums, defaults, formats and even the from/to pairing rule, so the baseline is 3. The description reinforces the period contract ('both or neither, never after today') and explains why get_sales_by revenue differs from get_summary's, but it adds little per-parameter meaning the schema does not already carry.

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?

Opens with a specific verb+resource+grouping dimension ('Product sales for the period grouped by product, product type, collection, tag or sales channel') and immediately frames its niche against siblings ('Use for any question the fixed product tools cannot answer ... or any product beyond the top ten'). An agent can distinguish it from get_summary and the fixed product tools without opening either 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?

Gives concrete when-to-use examples mapped to real question phrasings ('how much did the Special Prices collection sell this week', 'online vs in-store by product'), an explicit boundary against other tools, and a prescriptive rule for the period question ('A named month, a week or two dates the operator gave MUST be sent here ... When the operator names no period, send neither'). This is explicit routing guidance, not implied.

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