Skip to main content
Glama
servicenow-mcp-ai

servicenow-mcp-ai

by IvanBBaev

Aggregate ServiceNow records

servicenow_aggregate
Read-onlyIdempotent

Compute count, average, min, max, and sum over a ServiceNow table using the Stats API, with optional filtering and grouping for summarized reports.

Instructions

Server-side aggregates (count, avg, min, max, sum) over a table via the Stats API, optionally grouped.

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": "servicenow_aggregate"
  }
}

Input Schema

NameRequiredDescriptionDefault
countNoInclude a count (sysparm_count).
queryNoEncoded query filtering the rows.
tableYesTable, e.g. 'incident'.
havingNoHAVING clause (sysparm_having).
group_byNoFields to group by.
instanceNoProfile (default active)
avg_fieldsNoNumeric fields to average.
max_fieldsNoFields to take the max of.
min_fieldsNoFields to take the min of.
sum_fieldsNoNumeric fields to sum.
displayValueNoAdd display values (sysparm_display_value=all).

Output Schema

NameRequiredDescriptionDefault
resultNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed29 schema fields changedv3.0.0
    • removedInput schema / $schema
      Removed value: -"http://json-schema.org/draft-07/schema#"
    • addedInput schema / properties / avg_fields / items / maxLength
      Added value: +255
    • addedInput schema / properties / avg_fields / items / pattern
      Added value: +"^[A-Za-z0-9_.]+(?:\\s*,\\s*[A-Za-z0-9_.]+)*$"
    • addedInput schema / properties / avg_fields / maxItems
      Added value: +200
    • changedInput schema / properties / count / description
      Previous value: -"Include a record count (sysparm_count)."New value: +"Include a count (sysparm_count)."
    • addedInput schema / properties / displayValue
      Added value: +{
      +  "description": "Add display values (sysparm_display_value=all).",
      +  "type": "boolean"
      +}
    • addedInput schema / properties / group_by / items / maxLength
      Added value: +255
    • addedInput schema / properties / group_by / items / pattern
      Added value: +"^[A-Za-z0-9_.]+(?:\\s*,\\s*[A-Za-z0-9_.]+)*$"
    • addedInput schema / properties / group_by / maxItems
      Added value: +200
    • changedInput schema / properties / having / description
      Previous value: -"HAVING clause to filter groups (sysparm_having)."New value: +"HAVING clause (sysparm_having)."
    • addedInput schema / properties / having / maxLength
      Added value: +8000
    • changedInput schema / properties / instance / description
      Previous value: -"Connection profile to use for this call (default: the active profile). See servicenow_list_instances."New value: +"Profile (default active)"
    • addedInput schema / properties / instance / maxLength
      Added value: +128
    • changedInput schema / properties / max_fields / description
      Previous value: -"Fields to take the maximum of."New value: +"Fields to take the max of."
    • addedInput schema / properties / max_fields / items / maxLength
      Added value: +255
    • addedInput schema / properties / max_fields / items / pattern
      Added value: +"^[A-Za-z0-9_.]+(?:\\s*,\\s*[A-Za-z0-9_.]+)*$"
    • addedInput schema / properties / max_fields / maxItems
      Added value: +200
    • changedInput schema / properties / min_fields / description
      Previous value: -"Fields to take the minimum of."New value: +"Fields to take the min of."
    • addedInput schema / properties / min_fields / items / maxLength
      Added value: +255
    • addedInput schema / properties / min_fields / items / pattern
      Added value: +"^[A-Za-z0-9_.]+(?:\\s*,\\s*[A-Za-z0-9_.]+)*$"
    • addedInput schema / properties / min_fields / maxItems
      Added value: +200
    • changedInput schema / properties / query / description
      Previous value: -"Encoded query to filter rows before aggregating."New value: +"Encoded query filtering the rows."
    • addedInput schema / properties / query / maxLength
      Added value: +8000
    • addedInput schema / properties / sum_fields / items / maxLength
      Added value: +255
    • addedInput schema / properties / sum_fields / items / pattern
      Added value: +"^[A-Za-z0-9_.]+(?:\\s*,\\s*[A-Za-z0-9_.]+)*$"
    • addedInput schema / properties / sum_fields / maxItems
      Added value: +200
    • changedInput schema / properties / table / description
      Previous value: -"Table name, e.g. 'incident'."New value: +"Table, e.g. 'incident'."
    • addedInput schema / properties / table / pattern
      Added value: +"^[A-Za-z0-9_]{1,80}$"
    • changedOutput schema / (root)
      Previous value: -nullNew value: +{
      +  "additionalProperties": {},
      +  "properties": {
      +    "result": {}
      +  },
      +  "type": "object"
      +}
  2. First observedv2.0.1

TDQS

A3.5/5.0
Behavior3/5

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

Annotations already declare readOnlyHint, idempotentHint and destructiveHint=false, so the safety profile is covered. The description contributes 'server-side' and 'via the Stats API', which hints at where computation happens and that results are computed rather than raw rows, but says nothing about rate limits, max group cardinality, or behavior when requested fields are non-numeric.

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?

One sentence, front-loaded with the core operation and scoped by the supported functions and grouping option. Nothing redundant, no filler.

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?

With an output schema and 100% schema coverage the description needn't restate fields or return shape, but for an 11-parameter aggregation tool it omits practical guidance: whether an empty group_by yields a single total, whether count is needed alongside sum, and the distinction from query_table. Adequate but with clear gaps.

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 description coverage is 100% with 11 well-described parameters, so the baseline is 3. The description adds no information beyond the schema — e.g. it does not clarify how count/avg_fields/group_by interact or whether displayValue affects aggregate output.

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 description names a specific operation (server-side aggregation) and enumerates the supported aggregate functions (count, avg, min, max, sum) over a ServiceNow table, with optional grouping. This clearly separates it in spirit from servicenow_query_table, though it never names that sibling explicitly.

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

Usage Guidelines3/5

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

Usage is implied rather than stated: an agent can infer this is the tool for statistical rollups instead of row retrieval, and 'optionally grouped' hints at group_by usage. There is no explicit 'use this instead of query_table when you need counts/sums' routing or prerequisite guidance.

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