Skip to main content
Glama
Dataverse Mcp Server

Dataverse Mcp Server

aggregate_records

Computes counts, sums, averages, minimums, and maximums over Dataverse records, optionally filtered and grouped by columns or date parts, without reading the records themselves.

Instructions

Count, sum, average, or take the minimum or maximum of records of one table (entity set), optionally grouped by columns and by parts of a date, computed by Dataverse; only reads. Use it instead of reading records with query_records to count or add them up. Returns { rows: [...] }: one row per group, holding every group's and aggregate's as, ordered by order. A value that is missing is null: a group of rows where the column is empty, or an aggregate over no non-null values (count gives 0). A group by a lookup, a choice or a yes/no column also has _label, the record's name or the choice's label (null for the empty group). A date grouping gives a part of the date as a number, not a period: month is 1 to 12, week the week of the year, quarter the quarter of the fiscal year, day the day of the month; so month, quarter and week are refused unless the same column is also grouped by year, and day unless by year and month. Weeks are counted from 1 January, so the week around the new year is split into two groups, the last week of one year and week 1 of the next; for whole weeks, filter by dates. year is the calendar year: with a fiscal year that does not start on a calendar quarter, one year and quarter group can hold the ends of two fiscal quarters, so group by year and month instead. The parts are in the time zone of the user the call runs as, the one that user sees in Dynamics. Only rows that user may read are counted. Dataverse computes totals over at most 50,000 rows: a query that matches more is an error, to be narrowed by the filter, for example to a date range. One page of groups comes back, 5000 (500 on an elastic table): a query with more groups is an error, to be narrowed by the filter or by coarser groups. A Money column is summed as stored, in each record's currency: over records in several currencies, aggregate its _base instead, in the base currency, or group by transactioncurrencyid. countcolumn does not work on a Money column; use count with a not-null filter on it. An unknown entity set or column is an error.

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_set": "<entity_set>",
      "aggregates": "<aggregates>"
    },
    "name": "aggregate_records"
  }
}

Input Schema

NameRequiredDescriptionDefault
orderNoThe order of the result rows
filterNoConditions on the rows counted, combined with 'and'
group_byNoColumns to group by; without it the result is one row
aggregatesYesWhat to compute for each group
entity_setYesEntity set name (plural, e.g. 'accounts', 'contacts')

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv0.11.0

TDQS

A4.8/5.0
Behavior5/5

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

With no annotations, the description carries the full burden and does so thoroughly: read-only ('only reads'), the 50,000-row compute ceiling, the 5000 (500 elastic) group page limit, security trimming ('only rows that user may read are counted'), time-zone semantics, and error conditions for unknown entity set or column. Null and empty-group semantics are also disclosed, which an agent could not infer elsewhere.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Purpose and the query_records routing are front-loaded, but the body is a dense wall of text that re-explains date-part rules already present in the group_by.date schema field and repeats the week-splitting caveat at length. Every sentence is informative, but the date-grouping material could be tightened and split into shorter units for scanability.

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?

For a five-parameter aggregation tool with no output schema and no annotations, the description covers result shape ({ rows: [...] }), ordering by 'order', null semantics, label columns, and every limit or refusal condition. Nothing an agent needs to construct a correct call or interpret the response is missing.

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 coverage is 100%, so the baseline is 3, but the description adds cross-parameter meaning the schema states only piecemeal: month/quarter/week refused unless the same column is also grouped by year, day requires year and month, countcolumn is invalid on Money, and <as>_label appears for lookup/choice/yes-no groupings. These interdependencies materially change how an agent builds a valid call.

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 the specific verb set (count, sum, average, min, max) and the resource (records of one table/entity set), and states the optional grouping and that it is computed by Dataverse. It is clearly distinguishable from query_records and get_record, which read rows rather than aggregate them.

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?

Explicitly names the alternative: 'Use it instead of reading records with query_records to count or add them up.' It also gives when-not conditions by specifying what to do when limits are hit (narrow the filter, coarser groups) and which column alternative to use for Money (aggregate <column>_base or group by transactioncurrencyid).

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