Skip to main content
Glama

Run a custom insight query

query_insights
Read-onlyIdempotent

[read-only] Read-only analytics query: one metric aggregated (median by default) over posts, broken down by up to a few dimensions (platform, weekday, hour, brand, campaign, postType, label:, arm), at a fixed post age window (48h / 7d / 30d / lifetime) so posts are compared fairly. Every row carries its sample size n; platforms that do not report the metric are listed in availability, never counted as 0. Pro plan or higher. (Wraps POST /api/v2/insights/query.)

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": "query_insights"
  }
}

Input Schema

NameRequiredDescriptionDefault
dateToNoISO date or epoch ms. Default: now.
formatNocsv = the result as a spreadsheet-safe CSV attachment (UTF-8 BOM, CRLF, cells starting with = + - @ are prefixed with '). Without `format`, `Accept: text/csv` also selects CSV. Errors are always JSON.json
metricNoimpressions
windowNoSnapshot age: the metric as it stood 48h / 7d / 30d after publish, or the latest refresh.7d
brandIdNoA brand id, or "all" (default: every profile you can see). A brand-bound key is always its own brand.
filtersNo
formulaNoOptional (needs the Advanced insights feature): combine up to three series. Each series is a metric + aggregation over the same breakdown, window, interval, filters and range. `expression` (≤ 80 characters) uses A, B, C, numbers, + - * / and parentheses, e.g. "A / B". Rows are joined on their keys; a group missing from any series, or a division by zero, is null. n = the smallest n across series. `metric` defaults to (and must equal) series A's. Referral series can only be split by platform, weekday or hour.
dateFromNoISO date or epoch ms (publish time). Default: 90 days ago; ranges are capped at 400 days.
intervalNoAdds a time series bucketed by publish date.
breakdownNoUp to 2 of: platform, brand, campaign, experiment, arm, weekday, hour, postType, or label:<key> (e.g. label:cut, label:line, label:source, label:hook, label:series). The multi-valued format key also splits per group: label:format@length, label:format@style, label:format@non_video, label:format@method (a post counts once in each, never twice in one). A post with no source: label (or no length) falls back to how it was made; those rows have `derived` > 0 and a "derived" label, and no label is written. "arm" = the experiment's compareKey and needs filters.experimentId.
aggregationNoDefault median; pooled for the rates engagementRate, ctr and completionRate. A rate is pooled (Σ numerator ÷ Σ denominator), mean, median or count, never sum or p90. Pooled applies to rates only.median
tzOffsetMinutesNoOffset from UTC for weekday / hour / day buckets (e.g. -300).

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed5 schema fields changed
    • changedInput schema / properties / breakdown / description
      Previous value: -"Up to 2 of: platform, brand, campaign, experiment, arm, weekday, hour, postType, or label:<key> (e.g. label:cut, label:line, label:source, label:hook, label:series). The multi-valued format key also splits per group: label:format@length, label:format@style, label:format@non_video (a post counts once in each, never twice in one). A post with no source: label (or no length) falls back to how it was made; those rows have `derived` > 0 and a \"derived\" label, and no label is written. \"arm\" = the experiment's compareKey and needs filters.experimentId."New value: +"Up to 2 of: platform, brand, campaign, experiment, arm, weekday, hour, postType, or label:<key> (e.g. label:cut, label:line, label:source, label:hook, label:series). The multi-valued format key also splits per group: label:format@length, label:format@style, label:format@non_video, label:format@method (a post counts once in each, never twice in one). A post with no source: label (or no length) falls back to how it was made; those rows have `derived` > 0 and a \"derived\" label, and no label is written. \"arm\" = the experiment's compareKey and needs filters.experimentId."
    • changedInput schema / properties / formula / properties / series / properties / A / properties / metric / enum
      Previous value: -[
      -  "impressions",
      -  "views",
      -  "engagement",
      -  "engagementRate",
      -  "clicks",
      -  "ctr",
      -  "reach",
      -  "likes",
      -  "comments",
      -  "shares",
      -  "saves",
      -  "followersGained",
      -  "watchTimeHours",
      -  "avgWatchSeconds",
      -  "completionRate",
      -  "postsPublished",
      -  "referralClicks"
      -]New value: +[
      +  "impressions",
      +  "views",
      +  "engagement",
      +  "engagementRate",
      +  "clicks",
      +  "ctr",
      +  "reach",
      +  "likes",
      +  "comments",
      +  "shares",
      +  "saves",
      +  "followersGained",
      +  "watchTimeHours",
      +  "avgWatchSeconds",
      +  "completionRate",
      +  "postsPublished",
      +  "referralClicks",
      +  "siteVisits",
      +  "visitsPer1kReach"
      +]
    • changedInput schema / properties / formula / properties / series / properties / B / properties / metric / enum
      Previous value: -[
      -  "impressions",
      -  "views",
      -  "engagement",
      -  "engagementRate",
      -  "clicks",
      -  "ctr",
      -  "reach",
      -  "likes",
      -  "comments",
      -  "shares",
      -  "saves",
      -  "followersGained",
      -  "watchTimeHours",
      -  "avgWatchSeconds",
      -  "completionRate",
      -  "postsPublished",
      -  "referralClicks"
      -]New value: +[
      +  "impressions",
      +  "views",
      +  "engagement",
      +  "engagementRate",
      +  "clicks",
      +  "ctr",
      +  "reach",
      +  "likes",
      +  "comments",
      +  "shares",
      +  "saves",
      +  "followersGained",
      +  "watchTimeHours",
      +  "avgWatchSeconds",
      +  "completionRate",
      +  "postsPublished",
      +  "referralClicks",
      +  "siteVisits",
      +  "visitsPer1kReach"
      +]
    • changedInput schema / properties / formula / properties / series / properties / C / properties / metric / enum
      Previous value: -[
      -  "impressions",
      -  "views",
      -  "engagement",
      -  "engagementRate",
      -  "clicks",
      -  "ctr",
      -  "reach",
      -  "likes",
      -  "comments",
      -  "shares",
      -  "saves",
      -  "followersGained",
      -  "watchTimeHours",
      -  "avgWatchSeconds",
      -  "completionRate",
      -  "postsPublished",
      -  "referralClicks"
      -]New value: +[
      +  "impressions",
      +  "views",
      +  "engagement",
      +  "engagementRate",
      +  "clicks",
      +  "ctr",
      +  "reach",
      +  "likes",
      +  "comments",
      +  "shares",
      +  "saves",
      +  "followersGained",
      +  "watchTimeHours",
      +  "avgWatchSeconds",
      +  "completionRate",
      +  "postsPublished",
      +  "referralClicks",
      +  "siteVisits",
      +  "visitsPer1kReach"
      +]
    • changedInput schema / properties / metric / enum
      Previous value: -[
      -  "impressions",
      -  "views",
      -  "engagement",
      -  "engagementRate",
      -  "clicks",
      -  "ctr",
      -  "reach",
      -  "likes",
      -  "comments",
      -  "shares",
      -  "saves",
      -  "followersGained",
      -  "watchTimeHours",
      -  "avgWatchSeconds",
      -  "completionRate",
      -  "postsPublished",
      -  "referralClicks"
      -]New value: +[
      +  "impressions",
      +  "views",
      +  "engagement",
      +  "engagementRate",
      +  "clicks",
      +  "ctr",
      +  "reach",
      +  "likes",
      +  "comments",
      +  "shares",
      +  "saves",
      +  "followersGained",
      +  "watchTimeHours",
      +  "avgWatchSeconds",
      +  "completionRate",
      +  "postsPublished",
      +  "referralClicks",
      +  "siteVisits",
      +  "visitsPer1kReach"
      +]
  2. Changed7 schema fields changed
    • addedInput schema / properties / aggregation / description
      Added value: +"Default median; pooled for the rates engagementRate, ctr and completionRate. A rate is pooled (Σ numerator ÷ Σ denominator), mean, median or count, never sum or p90. Pooled applies to rates only."
    • changedInput schema / properties / aggregation / enum
      Previous value: -[
      -  "sum",
      -  "mean",
      -  "median",
      -  "p90",
      -  "count"
      -]New value: +[
      +  "sum",
      +  "mean",
      +  "median",
      +  "p90",
      +  "count",
      +  "pooled"
      +]
    • changedInput schema / properties / breakdown / description
      Previous value: -"Up to 2 of: platform, brand, campaign, experiment, arm, weekday, hour, postType, or label:<key> (e.g. label:cut). \"arm\" = the experiment's compareKey and needs filters.experimentId."New value: +"Up to 2 of: platform, brand, campaign, experiment, arm, weekday, hour, postType, or label:<key> (e.g. label:cut, label:line, label:source, label:hook, label:series). The multi-valued format key also splits per group: label:format@length, label:format@style, label:format@non_video (a post counts once in each, never twice in one). A post with no source: label (or no length) falls back to how it was made; those rows have `derived` > 0 and a \"derived\" label, and no label is written. \"arm\" = the experiment's compareKey and needs filters.experimentId."
    • addedInput schema / properties / filters / properties / excludeLabels
      Added value: +{
      +  "description": "Posts with any of these labels are left out (the tag templates exclude line:test).",
      +  "items": {
      +    "type": "string"
      +  },
      +  "maxItems": 5,
      +  "type": "array"
      +}
    • changedInput schema / properties / formula / properties / series / properties / A / properties / aggregation / enum
      Previous value: -[
      -  "sum",
      -  "mean",
      -  "median",
      -  "p90",
      -  "count"
      -]New value: +[
      +  "sum",
      +  "mean",
      +  "median",
      +  "p90",
      +  "count",
      +  "pooled"
      +]
    • changedInput schema / properties / formula / properties / series / properties / B / properties / aggregation / enum
      Previous value: -[
      -  "sum",
      -  "mean",
      -  "median",
      -  "p90",
      -  "count"
      -]New value: +[
      +  "sum",
      +  "mean",
      +  "median",
      +  "p90",
      +  "count",
      +  "pooled"
      +]
    • changedInput schema / properties / formula / properties / series / properties / C / properties / aggregation / enum
      Previous value: -[
      -  "sum",
      -  "mean",
      -  "median",
      -  "p90",
      -  "count"
      -]New value: +[
      +  "sum",
      +  "mean",
      +  "median",
      +  "p90",
      +  "count",
      +  "pooled"
      +]
  3. First observed

TDQS

A3.6/5.0
Behavior4/5

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

Annotations already cover the safety profile (readOnly, idempotent, non-destructive), yet the description still adds substantive behavior: every row carries sample size n, non-reporting platforms appear in `availability` rather than as zeros, and a Pro plan is required. That is real context beyond the structured fields, though it says nothing about result size, rate limits, or error behavior beyond the CSV note in the schema.

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 lead sentence front-loads the core contract — read-only, one metric, dimensions, fixed window — before the operational caveats, and the trailing endpoint note is compact. The second sentence is long and packs several ideas (n, availability, plan tier) into one clause chain, but no sentence is pure filler.

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

Completeness3/5

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

For a 12-parameter tool with nested objects and no output schema, the description gives only partial return-shape guidance (rows carry n, availability list) and leaves the grouping keys, interval series shape, and formula null semantics to the schema. It is adequate to call the tool correctly but thin on what comes back.

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 83%, so the schema already documents most parameters thoroughly (window, aggregation, breakdown, formula, format). The description mostly restates the headline parameters (metric, default median, window values, dimension list) and adds rationale ('compared fairly') rather than new syntax or edge-case meaning, so the baseline 3 applies.

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 ('Read-only analytics query: one metric aggregated ... over posts, broken down by ...') and pins down the mechanics (metric, dimensions, fixed post age window). It does not explicitly contrast with nearby siblings such as get_analytics, compare_labels, or ads_insights, so an agent still has to infer which analytics tool fits.

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?

Usage is implied through the framing ('so posts are compared fairly', 'Pro plan or higher'), which signals that this is the tool for apples-to-apples comparison across posts at a fixed age. However, there is no explicit when-to-use/when-not guidance and no named alternative when the agent wants raw totals, a single post's stats, or label-vs-label comparison.

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