fda_event_counts
Pack: openfda · Endpoint: https://gateway.pipeworx.io/openfda/mcp
Aggregate adverse events by reaction type, patient age, or outcome. Returns top reactions for a drug and event trends over time.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
query | string | yes | OpenFDA search query to filter events before counting. Same syntax as fda_drug_events. |
count_field | string | yes | Field to count/aggregate by. Examples: “patient.reaction.reactionmeddrapt.exact” (top reactions), “receivedate” (timeline), “serious” (severity breakdown), “patient.drug.openfda.brand_name.exact” (co-reported drugs) |
Example call
Arguments
{
"query": "patient.drug.openfda.brand_name:\"ASPIRIN\"",
"count_field": "patient.reaction.reactionmeddrapt.exact"
}
curl
curl -X POST https://gateway.pipeworx.io/openfda/mcp \
-H 'Content-Type: application/json' \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"fda_event_counts","arguments":{"query":"patient.drug.openfda.brand_name:\"ASPIRIN\"","count_field":"patient.reaction.reactionmeddrapt.exact"}}}'
TypeScript (@pipeworx/sdk)
import { Pipeworx } from '@pipeworx/sdk';
const pipeworx = new Pipeworx();
const result = await pipeworx.call('fda_event_counts', {
"query": "patient.drug.openfda.brand_name:\"ASPIRIN\"",
"count_field": "patient.reaction.reactionmeddrapt.exact"
});
More examples
{
"query": "serious:1+AND+receivedate:[20230101+TO+20231231]",
"count_field": "receivedate"
}
{
"query": "patient.drug.openfda.generic_name:\"MONTELUKAST\"",
"count_field": "patient.patientonsetage"
}
Response shape
Always returns: query, count_field, results
| Field | Type | Description |
|---|---|---|
query | string | The search query used to filter events |
count_field | string | The field aggregated/counted by |
results | array | Array of count results by term |
reaction_requested | string | The reaction term as the caller supplied it, uppercased |
reaction_resolved | string | The MedDRA preferred term actually used for the filter |
reaction_resolution | string | How the supplied reaction term mapped onto a MedDRA preferred term. not_a_meddra_preferred_term means the filter matched nothing — counts are zero because the term missed, not because no reports exist |
reaction_resolution_note | string | Present when word order was corrected; states the substitution made |
reaction_resolution_hint | string | Present when the term matched nothing; names a working way to discover the real preferred terms |
requested_query | string | The search query as supplied, when it differs from the resolved query in query |
Full JSON Schema
{
"type": "object",
"properties": {
"query": {
"type": "string",
"description": "The search query used to filter events"
},
"count_field": {
"type": "string",
"description": "The field aggregated/counted by"
},
"results": {
"type": "array",
"description": "Array of count results by term",
"items": {
"type": "object",
"properties": {
"term": {
"type": "string",
"description": "The term/value counted"
},
"count": {
"type": "number",
"description": "Number of occurrences"
}
},
"required": [
"term",
"count"
]
}
},
"reaction_requested": {
"type": "string",
"description": "The reaction term as the caller supplied it, uppercased"
},
"reaction_resolved": {
"type": "string",
"description": "The MedDRA preferred term actually used for the filter"
},
"reaction_resolution": {
"type": "string",
"enum": [
"exact_match",
"word_order_corrected",
"not_a_meddra_preferred_term"
],
"description": "How the supplied reaction term mapped onto a MedDRA preferred term. not_a_meddra_preferred_term means the filter matched nothing — counts are zero because the term missed, not because no reports exist"
},
"reaction_resolution_note": {
"type": "string",
"description": "Present when word order was corrected; states the substitution made"
},
"reaction_resolution_hint": {
"type": "string",
"description": "Present when the term matched nothing; names a working way to discover the real preferred terms"
},
"requested_query": {
"type": "string",
"description": "The search query as supplied, when it differs from the resolved query in `query`"
}
},
"required": [
"query",
"count_field",
"results"
]
}
Connect
Add this to your MCP client config, or use one-click install buttons:
{
"mcpServers": {
"openfda": {
"url": "https://gateway.pipeworx.io/openfda/mcp"
}
}
}
See Getting Started for client-specific install steps.