Skip to main content
Glama

Query insights

query_insights
Read-only

Query runs a product-analytics insight over the project's events and returns the computed result. A single call covers every insight type — trends, segmentation, funnel, retention, user flow (Sankey), top-K and map (a metric per country, returned as top_k rows keyed by ISO alpha-2) — chosen by the InsightQuerySpec (its insight_type, events, breakdowns and filters, among others). Map, user flow, top-K and session each carry their own sub-message (spec.map / spec.user_flow / spec.top_k / spec.session) and take no events or breakdowns; a map's country dimension is implicit, so spec.map may be empty. The request also carries the time range and granularity, and it is the right tool for any project-wide or over-time question; per-granularity range caps apply. Traffic tagged as a bot at ingest is excluded unless spec.include_bots is true, and that includes crawler_request events, one per crawler request a site reported. On those, $bot_reason names the crawler, $crawler_category is answers, search, training, seo or other, $crawler_company is absent for most search engines and SEO tools, and $crawler_verified is verified, failed (an IP outside the operator's published ranges) or unchecked (no ranges or no usable IP to check). Discover valid event kinds and property keys with the get_insights_filter_schema tool first.

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
specNo
timezoneNo
project_idNoThe id of the project, from list_projects.
time_rangeNo
granularityNo

Output Schema

NameRequiredDescriptionDefault
resultNoExactly one of the "result" group. Set "which" to the chosen field name, then set only that field.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.6/5.0
Behavior5/5

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

Annotations already declare readOnly/non-destructive, but the description adds substantial behavior beyond them: bot traffic is excluded by default unless spec.include_bots is true, crawler_request events are one-per-request, and the $bot_reason/$crawler_category/$crawler_company/$crawler_verified fields are explained with their value sets. It also warns that per-granularity range caps apply, which is exactly the kind of constraint an agent needs before calling.

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 the core purpose and insight-type enumeration, and every sentence carries information. The middle is a dense run-on that packs sub-message rules, bot semantics and crawler field values into one paragraph, which would read better as short bullets, but there is little outright waste.

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?

For a complex, deeply nested spec with an output schema (so return values need not be described), the description covers the insight-type dispatch, the special sub-message shapes, bot/crawler handling, range caps, and the prerequisite discovery tool. An agent has enough to construct a valid call without opening the 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?

With only 20% schema description coverage, the description carries real weight: it explains that map, user_flow, top_k and session each have their own sub-message and take no events or breakdowns, that a map's country dimension is implicit so spec.map may be empty, and that the request carries time range and granularity. It leaves several top-level parameters (timezone, breakdown_limit, conversion_window, include_cookieless, include_step_timing) unexplained, so it compensates well but not completely.

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 ('Query runs a product-analytics insight over the project's events and returns the computed result') and then enumerates the concrete insight types it covers (trends, segmentation, funnel, retention, user flow, top-K, map). It also distinguishes itself from the discovery sibling by pointing to get_insights_filter_schema, so an agent can tell what this tool does and does not do.

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

Usage Guidelines4/5

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

Explicitly says it is 'the right tool for any project-wide or over-time question' and gives a prerequisite workflow ('Discover valid event kinds and property keys with the get_insights_filter_schema tool first'). It does not state when NOT to use it (e.g., per-profile questions that belong to get_profile_stats), so it stops short of full routing guidance.

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.