Skip to main content
Glama

check-drug-interactions

Identify potential drug-drug interactions between two medications to help prevent adverse effects and ensure medication safety.

Instructions

Check for potential drug-drug interactions between two medications

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
drug1YesFirst drug name
drug2YesSecond drug name

Implementation Reference

  • src/index.ts:215-230 (registration)
    Registration of the 'check-drug-interactions' tool with MCP server, including inline input schema (zod) and thin wrapper handler that delegates to core logic.
    server.tool(
      "check-drug-interactions",
      "Check for potential drug-drug interactions between two medications",
      {
        drug1: z.string().describe("First drug name"),
        drug2: z.string().describe("Second drug name"),
      },
      async ({ drug1, drug2 }) => {
        try {
          const interactions = await checkDrugInteractions(drug1, drug2);
          return formatDrugInteractions(interactions, drug1, drug2);
        } catch (error: any) {
          return createErrorResponse("checking drug interactions", error);
        }
      },
    );
  • Core handler implementation: Queries PubMed API for literature on drug interactions between the two input drugs, parses abstracts to detect interactions, classifies severity, extracts clinical effects and management advice.
    export async function checkDrugInteractions(
      drug1: string,
      drug2: string,
    ): Promise<DrugInteraction[]> {
      try {
        // Search for interaction studies between the two drugs
        const interactionTerms = [
          `"${drug1}" AND "${drug2}" AND "interaction"`,
          `"${drug1}" AND "${drug2}" AND "contraindication"`,
          `"${drug1}" AND "${drug2}" AND "adverse"`,
        ];
    
        const interactions: DrugInteraction[] = [];
    
        for (const term of interactionTerms) {
          try {
            const searchRes = await superagent
              .get(`${PUBMED_API_BASE}/esearch.fcgi`)
              .query({
                db: "pubmed",
                term: term,
                retmode: "json",
                retmax: 3,
              })
              .set("User-Agent", USER_AGENT);
    
            const idList = searchRes.body.esearchresult?.idlist || [];
            if (idList.length > 0) {
              const fetchRes = await superagent
                .get(`${PUBMED_API_BASE}/efetch.fcgi`)
                .query({
                  db: "pubmed",
                  id: idList.join(","),
                  retmode: "xml",
                })
                .set("User-Agent", USER_AGENT);
    
              const articles = parsePubMedXML(fetchRes.text);
    
              for (const article of articles) {
                const abstract = (article.abstract || "").toLowerCase();
    
                if (
                  (abstract.includes("interaction") ||
                    abstract.includes("contraindication")) &&
                  !abstract.includes("no interaction") &&
                  !abstract.includes("safe combination") &&
                  !abstract.includes("no contraindication") &&
                  !abstract.includes("can be used together")
                ) {
                  let severity: "Minor" | "Moderate" | "Major" | "Contraindicated" =
                    "Moderate";
    
                  // More careful severity assessment
                  if (
                    abstract.includes("contraindicated") ||
                    abstract.includes("avoid")
                  ) {
                    severity = "Contraindicated";
                  } else if (
                    abstract.includes("severe") ||
                    abstract.includes("major")
                  ) {
                    severity = "Major";
                  } else if (
                    abstract.includes("minor") ||
                    abstract.includes("mild")
                  ) {
                    severity = "Minor";
                  }
    
                  // Avoid duplicates
                  const existingInteraction = interactions.find(
                    (i) => i.drug1 === drug1 && i.drug2 === drug2,
                  );
                  if (!existingInteraction) {
                    // Extract specific clinical effects from the abstract
                    const clinicalEffects = extractClinicalEffects(abstract);
                    const management = extractManagementAdvice(abstract);
    
                    interactions.push({
                      drug1,
                      drug2,
                      severity,
                      description: `Interaction between ${drug1} and ${drug2} - see referenced literature`,
                      clinical_effects:
                        clinicalEffects ||
                        "See referenced literature for clinical effects",
                      management:
                        management ||
                        "Consult healthcare provider before combining medications",
                      evidence_level: "Literature Review",
                    });
                  }
                }
              }
            }
          } catch (error) {
            console.error(`Error checking interactions for term: ${term}`, error);
          }
        }
    
        return interactions;
      } catch (error) {
        console.error("Error checking drug interactions:", error);
        return [];
      }
    }
  • Type definition for DrugInteraction results returned by the handler.
    export type DrugInteraction = {
      drug1: string;
      drug2: string;
      severity: "Minor" | "Moderate" | "Major" | "Contraindicated";
      description: string;
      clinical_effects: string;
      management: string;
      evidence_level: string;
    };
  • Helper function to format DrugInteraction results into a user-friendly MCP text response.
    export function formatDrugInteractions(
      interactions: any[],
      drug1: string,
      drug2: string,
    ) {
      if (interactions.length === 0) {
        return createMCPResponse(
          `No significant drug interactions found between ${drug1} and ${drug2}. However, always consult a healthcare provider before combining medications.`,
        );
      }
    
      let result = `**Drug Interaction Check: ${drug1} + ${drug2}**\n\n`;
      result += `Found ${interactions.length} interaction(s)\n\n`;
    
      interactions.forEach((interaction, index) => {
        result += `${index + 1}. **${interaction.severity} Interaction**\n`;
        result += `   Description: ${interaction.description}\n`;
        if (interaction.clinical_effects) {
          result += `   Clinical Effects: ${interaction.clinical_effects}\n`;
        }
        if (interaction.management) {
          result += `   Management: ${interaction.management}\n`;
        }
        result += "\n";
      });
    
      return createMCPResponse(result);
    }
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 states the tool checks for 'potential' interactions but doesn't specify what constitutes a potential interaction, the source of data, accuracy levels, or output format. For a medical tool with safety implications, this is a significant gap.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that directly states the tool's purpose without unnecessary words. It is appropriately sized and front-loaded, making it easy for an agent to parse quickly.

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

Completeness2/5

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

Given the complexity of drug interaction checking and the lack of annotations and output schema, the description is incomplete. It doesn't explain what the tool returns, how interactions are categorized, or any limitations, which is inadequate for a tool with potential safety-critical applications.

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%, with clear descriptions for 'drug1' and 'drug2' as drug names. The description adds no additional parameter semantics beyond what the schema provides, such as format examples or constraints, so it meets the baseline for high schema 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 ('Check') and resource ('drug-drug interactions'), specifying it evaluates interactions between two medications. However, it doesn't distinguish this from sibling tools like 'get-drug-details' or 'search-drugs', which might provide related but different functionality.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites, exclusions, or compare it to sibling tools such as 'search-drug-nomenclature' or 'search-medical-databases', leaving the agent to infer usage context.

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/JamesANZ/medical-mcp'

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