Skip to main content
Glama

Query

query
Read-only

Query an entity. Select fields by name and traverse relationships with dots (e.g. 'account_manager.full_name'); filters, grouping and ordering use the same names. Blessed metrics encode which of several defensible definitions (of revenue, say) the business uses. A metric answers what the business means; an aggregate answers exactly what was asked and nothing more. describe_entity gives this entity's fields and how to write filters against them. Set dry_run to compile and return the SQL without executing it. This tool does not accept SQL.

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

Input Schema

NameRequiredDescriptionDefault
limitNomaximum rows to return
modelNomodel name; omit for the default
entityYesentity to query, from list_entities
fieldsNofield names; traverse relationships with dots, e.g. account_manager.full_name
grainsNotruncate a date field to a period: field plus grain (day, week, month, quarter, year). Each makes its own output column <field>_<grain>, which is the name group_by and order_by must use
havingNosame shape as filters, but names aggregate aliases and metric names rather than fields, and needs at least one aggregate or metric. To filter rows BEFORE grouping use filters, which is cheaper
dry_runNocompile and return the SQL and what it would traverse, WITHOUT running it — to check an expensive query first, or to show how a number was derived
filtersNopredicates, ANDed. A leaf is {field, op, value}; op is one of = != <> > >= < <= like, not like, ilike, not ilike, in, not in, between, not between, is_null, is_not_null. A node may instead carry and/or (lists) or not (one), which is how you group. describe_entity gives the value rules, a worked example in the entity's own columns, and relative dates
metricsNoblessed metric names defined on this entity
group_byNofield names to group by when using metrics or aggregates; each must also be in fields. For a period, name the grain's output column
order_byNosort terms; field plus optional desc
per_groupNotop n rows WITHIN each group rather than overall ('top 3 per owner'): n plus partition, naming selected fields or grain output columns. Requires an explicit order_by, which decides which rows survive
aggregatesNoaggregations you compose when no blessed metric fits: fn is count, count_distinct, sum, avg, min, max or ratio. count takes NO field and counts rows. ratio: sum(field) / sum(over), or a rate field alone (describe_entity's rebuild). optional as names the output column

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed4 schema fields changed
    • changedInput schema / properties / aggregates / description
      Previous value: -"aggregations you compose when no blessed metric fits: fn is count, count_distinct, sum, avg, min or max. count takes NO field and counts rows. optional as names the output column"New value: +"aggregations you compose when no blessed metric fits: fn is count, count_distinct, sum, avg, min, max or ratio. count takes NO field and counts rows. ratio: sum(field) / sum(over), or a rate field alone (describe_entity's rebuild). optional as names the output column"
    • addedInput schema / properties / aggregates / items / properties / complement
      Added value: +{
      +  "type": "boolean"
      +}
    • addedInput schema / properties / aggregates / items / properties / over
      Added value: +{
      +  "type": "string"
      +}
    • addedInput schema / properties / aggregates / items / properties / scale
      Added value: +{
      +  "type": "number"
      +}
  2. Changed13 schema fields changed
    • addedInput schema / additionalProperties
      Added value: +false
    • addedInput schema / properties / aggregates / items / additionalProperties
      Added value: +false
    • removedInput schema / properties / aggregates / items / properties / fn / enum
      Removed value: -[
      -  "count",
      -  "count_distinct",
      -  "sum",
      -  "avg",
      -  "min",
      -  "max"
      -]
    • changedInput schema / properties / dry_run / description
      Previous value: -"compile and return the SQL without running it"New value: +"compile and return the SQL and what it would traverse, WITHOUT running it — to check an expensive query first, or to show how a number was derived"
    • changedInput schema / properties / filters / items
      Previous value: -{
      -  "type": "object"
      -}New value: +true
    • changedInput schema / properties / filters / type
      Previous value: -[
      -  "array",
      -  "null"
      -]New value: +"array"
    • addedInput schema / properties / grains / items / additionalProperties
      Added value: +false
    • addedInput schema / properties / grains / items / properties / grain / description
      Added value: +"day, week, month, quarter or year"
    • removedInput schema / properties / grains / items / properties / grain / enum
      Removed value: -[
      -  "day",
      -  "week",
      -  "month",
      -  "quarter",
      -  "year"
      -]
    • changedInput schema / properties / having / items
      Previous value: -{
      -  "type": "object"
      -}New value: +true
    • changedInput schema / properties / having / type
      Previous value: -[
      -  "array",
      -  "null"
      -]New value: +"array"
    • addedInput schema / properties / order_by / items / additionalProperties
      Added value: +false
    • addedInput schema / properties / per_group / additionalProperties
      Added value: +false
  3. First observed

TDQS

A4/5.0
Behavior4/5

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

Annotations already declare read-only and non-destructive, so the description earns credit for the extra facts: no SQL is accepted, dry_run compiles without executing, and metrics vs aggregates differ in whether a blessed definition is applied. Return shape and result limits are not described, which is the 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?

Front-loaded with the core action and efficient overall, with each rule in its own sentence. The metrics-versus-aggregates passage is conceptually useful but slightly discursive for a tool description.

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 13-parameter query DSL with no output schema, the description covers the decision points an agent needs: where to learn field names, how to compile without running, what metrics mean, and the no-SQL constraint. Details of result shape and pagination are left implicit, but the schema carries the parameter-level detail.

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%, so the baseline is 3; the description goes beyond it by explaining the cross-parameter naming rule (the same dotted names are reused in filters, group_by and order_by) and by framing the metrics/aggregates semantic split. It doesn't touch limit, model, grains or per_group, which the schema already covers.

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?

Opens with a specific verb and resource ('Query an entity') and immediately scopes what can be selected, filtered, grouped and ordered. The 'entity' object is abstract until list_entities/describe_entity are consulted, but the tool's role is unmistakable and distinct from search or sample_values.

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 real decision rules: use describe_entity to learn fields and filter syntax, use metrics when the business definition matters, use aggregates for an exact bespoke calculation, and set dry_run to inspect an expensive query. It does not state when to prefer this over siblings like search or sample_values, which is the main gap.

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