Skip to main content
Glama

Pug

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. 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 only cover the safety profile (readOnly, non-destructive, non-idempotent, closed-world), and the description goes well beyond them: per-granularity range caps, ingest-time bot exclusion unless spec.include_bots is true, the ISO alpha-2 keying and top_k row shape for map results, and the constraint that map/user_flow/top_k/session take no events or breakdowns. These are exactly the behavioral facts an agent needs and cannot get from structured fields.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Front-loaded with what the tool does and its result, then progressively narrows to sub-message rules, scope/time framing, and the bot caveat, ending on the prerequisite. Dense but every sentence carries a distinct constraint; nothing is restated from the annotations or schema.

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?

With an output schema present, return-value documentation is rightly omitted, and the description still covers the hard parts: type selection, sub-message exclusivity, bot handling and range caps. Gaps remain around timezone/granularity interaction and the optional spec knobs (breakdown_limit, conversion_window), which matter for a tool this configurable.

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 only 20%, so the description must carry meaning, and it does: it maps insight_type, events, breakdowns and filters to the InsightQuerySpec, explains the four sub-messages and their exclusivity, and clarifies that a map's country dimension is implicit so spec.map may be empty. It leaves timezone, granularity levels, breakdown_limit and conversion_window unaddressed, which keeps it from a 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 ('Query runs a product-analytics insight over the project's events and returns the computed result') and then enumerates exactly which insight types are covered (trends, segmentation, funnel, retention, user flow, top-K, map). An agent can tell this is the general-purpose analytics query tool, distinct from the schema/property-value helpers in the sibling list.

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?

Gives a clear positive routing rule ('the right tool for any project-wide or over-time question') and an explicit prerequisite ordering ('Discover valid event kinds and property keys with the get_insights_filter_schema tool first'). It stops short of naming a when-not case or contrasting with explore_events, so the boundary with the event-exploration sibling is left to inference.

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.