Skip to main content
Glama

query

Get data from a semantic model by describing the dimensions, measures, filters, and time buckets you need; the query compiles into SQL and returns the result rows.

Instructions

Query data from a semantic model. Call inspect(reference=".", entity_type="model") first to see available columns and measures, and search (with the entities you plan to use and/or a free-text question) to surface saved learnings and example queries before finalizing a query.

The query argument takes one of three forms:

  • Model name (string) — run a query-backed saved model by name, e.g. "monthly_revenue" (honors variables; every other setting comes from the stored query).

  • Query object (dict) — a single query; per-field documentation is on the SlayerQuery schema.

  • Multi-stage list (list of query objects) — a DAG of stages. Every entry except the last MUST carry a name; the last entry is the root whose rows are returned. Stages reference one another by that name — as a source_model or via a join in an inline ModelExtension — and the engine orders them topologically. An inner stage's result columns become plain columns of the outer stage (dotted paths flatten: stores.name -> stores__name); a stage may reference only what its own source defines or what a prior stage projected — define before you reference. Use stages when a whole result set must be re-queried, joined, or reused; single-query nesting and computed dimensions already cover re-aggregation.

Expressions — one language, used in measures, computed dimensions, filters, and order. The same expression returns its value as a measure, groups by it as a computed dimension, masks as a filter (routed automatically to WHERE / HAVING / post-aggregation), and sorts in order.

  • Aggregations are function calls over a column or a same-model scalar expression: count(*), sum(total), sum(amount - cost), percentile(price, p=0.95). Available: sum, avg (both take window='90d' for trailing time windows), min, max, count, count_distinct, count_distinct_approx, median, percentile(x, p=), weighted_avg(x, weight=col), stddev_samp, stddev_pop, var_samp, var_pop, corr(x, other=col), covar_samp(x, other=col), covar_pop(x, other=col), first(x[, time_col]) / last(x[, time_col]) (earliest/latest record's value per group), plus model-defined custom aggregations. Write count_distinct(x), never count(distinct x).

  • All aggregations support partition_by= (bare names: partition_by=region, partition_by=[region, city], partition_by=[] for the grand total), computing the aggregate at that coarser grain; the result is broadcast over the missing dimensions.

  • Combine aggregations with arithmetic and transforms — missing dimensions broadcast on both sides. E.g. with dimensions ["city", "region"], the measure {"formula": "sum(total) / sum(total, partition_by=region)", "name": "share_of_region"} is each city's share of its region's total.

  • Aggregations nest: "avg(sum(total, partition_by=[region, city]), partition_by=[region])" averages the per-city totals within each region. The top-level partition_by must be a subset of the query's dimensions; inner aggregations' partition_by need not be. An outer aggregation's parameters must be determined by the operand's grain — a cell value at that grain, e.g. weight=count(id, partition_by=[region, city]), or a column that grain fixes; any other row column is a typed error.

  • Transforms wrap aggregated expressions: cumsum(x); change(x) / change_pct(x) (period-over-period delta / % change — calendar-aware and partition-safe, prefer these for growth); time_shift(x, -1[, 'year']) (the shifted value itself, for custom arithmetic); lag(x, n) / lead(x, n) (row-position shift, NULL at edges); first(x) / last(x) (broadcast the earliest/latest bucket's value); consecutive_periods(predicate) (trailing run length; the predicate may be row-level, e.g. status = 'paid'); rank(x), dense_rank(x), percent_rank(x), ntile(x, n=N) (rank family — optional partition_by=, no time dimension needed). All other transforms require a time_dimensions entry. Transforms nest in either order (change(cumsum(x))). Not supported: a row-level column mixed into a composite or nested input of time_shift / change / change_pct, or mixed with another aggregation's value inside one aggregation source.

  • Cross-model: reference any joined model's field as model_name.field_name (or a longer dotted path) and the engine figures out the join paths, avoiding fan-outs and chasm traps — each aggregation computes over its own model's rows exactly once; ambiguous routes error naming the candidates, and result keys use the full routed path. An aggregation sliced by a dimension not attributable to it broadcasts its value with a warning — see to_many_handling to attribute or error instead.

Method — decompose the question into blocks first: every qualifier, projected column, filter, grouping, unit, rounding, and ordering hint is one block, and each must map to a named column/measure/filter/dimension. Never drop a qualifier because no entity matched — search for it, else encode it as an expression or an inline ModelExtension column; reference already-encoded quantities by name rather than re-deriving their logic. Pin explicitly rather than guessing: which aggregation ("typical" is not automatically avg vs median), the grouping column and raw-vs-standardized labels, each aggregate's scope (all rows vs a filtered subset), sort column + direction + tie-break, NULL handling, units and rounding, exact numeric constants. "How many / count of" -> a scalar count(*); "which / list / show" -> the rows. Project exactly the columns the question names — no extras, none missing.

Filter literals — build every ==/in/like predicate on a text column from that column's sampled values (inspect it), never a guessed spelling; samples are a top-N snapshot, so when a needed literal is absent verify it (e.g. a distinct-values query) rather than assume either way. Compare case/whitespace-insensitively in the FILTER position only, never on a projected, grouped, or join-key column; abbreviations that case-folding can't unify go in the IN-set. Apply only the transformations (TRIM/ROUND/CAST/dedup) the question or a governing definition requires.

Verify — run the exact final query and read the result (show_sql=true when unsure): row count plausible; no dimension-only GROUP BY when you wanted per-record rows (distinct_dimension_values: false); sort column + direction as asked; each aggregate's scope right; NULL behavior intended; string values carry the expected casing. On a wrong result, change ONE variable at a time — two changes per attempt make the outcome uninterpretable.

Query-object fields taking the functional time-granularity form gran(col) — gran one of second, minute, hour, day, week, week_sunday, month, quarter, year: dimensions: group-by columns; a granularity call such as month(created_at) buckets that timestamp, equivalent to a time_dimensions entry (and orderable as month(created_at)). time_dimensions: time-bucketed group-bys — {"dimension": ..., "granularity": ...} dicts, or the string form month(created_at). main_time_dimension: which time dimension time-ordered transforms key off.

Top-level arguments (siblings of query, NOT fields inside it): variables: Values for {placeholder} substitutions in filters / model SQL. Also settable per query object; precedence: runtime (top-level) > named-stage > outer-query > model.query_variables. show_sql: When true, include the generated SQL in the response for debugging. dry_run: When true, generate and return the SQL without executing it. explain: When true, run EXPLAIN ANALYZE and return the query plan. format: Output format — "markdown" (default, compact) | "json" | "csv". Case-insensitive.

Without an explicit limit the response is capped at 20 rows with a truncation notice.

Example: query(query={"source_model": "orders", "dimensions": ["status"], "measures": [{"formula": "count(*)"}], "filters": ["status == 'completed'"]})

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes
formatNomarkdown
dry_runNo
explainNo
show_sqlNo
variablesNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed27 schema fields changedv0.10.2
    • changedInput schema / $defs / Column / properties / db_type / description
      Previous value: -"Raw database type string (e.g. 'point', 'jsonb'), retained when the declared DataType loses information. Populated by ingestion for UNKNOWN (opaque) columns; None for mapped types, where the declared DataType already carries everything we need."New value: +"Raw database type string (e.g. 'point', 'DECIMAL(18, 2)'), retained when the declared DataType loses information. Populated by ingestion for UNKNOWN (opaque) and exact NUMERIC/DECIMAL columns; None when the mapped type carries everything needed."
    • addedInput schema / $defs / ColumnRef
      Added value: +{
      +  "description": "A column reference: bare name or dotted join path (``customers.regions.name``); a short form (``regions.name``) auto-routes when exactly one route exists.",
      +  "properties": {
      +    "label": {
      +      "anyOf": [
      +        {
      +          "type": "string"
      +        },
      +        {
      +          "type": "null"
      +        }
      +      ],
      +      "default": null,
      +      "title": "Label"
      +    },
      +    "model": {
      +      "anyOf": [
      +        {
      +          "type": "string"
      +        },
      +        {
      +          "type": "null"
      +        }
      +      ],
      +      "default": null,
      +      "title": "Model"
      +    },
      +    "name": {
      +      "title": "Name",
      +      "type": "string"
      +    }
      +  },
      +  "required": [
      +    "name"
      +  ],
      +  "title": "ColumnRef",
      +  "type": "object"
      +}
    • addedInput schema / $defs / ComputedDimension
      Added value: +{
      +  "additionalProperties": false,
      +  "description": "A dimension computed by an ``expression``; an aggregation inside must carry ``partition_by=`` to fix its grain. Best given an explicit ``name``.",
      +  "properties": {
      +    "expression": {
      +      "title": "Expression",
      +      "type": "string"
      +    },
      +    "name": {
      +      "anyOf": [
      +        {
      +          "type": "string"
      +        },
      +        {
      +          "type": "null"
      +        }
      +      ],
      +      "default": null,
      +      "title": "Name"
      +    }
      +  },
      +  "required": [
      +    "expression"
      +  ],
      +  "title": "ComputedDimension",
      +  "type": "object"
      +}
    • removedInput schema / $defs / DataType / description
      Removed value: -"SLayer data types — values match sqlglot's ``exp.DataType.Type``\nbyte-for-byte so SQL generation can ``CAST`` to the declared type without\na translation map. (DEV-1361.)\n\n``UNKNOWN`` is the explicit *opaque* type: the column's database type was\ndetected but SLayer cannot operate on it — it has no default btree/hash\noperator class, which is exactly what ``GROUP BY`` / ``DISTINCT`` require\n(``json``, ``xml``, the geometric / PostGIS types, range types, ...).\nComparable types keep working as ``TEXT`` even when unmapped — ``jsonb``,\n``uuid``, ``bytea``, arrays and ``tsvector`` are all groupable and are\ndeliberately *not* opaque. ``slayer.engine.ingestion._OPAQUE_SA_TYPE_NAMES``\nis the source of truth for that classification. Such a column is\n**stored and displayed** — its raw DB type string is kept on\n``Column.db_type`` — but it is never used in ``GROUP BY``, ``DISTINCT``,\naggregation, or ``CAST``, because those operations fail at the database\n(e.g. \"could not identify an equality operator for type point\"). Use the\n:attr:`is_opaque` property rather than comparing against the member\ndirectly. ``UNKNOWN`` is also a real ``sqlglot`` type name, so the\nbyte-equality invariant above still holds."
    • addedInput schema / $defs / ModelExtension / additionalProperties
      Added value: +false
    • changedInput schema / $defs / ModelExtension / properties / columns / anyOf
      Previous value: -[
      -  {
      -    "items": {},
      -    "type": "array"
      -  },
      -  {
      -    "type": "null"
      -  }
      -]New value: +[
      +  {
      +    "items": {
      +      "$ref": "#/$defs/Column"
      +    },
      +    "type": "array"
      +  },
      +  {
      +    "type": "null"
      +  }
      +]
    • changedInput schema / $defs / ModelExtension / properties / joins / anyOf
      Previous value: -[
      -  {
      -    "items": {},
      -    "type": "array"
      -  },
      -  {
      -    "type": "null"
      -  }
      -]New value: +[
      +  {
      +    "items": {
      +      "$ref": "#/$defs/ModelJoin"
      +    },
      +    "type": "array"
      +  },
      +  {
      +    "type": "null"
      +  }
      +]
    • addedInput schema / $defs / ModelJoin / properties / name
      Added value: +{
      +  "anyOf": [
      +    {
      +      "type": "string"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null,
      +  "title": "Name"
      +}
    • changedInput schema / $defs / ModelMeasure / description
      Previous value: -"A named formula evaluating to an aggregated value (grammar: ``slayer/core/formula.py``)."New value: +"A named aggregated value: ``formula`` is an aggregation expression — inline in a query's measures or saved on a model and referenced by bare name. ``name`` sets the result key, referenceable in filters and order by either the name or the formula text."
    • addedInput schema / $defs / OrderItem
      Added value: +{
      +  "additionalProperties": false,
      +  "description": "A sort key: ``column`` is a result column name or an expression string; ``direction`` asc|desc.",
      +  "properties": {
      +    "column": {
      +      "$ref": "#/$defs/ColumnRef"
      +    },
      +    "direction": {
      +      "default": "asc",
      +      "title": "Direction",
      +      "type": "string"
      +    },
      +    "raw_formula": {
      +      "anyOf": [
      +        {
      +          "type": "string"
      +        },
      +        {
      +          "type": "null"
      +        }
      +      ],
      +      "default": null,
      +      "description": "Internal — captured automatically from expression strings; do not set.",
      +      "title": "Raw Formula"
      +    }
      +  },
      +  "required": [
      +    "column"
      +  ],
      +  "title": "OrderItem",
      +  "type": "object"
      +}
    • changedInput schema / $defs / SlayerModel / properties / version / default
      Previous value: -9New value: +10
    • addedInput schema / $defs / SlayerQuery
      Added value: +{
      +  "additionalProperties": false,
      +  "description": "User-facing query object — what to retrieve from a model, as names/references, no SQL.",
      +  "properties": {
      +    "dimensions": {
      +      "anyOf": [
      +        {
      +          "items": {
      +            "anyOf": [
      +              {
      +                "$ref": "#/$defs/ColumnRef"
      +              },
      +              {
      +                "$ref": "#/$defs/ComputedDimension"
      +              }
      +            ]
      +          },
      +          "type": "array"
      +        },
      +        {
      +          "type": "null"
      +        }
      +      ],
      +      "default": null,
      +      "description": "Group-by columns — names / dotted paths, or computed expressions ({\"expression\": ..., \"name\": ...}); one result row per distinct value combination.",
      +      "title": "Dimensions"
      +    },
      +    "distinct_dimension_values": {
      +      "default": true,
      +      "description": "Default true: dimension-only queries return distinct dimension combinations (GROUP BY the projected dimensions). Set false for raw per-record rows — requires empty `measures` and no measure reference in `filters`/`order`. For rows plus a count, keep the default and add `count(*)`.",
      +      "title": "Distinct Dimension Values",
      +      "type": "boolean"
      +    },
      +    "filters": {
      +      "anyOf": [
      +        {
      +          "items": {
      +            "type": "string"
      +          },
      +          "type": "array"
      +        },
      +        {
      +          "type": "null"
      +        }
      +      ],
      +      "default": null,
      +      "description": "Condition strings, AND-ed; each routes automatically to WHERE / HAVING / post-aggregation. May contain aggregations, transforms, and {variable} placeholders.",
      +      "title": "Filters"
      +    },
      +    "limit": {
      +      "anyOf": [
      +        {
      +          "type": "integer"
      +        },
      +        {
      +          "type": "null"
      +        }
      +      ],
      +      "default": null,
      +      "description": "Max rows to return. Use only for top-N / 'the single most X' requests — never to trim a plain list (an uncapped MCP response is truncated at 20 rows with an explicit notice).",
      +      "title": "Limit"
      +    },
      +    "main_time_dimension": {
      +      "anyOf": [
      +        {
      +          "type": "string"
      +        },
      +        {
      +          "type": "null"
      +        }
      +      ],
      +      "default": null,
      +      "description": "Name of the time dimension that time-ordered transforms (change, lag, ...) key off; overrides auto-detection when the query has multiple time dimensions.",
      +      "title": "Main Time Dimension"
      +    },
      +    "measures": {
      +      "anyOf": [
      +        {
      +          "items": {
      +            "$ref": "#/$defs/ModelMeasure"
      +          },
      +          "type": "array"
      +        },
      +        {
      +          "type": "null"
      +        }
      +      ],
      +      "default": null,
      +      "description": "Values to return: aggregation-expression formulas (see the query tool description). A bare name references a saved model measure.",
      +      "title": "Measures"
      +    },
      +    "name": {
      +      "anyOf": [
      +        {
      +          "type": "string"
      +        },
      +        {
      +          "type": "null"
      +        }
      +      ],
      +      "default": null,
      +      "description": "Stage name in a multi-stage list; other stages reference it as their source_model.",
      +      "title": "Name"
      +    },
      +    "offset": {
      +      "anyOf": [
      +        {
      +          "type": "integer"
      +        },
      +        {
      +          "type": "null"
      +        }
      +      ],
      +      "default": null,
      +      "description": "Rows to skip.",
      +      "title": "Offset"
      +    },
      +    "order": {
      +      "anyOf": [
      +        {
      +          "items": {
      +            "$ref": "#/$defs/OrderItem"
      +          },
      +          "type": "array"
      +        },
      +        {
      +          "type": "null"
      +        }
      +      ],
      +      "default": null,
      +      "description": "Sort keys; column is a result column name or an aggregation-bearing expression string.",
      +      "title": "Order"
      +    },
      +    "source_model": {
      +      "anyOf": [
      +        {
      +          "oneOf": [
      +            {
      +              "type": "string"
      +            },
      +            {
      +              "$ref": "#/$defs/ModelExtension"
      +            },
      +            {
      +              "$ref": "#/$defs/SlayerModel"
      +            }
      +          ]
      +        },
      +        {
      +          "type": "null"
      +        }
      +      ],
      +      "default": null,
      +      "description": "The query's population: a saved model name, an inline ModelExtension ({\"source_name\": ..., plus optional \"columns\"/\"measures\"/\"joins\"}), or a full inline model. Omit to infer the smallest model determining every queried dimension, time dimension, and row-level filter column (the choice is reported in response metadata).",
      +      "title": "Source Model"
      +    },
      +    "time_dimensions": {
      +      "anyOf": [
      +        {
      +          "items": {
      +            "anyOf": [
      +              {
      +                "$ref": "#/$defs/TimeDimension"
      +              },
      +              {
      +                "type": "string"
      +              }
      +            ]
      +          },
      +          "type": "array"
      +        },
      +        {
      +          "type": "null"
      +        }
      +      ],
      +      "default": null,
      +      "description": "Time-bucketed group-bys — one result row per bucket. Each entry is a TimeDimension dict or the functional string gran(col), e.g. \"month(created_at)\".",
      +      "title": "Time Dimensions"
      +    },
      +    "to_many_handling": {
      +      "default": "broadcast",
      +      "description": "What happens when an aggregation is sliced by a dimension not attributable to it: broadcast (default — repeat the value across the cells, with a warning) | associate (aggregate per cell over the distinct associated entities) | error (refuse).",
      +      "enum": [
      +        "broadcast",
      +        "associate",
      +        "error"
      +      ],
      +      "title": "To Many Handling",
      +      "type": "string"
      +    },
      +    "variables": {
      +      "anyOf": [
      +        {
      +          "additionalProperties": true,
      +          "type": "object"
      +        },
      +        {
      +          "type": "null"
      +        }
      +      ],
      +      "default": null,
      +      "description": "{placeholder} values scoped to this query object / stage; the tool-level variables argument overrides.",
      +      "title": "Variables"
      +    },
      +    "version": {
      +      "default": 4,
      +      "title": "Version",
      +      "type": "integer"
      +    },
      +    "whole_periods_only": {
      +      "default": false,
      +      "description": "Snap date filters to whole time buckets and drop the current incomplete bucket.",
      +      "title": "Whole Periods Only",
      +      "type": "boolean"
      +    }
      +  },
      +  "title": "SlayerQuery",
      +  "type": "object"
      +}
    • addedInput schema / $defs / TimeDimension
      Added value: +{
      +  "description": "Group-by on ``dimension`` truncated to ``granularity``; optional ``date_range`` [start, end] (ISO dates).",
      +  "properties": {
      +    "date_range": {
      +      "anyOf": [
      +        {
      +          "items": {
      +            "type": "string"
      +          },
      +          "type": "array"
      +        },
      +        {
      +          "type": "null"
      +        }
      +      ],
      +      "default": null,
      +      "title": "Date Range"
      +    },
      +    "dimension": {
      +      "$ref": "#/$defs/ColumnRef"
      +    },
      +    "granularity": {
      +      "$ref": "#/$defs/TimeGranularity"
      +    },
      +    "label": {
      +      "anyOf": [
      +        {
      +          "type": "string"
      +        },
      +        {
      +          "type": "null"
      +        }
      +      ],
      +      "default": null,
      +      "title": "Label"
      +    }
      +  },
      +  "required": [
      +    "dimension",
      +    "granularity"
      +  ],
      +  "title": "TimeDimension",
      +  "type": "object"
      +}
    • addedInput schema / $defs / TimeGranularity
      Added value: +{
      +  "enum": [
      +    "second",
      +    "minute",
      +    "hour",
      +    "day",
      +    "week",
      +    "week_sunday",
      +    "month",
      +    "quarter",
      +    "year"
      +  ],
      +  "title": "TimeGranularity",
      +  "type": "string"
      +}
    • removedInput schema / properties / dimensions
      Removed value: -{
      -  "anyOf": [
      -    {
      -      "items": {
      -        "type": "string"
      -      },
      -      "type": "array"
      -    },
      -    {
      -      "type": "null"
      -    }
      -  ],
      -  "default": null,
      -  "title": "Dimensions"
      -}
    • removedInput schema / properties / distinct_dimension_values
      Removed value: -{
      -  "default": true,
      -  "title": "Distinct Dimension Values",
      -  "type": "boolean"
      -}
    • removedInput schema / properties / filters
      Removed value: -{
      -  "anyOf": [
      -    {
      -      "items": {
      -        "type": "string"
      -      },
      -      "type": "array"
      -    },
      -    {
      -      "type": "null"
      -    }
      -  ],
      -  "default": null,
      -  "title": "Filters"
      -}
    • removedInput schema / properties / limit
      Removed value: -{
      -  "anyOf": [
      -    {
      -      "type": "integer"
      -    },
      -    {
      -      "type": "null"
      -    }
      -  ],
      -  "default": null,
      -  "title": "Limit"
      -}
    • removedInput schema / properties / measures
      Removed value: -{
      -  "anyOf": [
      -    {
      -      "items": {
      -        "additionalProperties": {
      -          "type": "string"
      -        },
      -        "type": "object"
      -      },
      -      "type": "array"
      -    },
      -    {
      -      "type": "null"
      -    }
      -  ],
      -  "default": null,
      -  "title": "Measures"
      -}
    • removedInput schema / properties / offset
      Removed value: -{
      -  "anyOf": [
      -    {
      -      "type": "integer"
      -    },
      -    {
      -      "type": "null"
      -    }
      -  ],
      -  "default": null,
      -  "title": "Offset"
      -}
    • removedInput schema / properties / order
      Removed value: -{
      -  "anyOf": [
      -    {
      -      "items": {
      -        "additionalProperties": {
      -          "type": "string"
      -        },
      -        "type": "object"
      -      },
      -      "type": "array"
      -    },
      -    {
      -      "type": "null"
      -    }
      -  ],
      -  "default": null,
      -  "title": "Order"
      -}
    • addedInput schema / properties / query
      Added value: +{
      +  "anyOf": [
      +    {
      +      "type": "string"
      +    },
      +    {
      +      "$ref": "#/$defs/SlayerQuery"
      +    },
      +    {
      +      "items": {
      +        "$ref": "#/$defs/SlayerQuery"
      +      },
      +      "type": "array"
      +    }
      +  ],
      +  "title": "Query"
      +}
    • removedInput schema / properties / source_model
      Removed value: -{
      -  "anyOf": [
      -    {
      -      "type": "string"
      -    },
      -    {
      -      "$ref": "#/$defs/ModelExtension"
      -    },
      -    {
      -      "$ref": "#/$defs/SlayerModel"
      -    }
      -  ],
      -  "title": "Source Model"
      -}
    • removedInput schema / properties / strict
      Removed value: -{
      -  "default": false,
      -  "title": "Strict",
      -  "type": "boolean"
      -}
    • removedInput schema / properties / time_dimensions
      Removed value: -{
      -  "anyOf": [
      -    {
      -      "items": {
      -        "additionalProperties": true,
      -        "type": "object"
      -      },
      -      "type": "array"
      -    },
      -    {
      -      "type": "null"
      -    }
      -  ],
      -  "default": null,
      -  "title": "Time Dimensions"
      -}
    • removedInput schema / properties / whole_periods_only
      Removed value: -{
      -  "default": false,
      -  "title": "Whole Periods Only",
      -  "type": "boolean"
      -}
    • changedInput schema / required
      Previous value: -[
      -  "source_model"
      -]New value: +[
      +  "query"
      +]
  2. First observedv0.10.0

TDQS

A5/5.0
Behavior5/5

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

With no annotations provided, the description carries the full behavioral burden and does so exhaustively: default 20-row truncation, automatic WHERE/HAVING/post-aggregation filter routing, broadcast warnings for non-attributable dimensions, topological stage ordering, dotted-path flattening, and precedence rules for variables. It also discloses debug behaviors (show_sql, dry_run, explain) and verification expectations.

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?

The description is long, but every section earns its place for a tool of this complexity: purpose and prerequisites are front-loaded, and bold headers with bullet lists make the expression rules, argument forms, filters, and verification steps scannable. The included example concretizes the abstract spec without redundancy.

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?

Given the tool's complexity, an output schema, and zero annotation coverage, the description is essentially complete: it covers preconditions, input forms, expression syntax, filter construction, stage semantics, debug options, output format, row caps, and a verification protocol. Nothing an agent must know to invoke this tool safely and correctly is left undocumented.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0% for top-level parameters, and the description fully compensates by documenting all five top-level siblings (variables, show_sql, dry_run, explain, format) with precedence and behavior, plus the three forms of the query argument in depth. It adds meaning far beyond the schema, including the expression language, gran() forms, and per-field clarification of query-object semantics.

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?

"Query data from a semantic model" states a specific verb and resource, and the opening lines position this tool as the execution step after inspect and search, naming sibling tools explicitly. The three query argument forms and the worked example further pin down exactly what this tool does versus siblings like inspect_model or search.

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

Usage Guidelines5/5

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

The description explicitly says to call inspect(...) first and search(...) before finalizing a query, giving an unambiguous workflow. It also states when to use multi-stage lists versus single-query nesting, and warns against using limit to trim plain lists — clear when-to-use and when-not-to-use guidance.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.