Skip to main content
Glama

get-drug-adverse-events

Retrieve adverse event reports for medications to access safety information about reported side effects and reactions using brand or generic drug names.

Instructions

Get adverse event reports for a drug. This provides safety information about reported side effects and reactions. Use brand name or generic name.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
drugNameYesDrug name (brand or generic)
limitNoMaximum number of events to return
seriousnessNoFilter by event seriousnessall

Implementation Reference

  • The core handler function for the get-drug-adverse-events tool. Builds an OpenFDA API query for adverse events using the drug name, optional limit and seriousness filters. Fetches data, handles errors/no results, maps results to a user-friendly format (report ID, seriousness, patient details, reactions, etc.), and returns formatted JSON text.
    async ({ drugName, limit, seriousness }) => {
      let searchQuery = `patient.drug.medicinalproduct:"${drugName}"`;
      
      if (seriousness !== "all") {
        const serious = seriousness === "serious" ? "1" : "2";
        searchQuery += `+AND+serious:${serious}`;
      }
    
      const url = new OpenFDABuilder()
        .context("event")
        .search(searchQuery)
        .limit(limit)
        .build();
    
      const { data: eventData, error } = await makeOpenFDARequest<any>(url);
      
      if (error) {
        return {
          content: [{
            type: "text",
            text: `Failed to retrieve adverse events for "${drugName}": ${error.message}`,
          }],
        };
      }
    
      if (!eventData || !eventData.results || eventData.results.length === 0) {
        return {
          content: [{
            type: "text",
            text: `No adverse events found for "${drugName}".`,
          }],
        };
      }
    
      const events = eventData.results.map((event: any) => ({
        report_id: event.safetyreportid,
        serious: event.serious === "1" ? "Yes" : "No",
        patient_age: event.patient?.patientonsetage || "Unknown",
        patient_sex: event.patient?.patientsex === "1" ? "Male" : event.patient?.patientsex === "2" ? "Female" : "Unknown",
        reactions: event.patient?.reaction?.map((r: any) => r.reactionmeddrapt).slice(0, 3) || [],
        outcomes: event.patient?.reaction?.map((r: any) => r.reactionoutcome).slice(0, 3) || [],
        report_date: event.receiptdate || "Unknown"
      }));
    
      return {
        content: [{
          type: "text",
          text: `Found ${events.length} adverse event report(s) for "${drugName}":\n\n${JSON.stringify(events, null, 2)}`,
        }],
      };
    }
  • Zod input schema defining parameters for the tool: drugName (required string), limit (optional number, default 10), seriousness (optional enum: serious/non-serious/all, default all).
    {
      drugName: z.string().describe("Drug name (brand or generic)"),
      limit: z.number().optional().default(10).describe("Maximum number of events to return"),
      seriousness: z.enum(["serious", "non-serious", "all"]).optional().default("all").describe("Filter by event seriousness")
    },
  • src/index.ts:201-260 (registration)
    Tool registration using server.tool() with name, description, Zod input schema, and inline async handler function.
    server.tool(
      "get-drug-adverse-events",
      "Get adverse event reports for a drug. This provides safety information about reported side effects and reactions. Use brand name or generic name.",
      {
        drugName: z.string().describe("Drug name (brand or generic)"),
        limit: z.number().optional().default(10).describe("Maximum number of events to return"),
        seriousness: z.enum(["serious", "non-serious", "all"]).optional().default("all").describe("Filter by event seriousness")
      },
      async ({ drugName, limit, seriousness }) => {
        let searchQuery = `patient.drug.medicinalproduct:"${drugName}"`;
        
        if (seriousness !== "all") {
          const serious = seriousness === "serious" ? "1" : "2";
          searchQuery += `+AND+serious:${serious}`;
        }
    
        const url = new OpenFDABuilder()
          .context("event")
          .search(searchQuery)
          .limit(limit)
          .build();
    
        const { data: eventData, error } = await makeOpenFDARequest<any>(url);
        
        if (error) {
          return {
            content: [{
              type: "text",
              text: `Failed to retrieve adverse events for "${drugName}": ${error.message}`,
            }],
          };
        }
    
        if (!eventData || !eventData.results || eventData.results.length === 0) {
          return {
            content: [{
              type: "text",
              text: `No adverse events found for "${drugName}".`,
            }],
          };
        }
    
        const events = eventData.results.map((event: any) => ({
          report_id: event.safetyreportid,
          serious: event.serious === "1" ? "Yes" : "No",
          patient_age: event.patient?.patientonsetage || "Unknown",
          patient_sex: event.patient?.patientsex === "1" ? "Male" : event.patient?.patientsex === "2" ? "Female" : "Unknown",
          reactions: event.patient?.reaction?.map((r: any) => r.reactionmeddrapt).slice(0, 3) || [],
          outcomes: event.patient?.reaction?.map((r: any) => r.reactionoutcome).slice(0, 3) || [],
          report_date: event.receiptdate || "Unknown"
        }));
    
        return {
          content: [{
            type: "text",
            text: `Found ${events.length} adverse event report(s) for "${drugName}":\n\n${JSON.stringify(events, null, 2)}`,
          }],
        };
      }
    );
  • Identical handler implementation in the built JavaScript version (bin/index.js).
    }, async ({ drugName, limit, seriousness }) => {
        let searchQuery = `patient.drug.medicinalproduct:"${drugName}"`;
        if (seriousness !== "all") {
            const serious = seriousness === "serious" ? "1" : "2";
            searchQuery += `+AND+serious:${serious}`;
        }
        const url = new OpenFDABuilder()
            .context("event")
            .search(searchQuery)
            .limit(limit)
            .build();
        const { data: eventData, error } = await makeOpenFDARequest(url);
        if (error) {
            return {
                content: [{
                        type: "text",
                        text: `Failed to retrieve adverse events for "${drugName}": ${error.message}`,
                    }],
            };
        }
        if (!eventData || !eventData.results || eventData.results.length === 0) {
            return {
                content: [{
                        type: "text",
                        text: `No adverse events found for "${drugName}".`,
                    }],
            };
        }
        const events = eventData.results.map((event) => ({
            report_id: event.safetyreportid,
            serious: event.serious === "1" ? "Yes" : "No",
            patient_age: event.patient?.patientonsetage || "Unknown",
            patient_sex: event.patient?.patientsex === "1" ? "Male" : event.patient?.patientsex === "2" ? "Female" : "Unknown",
            reactions: event.patient?.reaction?.map((r) => r.reactionmeddrapt).slice(0, 3) || [],
            outcomes: event.patient?.reaction?.map((r) => r.reactionoutcome).slice(0, 3) || [],
            report_date: event.receiptdate || "Unknown"
        }));
        return {
            content: [{
                    type: "text",
                    text: `Found ${events.length} adverse event report(s) for "${drugName}":\n\n${JSON.stringify(events, null, 2)}`,
                }],
        };
    });
  • bin/index.js:174-221 (registration)
    Tool registration in the built JavaScript entry point (bin/index.js).
    server.tool("get-drug-adverse-events", "Get adverse event reports for a drug. This provides safety information about reported side effects and reactions. Use brand name or generic name.", {
        drugName: z.string().describe("Drug name (brand or generic)"),
        limit: z.number().optional().default(10).describe("Maximum number of events to return"),
        seriousness: z.enum(["serious", "non-serious", "all"]).optional().default("all").describe("Filter by event seriousness")
    }, async ({ drugName, limit, seriousness }) => {
        let searchQuery = `patient.drug.medicinalproduct:"${drugName}"`;
        if (seriousness !== "all") {
            const serious = seriousness === "serious" ? "1" : "2";
            searchQuery += `+AND+serious:${serious}`;
        }
        const url = new OpenFDABuilder()
            .context("event")
            .search(searchQuery)
            .limit(limit)
            .build();
        const { data: eventData, error } = await makeOpenFDARequest(url);
        if (error) {
            return {
                content: [{
                        type: "text",
                        text: `Failed to retrieve adverse events for "${drugName}": ${error.message}`,
                    }],
            };
        }
        if (!eventData || !eventData.results || eventData.results.length === 0) {
            return {
                content: [{
                        type: "text",
                        text: `No adverse events found for "${drugName}".`,
                    }],
            };
        }
        const events = eventData.results.map((event) => ({
            report_id: event.safetyreportid,
            serious: event.serious === "1" ? "Yes" : "No",
            patient_age: event.patient?.patientonsetage || "Unknown",
            patient_sex: event.patient?.patientsex === "1" ? "Male" : event.patient?.patientsex === "2" ? "Female" : "Unknown",
            reactions: event.patient?.reaction?.map((r) => r.reactionmeddrapt).slice(0, 3) || [],
            outcomes: event.patient?.reaction?.map((r) => r.reactionoutcome).slice(0, 3) || [],
            report_date: event.receiptdate || "Unknown"
        }));
        return {
            content: [{
                    type: "text",
                    text: `Found ${events.length} adverse event report(s) for "${drugName}":\n\n${JSON.stringify(events, null, 2)}`,
                }],
        };
    });
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions that the tool 'provides safety information about reported side effects and reactions,' which implies a read-only operation, but it doesn't disclose critical behavioral traits such as whether this is a query of a public database, potential rate limits, authentication needs, or what the output format looks like (e.g., list of events with details). This leaves significant gaps for an agent to understand how to handle the tool effectively.

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 appropriately sized with three concise sentences that front-load the core purpose. Each sentence adds value: the first states the action, the second clarifies the type of information, and the third provides input guidance. There's no wasted text, making it efficient for quick understanding.

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

