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.

Input Schema

TableJSON 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.3/5.0
Behavior4/5

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

Annotations already declare readOnlyHint=true and openWorldHint=false, and the description layers on genuinely additive behavior: dry_run compiles and returns SQL plus traversal paths without executing, filters are cheaper than having, and the tool rejects raw SQL outright. It does not disclose result-size ceilings, default limit/row-cap behavior, or auth/permission requirements, so it stops short of full behavioral coverage.

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 core purpose is front-loaded and the length is defensible for a 13-parameter tool with nested objects. Each sentence carries information, though the run-on framing around metric vs aggregate is less scannable than the rest and the block reads as a wall of prose with no structural separation.

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 complex, deeply nested, high-parameter tool with no output schema, the description covers the load-bearing concepts: entity sourcing, field traversal, filter/having split, grain column naming, per-group semantics, dry-run, and the no-SQL rule. It leaves unstated what rows come back by default, any result-size limits, and failure/permission behavior, which are the remaining gaps for a query tool of this size.

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 13 parameters at 100% schema description coverage, the baseline is 3, and the description earns a bump by adding conceptual meaning the schema does not: metrics are 'blessed' business definitions while aggregates are literal compositions, and grains emit <field>_<grain> columns that group_by/order_by must reference. It also clarifies the metric-vs-aggregate choice, which is the hardest semantic decision in this schema.

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?

Opens with a specific verb+resource ('Query an entity') and immediately scopes the mechanics: field selection by name, dot-traversal for relationships, and filters/grouping/ordering sharing the same names. It also distinguishes itself from describe_entity (which supplies field and filter syntax) and rules out SQL, so an agent can place it against its siblings without opening a schema.

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 clear conditional guidance: use describe_entity to learn fields and filter rules, set dry_run to vet an expensive query or show derivation, and prefer filters over having for pre-grouping because it is cheaper. It also frames when to reach for a blessed metric vs a composed aggregate, but never names alternative tools for the underlying retrieval job (e.g. search, sample_values) or states exclusions.

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