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

NameTypeRequiredDescription
querystringyesOpenFDA search query to filter events before counting. Same syntax as fda_drug_events.
count_fieldstringyesField 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"
}

Response shape

Always returns: query, count_field, results

FieldTypeDescription
querystringThe search query used to filter events
count_fieldstringThe field aggregated/counted by
resultsarrayArray of count results by term
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"
        ]
      }
    }
  },
  "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.

Regenerated from source · build May 9, 2026