Completeness3/5

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

Given the tool's moderate complexity (3 parameters, no output schema, no annotations), the description is somewhat complete but has gaps. It covers the purpose and basic input guidance but lacks details on behavioral aspects (e.g., output format, data source limitations) and doesn't leverage sibling context to clarify usage. Without annotations or output schema, more context on what to expect from the tool would improve completeness.

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 description coverage is 100%, so the schema already documents all parameters (drugName, limit, seriousness) with descriptions and defaults. The description adds minimal value by reiterating that drugName can be 'brand name or generic name,' which is already covered in the schema's description. It doesn't provide additional context like examples or usage tips beyond the schema, so it meets the baseline for high coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with a specific verb ('Get') and resource ('adverse event reports for a drug'), and it distinguishes the type of data (safety information about side effects and reactions). However, it doesn't explicitly differentiate from sibling tools like 'get-drug-safety-info', which might cover similar ground, so it falls short of a perfect score.

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

Usage Guidelines3/5

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

The description provides implied usage by specifying 'Use brand name or generic name' for the drugName parameter, which helps guide input. However, it lacks explicit guidance on when to use this tool versus alternatives like 'get-drug-safety-info' or other siblings, and it doesn't mention exclusions or prerequisites, leaving some ambiguity.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ythalorossy/openfda'

If you have feedback or need assistance with the MCP directory API, please join our Discord server