Skip to main content
Glama

Aggregate table data

table_aggregate
Read-onlyIdempotent

Calculate counts, sums, averages, minima, or maxima for a ServiceNow table, optionally grouped by up to three fields, without retrieving full records.

Instructions

Count, average, sum, min or max over a table, optionally grouped by up to 3 fields. Faster and smaller than fetching records. having looks like count^*^>^10. Groups are sorted by orderBy (e.g. count) here, not by ServiceNow. A misspelt field in the query may be ignored by ServiceNow, so check the results.

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": {
      "table": "<table>"
    },
    "name": "table_aggregate"
  }
}

Input Schema

NameRequiredDescriptionDefault
avgNoNumeric fields to average.
maxNoFields to take the maximum of.
minNoFields to take the minimum of.
sumNoNumeric fields to add up.
countNoInclude the record count. Default true.
limitNoMaximum groups to return. Default and cap: the configured maxRecords.
queryNoEncoded query that selects the records.
tableYesTable name, e.g. incident or cmdb_ci_server.
havingNoFilter on groups: aggregate^field^operator^value, e.g. count^*^>^10.
groupByNoUp to 3 fields to group by, e.g. ["priority", "assignment_group"].
orderByNoSort order of the groups.
instanceNoInstance alias from the config (see instance_list). Defaults to the default instance.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

A3.8/5.0
Behavior4/5

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

Annotations already declare readOnly, idempotent, non-destructive and closed-world, so the safety profile is covered. The description adds genuine behavioral context the annotations cannot: server-side sorting differences from ServiceNow, and the silent-failure risk that a misspelt field may be ignored, with the instruction to verify results.

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?

Three tight sentences with the core capability front-loaded and caveats following; nothing is padded. The phrasing 'Groups are sorted by orderBy (e.g. count) here, not by ServiceNow' is telegraphic enough that it takes a second read to parse.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a 12-parameter tool with a nested orderBy object and no output schema, the description never indicates what comes back (per-group aggregate values keyed by groupBy fields, plus count), leaving the agent to infer the response shape. It handles the tricky inputs (having syntax, limit cap, sorting) well, but the return side is unaddressed.

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

Parameters3/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 mostly restates what the schema already documents, including the having example 'count^*^>^10' which appears verbatim in the schema. What it does add beyond the schema is the operational note that group ordering is applied by this tool rather than by ServiceNow, plus the ordering example value 'count' for orderBy.

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?

The opening sentence names the exact operations (count, average, sum, min, max), the resource (a table), and the grouping capability, so the agent knows precisely what the tool produces. It differentiates itself from record-fetching tools indirectly ('Faster and smaller than fetching records') but never names a specific sibling such as table_query or table_find.

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?

'Faster and smaller than fetching records' gives a clear selection rule: prefer this over paging raw records when only aggregates are needed. It stops short of explicit exclusions (e.g. when you need full records use table_query), and the guidance is implicit rather than a stated when/when-not rule.

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