count_cis
Count configuration items in ServiceNow CMDB based on a query, optionally grouping by a field for per-value counts.
Instructions
Count configuration items matching a query using the Aggregate API.
Uses the ServiceNow Stats API (/api/now/stats) for efficient counting without fetching actual records. Optionally group results by a field to get counts per value.
Examples: count_cis(table="cmdb_ci_server", group_by="operational_status") count_cis(table="cmdb_ci", group_by="sys_class_name") count_cis(table="cmdb_ci_linux_server", encoded_query="os=Linux Red Hat")
Args: table: CMDB table to count records in (e.g. cmdb_ci_server). Defaults to cmdb_ci. encoded_query: Optional encoded query to filter which CIs to count. Example: "operational_status=1" to count only operational CIs. group_by: Optional field name to group counts by (e.g. "sys_class_name" to get counts per CI type, or "operational_status" for counts per status).
Returns: JSON object with the aggregate count result. When group_by is used, returns counts broken down by each distinct value of that field.
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "count_cis"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| table | No | cmdb_ci | |
| encoded_query | No | ||
| group_by | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |