Skip to main content
Glama

search-drugs

Find drug information from FDA database by entering brand or generic names to access medication details and specifications.

Instructions

Search for drug information using FDA database

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesDrug name to search for (brand name or generic name)
limitNoNumber of results to return (max 50)

Implementation Reference

  • Core handler function that queries the FDA OpenFDA drug label API by brand name search term, returning DrugLabel objects.
    export async function searchDrugs(
      query: string,
      limit: number = 10,
    ): Promise<DrugLabel[]> {
      const res = await superagent
        .get(`${FDA_API_BASE}/drug/label.json`)
        .query({
          search: `openfda.brand_name:${query}`,
          limit: limit,
        })
        .set("User-Agent", USER_AGENT);
    
      return res.body.results || [];
    }
  • src/index.ts:43-67 (registration)
    MCP server.tool registration for 'search-drugs', including description, input schema, and wrapper handler calling searchDrugs.
    server.tool(
      "search-drugs",
      "Search for drug information using FDA database",
      {
        query: z
          .string()
          .describe("Drug name to search for (brand name or generic name)"),
        limit: z
          .number()
          .int()
          .min(1)
          .max(50)
          .optional()
          .default(10)
          .describe("Number of results to return (max 50)"),
      },
      async ({ query, limit }) => {
        try {
          const drugs = await searchDrugs(query, limit);
          return formatDrugSearchResults(drugs, query);
        } catch (error: any) {
          return createErrorResponse("searching drugs", error);
        }
      },
    );
  • Zod input schema defining 'query' (required string) and 'limit' (optional number, 1-50, default 10).
    {
      query: z
        .string()
        .describe("Drug name to search for (brand name or generic name)"),
      limit: z
        .number()
        .int()
        .min(1)
        .max(50)
        .optional()
        .default(10)
        .describe("Number of results to return (max 50)"),
    },
  • Helper function that formats the raw FDA API drug search results into a formatted text response for MCP.
    export function formatDrugSearchResults(drugs: any[], query: string) {
      if (drugs.length === 0) {
        return createMCPResponse(
          `No drugs found for "${query}". Try a different search term.`,
        );
      }
    
      let result = `**Drug Search Results for "${query}"**\n\n`;
      result += `Found ${drugs.length} drug(s)\n\n`;
    
      drugs.forEach((drug, index) => {
        result += `${index + 1}. **${drug.openfda.brand_name?.[0] || "Unknown Brand"}**\n`;
        result += `   Generic Name: ${drug.openfda.generic_name?.[0] || "Not specified"}\n`;
        result += `   Manufacturer: ${drug.openfda.manufacturer_name?.[0] || "Not specified"}\n`;
        result += `   Route: ${drug.openfda.route?.[0] || "Not specified"}\n`;
        result += `   Dosage Form: ${drug.openfda.dosage_form?.[0] || "Not specified"}\n`;
    
        if (drug.purpose && drug.purpose.length > 0) {
          result += `   Purpose: ${drug.purpose[0].substring(0, 200)}${drug.purpose[0].length > 200 ? "..." : ""}\n`;
        }
    
        result += `   Last Updated: ${drug.effective_time}\n\n`;
      });
    
      return createMCPResponse(result);
    }
  • TypeScript interface defining the structure of FDA DrugLabel objects returned by the search API.
    export type DrugLabel = {
      openfda: {
        brand_name?: string[];
        generic_name?: string[];
        manufacturer_name?: string[];
        product_ndc?: string[];
        substance_name?: string[];
        route?: string[];
        dosage_form?: string[];
      };
      purpose?: string[];
      warnings?: string[];
      adverse_reactions?: string[];
      drug_interactions?: string[];
      dosage_and_administration?: string[];
      clinical_pharmacology?: string[];
      effective_time: string;
    };
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. It states the action ('Search') and source ('FDA database'), but lacks details on permissions, rate limits, error handling, or response format. For a search tool with zero annotation coverage, this is insufficient to inform safe and effective use.

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's front-loaded with the core action and resource, making it easy 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 lack of annotations and output schema, the description is incomplete. It doesn't cover behavioral aspects like authentication needs or result structure, and with sibling tools present, it fails to provide differentiation. For a search tool in a medical context, more context is needed for reliable use.

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 input schema has 100% description coverage, fully documenting the 'query' and 'limit' parameters. The description adds no additional semantic context beyond what's in the schema, such as search syntax or result ordering. Baseline 3 is appropriate as the schema handles the heavy lifting.

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 ('Search for drug information') and the resource ('FDA database'), which is specific and unambiguous. However, it doesn't explicitly differentiate from sibling tools like 'search-drug-nomenclature' or 'search-medical-databases', which might also involve drug-related searches, leaving some room for confusion about scope.

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 like 'search-drug-nomenclature' or 'get-drug-details'. It mentions the FDA database as the source, but doesn't specify use cases, prerequisites, or exclusions, leaving the agent to infer usage from the name alone.

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