Skip to main content
Glama

fda_drug_lookup

Search the FDA database to retrieve detailed drug information, including labels, adverse events, or general data, for informed healthcare decisions.

Instructions

Look up drug information from the FDA database

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
drug_nameYesName of the drug to search for
search_typeNoType of information to retrieve: 'label', 'adverse_events', or 'general'general

Implementation Reference

  • Core handler function for 'fda_drug_lookup' tool: validates input, checks cache, queries FDA API based on search_type, extracts and formats data, caches result.
    async lookupDrug(drugName, searchType = 'general') {
      // Input validation
      if (!drugName) {
        return this.formatErrorResponse('Drug name is required');
      }
      
      // Normalize search type
      searchType = searchType.toLowerCase();
      if (!['label', 'adverse_events', 'general'].includes(searchType)) {
        searchType = 'general';
      }
      
      // Create cache key
      const cacheKey = this.getCacheKey('fda_drug', searchType, drugName);
      
      // Check cache first
      const cachedResult = this.cache.get(cacheKey);
      if (cachedResult) {
        console.error(`Cache hit for FDA drug lookup: ${drugName}, ${searchType}`);
        return cachedResult;
      }
      
      try {
        console.error(`Fetching FDA drug information for ${drugName}, type: ${searchType}`);
        
        // Determine endpoint and query based on search type
        let endpoint, query;
        if (searchType === 'adverse_events' || searchType === 'label') {
          endpoint = `${this.baseUrl}/label.json`;
          query = `openfda.generic_name:${drugName} OR openfda.brand_name:${drugName}`;
        } else { // general
          endpoint = `${this.baseUrl}/ndc.json`;
          query = `generic_name:${drugName} OR brand_name:${drugName}`;
        }
        
        // Build API URL with parameters
        const params = {
          search: query,
          limit: 1
        };
        
        // Add API key if available
        if (this.apiKey) {
          params.api_key = this.apiKey;
        }
        
        const url = this.buildUrl(endpoint, params);
        
        // Make the request
        const data = await this.makeRequest(url);
        
        // Extract and sanitize key information
        const extractedData = this.extractKeyInfo(data, searchType);
        
        // Process the response into expected format
        const drugs = data.results ? data.results.map(drug => ({
          product_number: drug.product_ndc || drug.ndc_product_code || '',
          generic_name: drug.generic_name || extractedData.generic_name || '',
          brand_name: drug.brand_name || extractedData.brand_name || '',
          labeler_name: drug.labeler_name || extractedData.manufacturer || '',
          product_type: drug.product_type || extractedData.product_type || '',
          ...extractedData
        })) : [extractedData];
        
        const result = this.formatSuccessResponse({
          drug_name: drugName,
          search_type: searchType,
          drugs: drugs,
          total_results: data.meta?.results?.total || 0
        });
        
        // Cache for 24 hours (86400 seconds)
        this.cache.set(cacheKey, result, 86400);
        
        return result;
        
      } catch (error) {
        console.error(`Error fetching FDA drug information: ${error.message}`);
        return this.formatErrorResponse(`Error fetching drug information: ${error.message}`);
      }
    }
  • Input schema defining parameters for the fda_drug_lookup tool: required drug_name (string), optional search_type (enum: general, label, adverse_events).
    inputSchema: {
      type: "object",
      properties: {
        drug_name: {
          type: "string",
          description: "Name of the drug to search for",
        },
        search_type: {
          type: "string",
          description: "Type of information to retrieve: 'label', 'adverse_events', or 'general'",
          enum: ["general", "label", "adverse_events"],
          default: "general",
        },
      },
      required: ["drug_name"],
    },
  • server/index.js:59-78 (registration)
    Tool registration in ListTools handler, including name, description, and input schema.
    {
      name: "fda_drug_lookup",
      description: "Look up drug information from the FDA database",
      inputSchema: {
        type: "object",
        properties: {
          drug_name: {
            type: "string",
            description: "Name of the drug to search for",
          },
          search_type: {
            type: "string",
            description: "Type of information to retrieve: 'label', 'adverse_events', or 'general'",
            enum: ["general", "label", "adverse_events"],
            default: "general",
          },
        },
        required: ["drug_name"],
      },
    },
  • Dispatch registration in CallToolRequestSchema handler switch statement.
    case "fda_drug_lookup":
      result = await fdaTool.lookupDrug(args.drug_name, args.search_type);
      break;
  • Helper method to extract and sanitize relevant drug information from FDA API response based on search type.
    extractKeyInfo(data, searchType) {
      const extracted = {};
      
      // Handle empty results
      if (!data || typeof data !== 'object' || !data.results) {
        return extracted;
      }
      
      // Get the first result (most relevant)
      const result = data.results && data.results.length > 0 ? data.results[0] : {};
      
      // Extract basic information based on search type
      if (searchType === 'label') {
        // Extract drug identification
        if (result.openfda) {
          const openfda = result.openfda;
          extracted.brand_names = (openfda.brand_name || []).slice(0, 3);
          extracted.generic_names = (openfda.generic_name || []).slice(0, 3);
          extracted.manufacturer = (openfda.manufacturer_name || []).slice(0, 1);
        }
        
        // Extract key clinical information (limit size)
        extracted.indications = this.sanitizeText(result.indications_and_usage || []);
        extracted.dosage = this.sanitizeText(result.dosage_and_administration || []);
        extracted.warnings = this.sanitizeText(result.warnings_and_cautions || []);
        extracted.contraindications = this.sanitizeText(result.contraindications || []);
        
        // Extract adverse reactions
        extracted.adverse_reactions = this.sanitizeText(result.adverse_reactions || []);
        
        // Extract drug interactions
        extracted.drug_interactions = this.sanitizeText(result.drug_interactions || []);
        
        // Extract pregnancy info
        extracted.pregnancy = this.sanitizeText(result.pregnancy || []);
        
      } else if (searchType === 'adverse_events') {
        // Focus on adverse events from label data
        if (result.openfda) {
          const openfda = result.openfda;
          extracted.brand_names = (openfda.brand_name || []).slice(0, 3);
          extracted.generic_names = (openfda.generic_name || []).slice(0, 3);
        }
        
        // Focus on adverse reactions and warnings
        extracted.adverse_reactions = this.sanitizeText(result.adverse_reactions || []);
        extracted.warnings = this.sanitizeText(result.warnings_and_cautions || []);
        extracted.boxed_warning = this.sanitizeText(result.boxed_warning || []);
        
      } else { // general
        // Extract basic drug identification
        extracted.generic_name = result.generic_name || '';
        extracted.brand_name = result.brand_name || '';
        extracted.manufacturer = result.labeler_name || '';
        extracted.product_type = result.product_type || '';
        extracted.route = result.route || [];
        extracted.marketing_status = result.marketing_status || '';
      }
      
      return extracted;
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure but only states the basic action. It doesn't cover aspects like rate limits, authentication needs, response format, or potential errors (e.g., drug not found), which are critical for a lookup tool interacting with an external database.

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, clear sentence with no wasted words, making it easy to parse and front-loaded with essential information. It efficiently communicates the core purpose without unnecessary elaboration.

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 an FDA database lookup with no annotations and no output schema, the description is insufficient. It lacks details on what information is returned, how results are structured, or any behavioral traits, leaving significant gaps for the agent to understand the tool's operation fully.

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?

The schema description coverage is 100%, with clear descriptions for both parameters, including an enum for 'search_type'. The description adds no additional parameter information beyond what the schema provides, so it meets the baseline score of 3 without compensating or detracting.

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 action ('Look up') and resource ('drug information from the FDA database'), making the tool's purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'clinical_trials_search' or 'pubmed_search' which also involve medical data lookup, missing an opportunity for clearer distinction.

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?

No guidance is provided on when to use this tool versus alternatives. The description doesn't mention sibling tools or specify use cases like FDA-specific regulatory information versus clinical trials or PubMed articles, leaving the agent without context for selection.

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

Related 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/Cicatriiz/healthcare-mcp-public'

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