Skip to main content
Glama

Count matching documents

count
Read-only

Return the number of documents matching a DSL query without retrieving them. Provides raw OpenSearch response with match totals, flagging incomplete results when you need only the number.

Instructions

Count documents matching a DSL query clause, without returning the documents.

    Use this instead of search_dsl when you only need the number of matches, not
    the documents themselves. Note the query_dsl shape differs from search_dsl's —
    the schema says how. Returns the raw OpenSearch _count response
    ({"count": N, ...}), with an "INCOMPLETE:" line above it when some shards
    failed or the count timed out.

    This tool takes no time arguments and applies no default window, so a
    bare call counts everything the index still holds, which on any real
    capture is millions of documents. Bound it with a range clause inside
    query_dsl, use malcolm_search when you want a human-readable time range,
    or arkime_sessions_summary when you want byte and packet totals beside
    the count.
    

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
indexNoIndex or pattern to count over. Accepts a wildcard; default is the Malcolm sessions index.arkime_sessions3-*
query_dslNoJSON string of the INNER DSL query clause only, e.g. {"term": {"event.dataset": "conn"}} (no "query" wrapper, no "aggs"/"size"). Empty counts all documents (match_all).

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv1.0.2
  2. Removedv0.3.3
  3. Addedv0.3.2
  4. Removedv0.3.0
  5. First observedv0.1.0

TDQS

A4.9/5.0
Behavior5/5

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

Goes well beyond the readOnly/openWorld annotations: it discloses the exact return envelope ({"count": N, ...}), the 'INCOMPLETE:' prefix on shard failure or timeout, and — critically — that there are no time arguments or default window, so a bare call counts millions of documents. That default-behavior warning is exactly the behavioral context an agent cannot get from structured fields.

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?

Front-loaded with the core purpose, then alternatives, then the run-away-default warning. Every sentence earns its place; no filler despite the length.

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?

An output schema exists, yet the description still names the return shape and the failure signal, and it warns about the unscoped default. For a 2-param read tool with annotations, nothing an agent needs in order to call it safely is missing.

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 baseline is 3; the description still adds value by flagging that query_dsl's shape differs from search_dsl's and that there are no time parameters bounding the count. It defers the precise shape to the schema, which is reasonable, but the added semantics are real.

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?

States a specific verb (count) and resource (documents matching a DSL query clause) and immediately clarifies the scope boundary: no documents are returned. An agent can distinguish it from search_dsl and the aggregate/field siblings 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?

Explicitly routes selection: 'use this instead of search_dsl when you only need the number of matches', and names malcolm_search for human-readable time ranges and arkime_sessions_summary for byte/packet totals. Both the when and the when-not are given.

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