Skip to main content
Glama

Statable Analytics

Query stats

query_stats
Read-only

Run a read-only analytics query for one site: aggregate totals, a time series, or a top-N breakdown. Returns {"results":[{"dimensions":{...omitted for aggregates},"metrics":{...}}]}. All dates and time buckets are in the site's own timezone (see list_sites .timezone). The event:name breakdown lists custom events (data-statable-event); its events metric is the raw event count. The event:goal breakdown lists the site's configured goals with visitors (converters), events (conversions) and conversion_rate (percent). events/conversion_rate are breakdown-only (rejected on aggregate/time-series or a dimension that doesn't compute them). Units: visit_duration = average seconds per visit; bounce_rate = percent 0-100; views_per_visit = pageviews/visits ratio; visitors/pageviews/visits = counts.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
siteNoNumeric site_id (preferred, from list_sites) or a domain, e.g. example.com — scheme, www. and path are ignored when matching. If several sites share the domain the call fails and lists their site_ids. Omit for a single-site key.
limitNoBreakdown only. Default 100, max 1000.
compareNo"previous_period" (equal-length window before date_range) or a custom ["YYYY-MM-DD","YYYY-MM-DD"] pair. Adds a compare {value, change%} block: per-metric (aggregate), per-row (breakdown; not event:status_code/event:goal), or per-bucket (time-series). Time-series needs an equal-length range (else compare_length_mismatch).
filtersNo
metricsYes
date_rangeYesPreset "7d" or "30d" (last N full days), "month" (current calendar month to date; the first bucket may land on the prior month's last day), "realtime" (last ~30 min — pair with the time:minute dimension), "Nd" for the last N days (1..90, e.g. "14d"), or a custom inclusive ["YYYY-MM-DD","YYYY-MM-DD"] pair (over 90 days use a custom pair).
dimensionsNoZero = aggregate; one time dimension (time, time:hour, time:day, time:week, time:month) = time series; one breakdown dimension = top-N. Besides the enum you may also pass a dynamic 'event:props:<key>' dimension to break a custom event down by one of its property values (metrics visitors + events) — it REQUIRES an 'event' filter to name the event, e.g. dimensions:['event:props:plan'] + filters:[{field:'event',operator:'is',values:['Signup']}].

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changed
    • changedInput schema / properties / filters / items / properties / values / description
      Previous value: -"OR-ed together. Values may not contain commas."New value: +"OR-ed together."
  2. Changed2 schema fields changed
    • addedInput schema / properties / compare / type
      Added value: +[
      +  "string",
      +  "array"
      +]
    • addedInput schema / properties / date_range / type
      Added value: +[
      +  "string",
      +  "array"
      +]
  3. First observed

TDQS

A4.1/5.0
Behavior5/5

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

Annotations already declare readOnlyHint=true, destructiveHint=false, and openWorldHint=false, so the safety profile is covered. The description adds substantial behavioral context beyond annotations: timezone handling, event:name and event:goal breakdown semantics, the fact that events/conversion_rate are breakdown-only and rejected on aggregate/time-series queries, and metric unit definitions such as visit_duration in seconds and bounce_rate as a 0-100 percent.

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 description is front-loaded with the core purpose and return shape, then moves into operational details. It is dense but appropriate for a complex analytics query with many modes. Some sentences repeat schema details, such as the dynamic event:props dimension requirement, but most content earns its place by adding semantics not present in the structured schema.

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?

Given no output schema, the description provides a return-shape example and explains key metric and breakdown semantics. Annotations cover safety, and the schema carries detailed parameter documentation. The description fills the remaining gaps needed to invoke the tool correctly, including timezone behavior, breakdown limitations, and metric units.

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 description coverage is 71%, so the schema already documents many parameters in detail. The description compensates meaningfully by explaining metric semantics and units, event:name and event:goal breakdown behavior, and when metrics like events or conversion_rate are rejected. It does not cover every parameter, such as limit or compare, but those are well described in the schema.

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

Purpose4/5

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

The description states a specific verb and resource: 'Run a read-only analytics query for one site: aggregate totals, a time series, or a top-N breakdown.' It clearly frames the tool as a general analytics query with three output modes. It does not explicitly distinguish itself from specialized sibling tools like top_pages, visitors_over_time, or top_custom_events, so it stops short of a 5.

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 description gives implied usage guidance by mapping dimensions to query modes: 'Zero = aggregate; one time dimension ... = time series; one breakdown dimension = top-N.' However, it never names or contrasts the specialized sibling tools, so an agent must infer when to use query_stats instead of top_pages, visitors_over_time, or top_custom_events.

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