Skip to main content
Glama

Contar por valor o clave

array-count-by
Read-onlyIdempotent

Cuenta las apariciones de cada valor distinto (o de una clave), ordenadas de mayor a menor. Cuándo: hay que transformar, comparar o revisar con exactitud datos estructurados (JSON, CSV, YAML, XML, arreglos). No para: agrupar objetos por el valor de una clave y devolver grupos y conteos (array-group-by). Efectos secundarios: ninguno (solo lectura, sin red, sin estado guardado). Determinista: la misma entrada da la misma salida. Límites: entrada JSON de hasta 64 KB, 1 s por llamada, resultado de hasta 1 MB.

EN: Counts occurrences of each distinct value (or of a key's value), sorted by count descending. When: structured data (JSON, CSV, YAML, XML, arrays) has to be transformed, compared or checked exactly. Not for: grouping objects by the value of a key (array-group-by). Side effects: none (read-only, no network access, no stored state). Deterministic: the same input gives the same output. Limits: JSON input up to 64 KB, 1 s per call, result up to 1 MB.

Input Schema

NameRequiredDescriptionDefault
byNoObject key (dotted path allowed) to compare by (string; optional; up to 500 chars).
itemsYesArray (array; required).

Output Schema

NameRequiredDescriptionDefault
countsNo
distinctNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changed
    • addedInput schema / properties / items / examples
      Added value: +[
      +  [
      +    "a",
      +    "b",
      +    "a",
      +    "c",
      +    "a",
      +    "b"
      +  ]
      +]
  2. First observed

TDQS

A4.6/5.0
Behavior5/5

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

Annotations already declare readOnly/openWorld/idempotent/destructive, but the description goes beyond them with concrete limits (64 KB input, 1 s per call, 1 MB result) and determinism, which annotations cannot express. These are operationally important for an agent deciding whether to call.

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

Conciseness4/5

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

Content is dense and front-loaded: purpose first, then when/not-for, side effects, determinism, limits. The only cost is full bilingual duplication, which roughly doubles length without adding 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?

An output schema exists, so return values needn't be explained; annotations cover safety; the description still supplies limits, determinism, and the sibling alternative. Nothing an agent needs to call correctly is missing.

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 coverage is 100%, so both parameters are documented structurally. The phrase 'or of a key's value' clarifies what `by` does beyond the schema's own description, but the gain over the schema is marginal (no dotted-path semantics, ordering interaction, or edge-case notes added).

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 action: counts occurrences of each distinct value (or a key's value), sorted descending. Explicitly distinguishes from the sibling array-group-by, so an agent can choose between them without opening schemas.

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' (structured data that must be transformed, compared, or checked exactly) and an explicit 'Not for' pointing to array-group-by with the differentiator (returning groups and counts). This is textbook when/when-not/alternative guidance.

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.

Resources