Skip to main content
Glama

Count/aggregate over an openFDA dataset

count
Read-only

openFDA's most valuable feature: aggregate over any dataset by a field to get a top-terms histogram (returns results: [{term, count}] instead of records). Use the '.exact' field suffix to count whole phrases. Example: endpoint 'drug/event', field 'patient.reaction.reactionmeddrapt.exact', search 'patient.drug.medicinalproduct:"aspirin"' → the most common reactions reported for aspirin.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
fieldYesThe field to count/aggregate on (required), e.g. 'patient.reaction.reactionmeddrapt.exact' or 'classification'. Add '.exact' to count whole phrases rather than tokens.
limitNoMax number of distinct terms to return (1–1000).
searchNoOptional Lucene filter applied before aggregation (same syntax as the search tools).
endpointYesThe openFDA endpoint to query, e.g. 'drug/event', 'device/510k', 'food/enforcement'.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changed
    • changedInput schema / $schema
      Previous value: -"http://json-schema.org/draft-07/schema#"New value: +"https://json-schema.org/draft/2020-12/schema"
  2. First observed

TDQS

A4.3/5.0
Behavior4/5

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

Annotations only declare readOnlyHint=true, so the description carries real weight: it discloses the return shape (aggregated terms rather than records), that 'search' is applied before aggregation, and the token-vs-phrase behavior of '.exact'. It omits rate limits, result ordering, and pagination, which keeps it out of the top band.

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?

Front-loads the core insight ('aggregate... top-terms histogram') before the example, and every sentence is load-bearing. The worked example is slightly verbose but earns its place by demonstrating the parameter combination.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a 4-parameter aggregation tool with no output schema, the description compensates by describing the return shape and the pre-aggregation filter behavior. It could still note result ordering or limits interplay, but nothing essential for a correct call 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 baseline is 3, but the description adds genuine value by showing how endpoint, field, and search combine in a concrete example, and by explaining the semantic effect of the '.exact' suffix. This is integration guidance the schema alone does not convey.

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 and resource ('aggregate over any dataset by a field to get a top-terms histogram') and explicitly contrasts the output with the sibling search tools ('returns results: [{term, count}] instead of records'). An agent can immediately tell this apart from the search_* siblings.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Gives a clear use case and a worked example wiring endpoint, field, and search together, plus the '.exact' rule for phrase counting. It implies but never explicitly states when to prefer this over the named sibling search tools (e.g. 'use search_drug_events when you need records'), so it stops short of full routing 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.