Skip to main content
Glama

Run analytics query

run_analytics_query
Read-only

Run ShopifyQL queries against store analytics to retrieve sales, sessions, and conversion metrics with grouping, filtering, and limits.

Instructions

Runs a ShopifyQL query against the store's analytics, the same data as the reports in the Shopify admin.

A query names a dataset with FROM and what to show with SHOW, and may group, filter, order and limit: FROM sales SHOW total_sales, orders GROUP BY month SINCE -12m ORDER BY month FROM sales SHOW net_sales GROUP BY product_title SINCE -30d ORDER BY net_sales DESC LIMIT 10 FROM sessions SHOW sessions, conversion_rate GROUP BY day SINCE -7d

Reference: https://shopify.dev/docs/api/shopifyql. Needs the read_reports scope. A query that cannot be parsed comes back as an error with Shopify's explanation.

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": {
      "query": "<query>"
    },
    "name": "run_analytics_query"
  }
}

Input Schema

NameRequiredDescriptionDefault
queryYesThe ShopifyQL query.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.2.0

TDQS

A4.1/5.0
Behavior4/5

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

Annotations already declare readOnlyHint and openWorldHint, so safety is covered; the description adds real value on top: the required read_reports scope, the behavior for unparseable queries ('comes back as an error with Shopify's explanation'), and a reference link. It does not mention result size limits, pagination, or latency, which is the main remaining gap.

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?

Purpose and scope come first, followed by syntax guidance, examples, then auth/error notes. The three examples each demonstrate a different shape (time-series, top-N, sessions) so they earn their space, though the block is longer than strictly minimal.

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

Completeness4/5

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

For a single-parameter read tool with no output schema, it covers the essentials: what data domain, how to construct the query, required auth scope, and error behavior. The notable omission is any hint of the return shape (columns, row limits, format), which matters since there is no output schema.

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 100% but the schema only says 'The ShopifyQL query.' The description substantially compensates by explaining the FROM/SHOW/GROUP BY/SINCE/ORDER BY/LIMIT clause vocabulary and giving three concrete query examples, which is far beyond the schema. Full grammar is delegated to an external doc, so it stops short of 5.

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?

States a specific verb and resource ('Runs a ShopifyQL query against the store's analytics') and anchors it to something the agent can reason about ('the same data as the reports in the Shopify admin'). That framing distinguishes it from the generic graphql_query sibling without needing to name it.

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

Usage Guidelines3/5

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

The three examples implicitly show use cases (sales, sessions, grouped time-series), so an agent can infer this is the reporting path rather than the admin API path. However, no explicit when-to-use/when-not or a named alternative (e.g. graphql_query for non-analytics data) is stated.

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