Skip to main content
Glama

Openfda Count Values

openfda_count_values
Read-only

Aggregate and tally unique values for any field across any openFDA endpoint. Returns ranked term-count pairs sorted by count descending. Pair with openfda_search_adverse_events, openfda_search_drug_approvals, openfda_search_device_clearances, openfda_search_recalls, openfda_get_drug_label, or openfda_lookup_ndc when sample records help interpret the aggregates.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
countYesField to count. Append .exact for whole-phrase counting of free-text fields (e.g. "patient.reaction.reactionmeddrapt.exact"). Identifier fields openFDA already indexes as keywords (product_ndc, application_number, pma_number) must be counted bare — .exact on those is rejected as not countable.
limitNoNumber of top terms to return (default 100, max 1000)
searchNoFilter query to scope the count (e.g. patient.drug.medicinalproduct:"metformin"). Omit to count across every record in the endpoint. Double quotes, parentheses, and range brackets must balance, and the query must not end on a backslash — each is rejected before the request.
endpointYesFull openFDA endpoint path (e.g. "drug/event", "device/classification")

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
capNoThe limit applied to the term list.
metaNoResponse metadata
errorNoPresent when the call failed. Absent on success.
shownNoNumber of terms returned in this response.
noticeNoGuidance when no terms matched — how to verify the field name or adjust the count expression. Absent when terms are returned.
resultsNoTerm-count pairs sorted by count descending
termCountNoNumber of distinct terms returned
truncatedNoTrue when the term list was capped at the limit — more distinct terms may exist.
truncationCeilingNoCount of the lowest-ranked term returned — omitted terms fall at or below it.

TDQS

A4.7/5.0
Behavior4/5

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

Annotations already declare readOnlyHint=true, so the description need not repeat safety. It adds valuable behavioral detail: sorting order, counting semantics ('append .exact'), and special handling for identifier fields (bare counting required). It also notes validation rejections (e.g., unbalanced quotes, backslash endings), which are useful edge cases. A small gap is not describing pagination or rate limits, but for a read-only aggregate tool the coverage is strong.

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?

The description is information-dense and front-loaded with the core action and output. It earns each sentence, but it is slightly long and the final pairing sentence could be seen as extra. Still, it is well-organized and not padded.

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?

With a rich schema (100% parameter coverage), a clear output schema, and readOnlyHint annotation, the description fills the gaps that matter: interpretation of results (ranking), use with sibling tools, and critical .exact behavior. An agent has enough to invoke correctly without surprise.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, yet the description elevates parameter meaning significantly. It explains when to use .exact, warns that certain fields reject .exact, gives a concrete search example, and clarifies the default/max limit. This goes well beyond the schema's bare descriptions.

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?

Description states a specific verb ('Aggregate and tally'), a resource ('unique values for any field across any openFDA endpoint'), and the output format ('ranked term-count pairs sorted by count descending'). It clearly differentiates from sibling search tools by emphasizing aggregation over retrieval of records.

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 names six sibling tools as complementary partners for interpreting aggregates ('Pair with...'). It does not spell out when NOT to use this tool, but the pairing guidance strongly implies this tool is for aggregation and those others are for sample records, which is clear directional 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.

TDQS

A4/5.0
Disambiguation5/5

Each tool targets a distinct FDA endpoint or analytic function. Search tools are separated by domain (adverse events, animal events, recalls, tobacco, etc.), and utility tools (count_values, describe_fields, dataframe_describe/query, drug_profile) serve unique purposes without overlap. An agent can clearly identify which tool to call for a given task.

Naming Consistency5/5

All tools follow a consistent openfda_<action>_<object> pattern in snake_case. Search tools use search_<domain>, while utility tools use clear verbs like get, lookup, count, describe, and query. The only slight deviation is drug_profile (a noun phrase), but it remains intuitive and fits the naming style.

Tool Count5/5

With 14 tools, the server is well-scoped for its purpose of providing access to multiple openFDA endpoints. Each tool covers a distinct resource or analytic capability, and none feel redundant. The count sits comfortably within the ideal range for a domain-specific server.

Completeness5/5

The server covers the major openFDA data categories: adverse events (human/animal), device clearances, drug approvals, shortages, recalls, tobacco, labels, and NDC lookup. It also provides robust analytics via count_values and dataframe queries, plus field discovery. There are no obvious gaps for the stated domain, and the composite drug_profile fills integration needs.