Skip to main content
Glama

Count CRM Records

count_crm_records
Read-only

Count the CRM records matching a filter, and return a small sample. For a population question a PERSON asked -- 'how many contacts have no mobile phone'. Reads a local mirror, calls no CRM API, spends nothing, changes nothing. matched is the whole count; the sample is capped and says so. NOT how you write a scope: a run's filter is resolved when the run is dispatched, so composing needs no counts and no record ids. If you are composing a plan, you do not need this. A FILTER WIDENS AS WELL AS NARROWS, and the widening case is the one that gets asked one term at a time. 'Our procurement contacts' is not several questions -- it is ONE group with combinator OR over the words that name the concept: title contains_word Procurement, OR Purchasing, OR Sourcing, OR Buyer, OR department is Purchasing. Ask it as one call. Asking each term separately costs a call per guess, answers each in isolation so nothing tells you the union, and double-counts anyone whose title carries two of the words. Groups nest, so an OR over synonyms sits inside an AND with the rest of the question -- those people, and no activity since a date.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
rootNoThe root of the filter tree. A group combines nodes with AND or OR; a node is either another group or a condition naming a field, an operator, and a value, and groups NEST -- an OR over the several words that name one concept, inside an AND with the rest of the question, is one filter and one call. EVERY NODE CARRIES ITS OWN `kind`: "group" on a group, "condition" on a condition. It is what selects the node type, so a nested group that omits it is refused before anything else is read. Call list_filterable_fields first: the fields and the operators each accepts are specific to this connection's CRM. OMIT IT ENTIRELY to count every record of the object on this connection -- that is the same scope a run with no filter operates on, and it needs no conditions to express.
object_typeYesWhich CRM object to count. One of: account, contact, lead, opportunity, case.
connection_idYesThe CRM connection to read. Required. Call list_crm_connections to get one.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.7/5.0
Behavior5/5

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

Annotations already declare readOnlyHint/destructiveHint/openWorldHint, so the bar is lower, yet the description still adds real behavioral context: reads a local mirror, calls no CRM API, "spends nothing, changes nothing," and clarifies the return shape ("`matched` is the whole count; the sample is capped and says so"). It also warns that the read-side freedom to omit `root` must not reach the write scope, which is meaningful operational context.

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 no-run routing note are front-loaded, which is correct. But the body runs long and partly re-teaches filter-tree construction that the schema's FilterGroup/FilterCondition descriptions already cover, and the all-caps emphasis adds bulk without new information.

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?

There is no output schema, and the description compensates by naming the returned pair (`matched` plus a capped sample) and its cap behavior. Combined with the prerequisite note (call list_filterable_fields first, list_crm_connections for the connection id), an agent has everything needed to call this correctly.

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?

Schema coverage is 100%, so the schema carries the field-level burden, but the description adds compositional meaning not in the schema: filters widen as well as narrow, OR-of-synonyms nests inside an AND, and every node carries its own `kind`. Some overlap exists (the schema's `root` description also states that omitting it counts every record), so it is strong rather than exceptional.

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?

Opening sentence states a specific verb and resource ("Count the CRM records matching a filter, and return a small sample") and immediately frames the scope as a local-mirror read rather than a CRM call. It distinguishes itself from the run-composition siblings explicitly ("If you are composing a plan, you do not need this"). An agent can tell this apart from list_runs/preview_records_run without opening any schema.

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?

Gives an explicit when ("a population question a PERSON asked -- 'how many contacts have no mobile phone'") and an explicit when-not (composing a scope for a run needs no counts and no record ids). It even prescribes the calling pattern: ask a synonym set as one OR-group call, not one call per term, with the reasoning (double-counting, lost union) spelled out.

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.