Skip to main content
Glama

get-drug-details

Retrieve comprehensive drug information using National Drug Code (NDC) to access detailed medication data from FDA, WHO, and medical databases.

Instructions

Get detailed information about a specific drug by NDC (National Drug Code)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
ndcYesNational Drug Code (NDC) of the drug

Implementation Reference

  • src/index.ts:69-83 (registration)
    Registers the 'get-drug-details' MCP tool, defines input schema (NDC string), and provides inline handler that fetches data via getDrugByNDC and formats it.
    server.tool( "get-drug-details", "Get detailed information about a specific drug by NDC (National Drug Code)", { ndc: z.string().describe("National Drug Code (NDC) of the drug"), }, async ({ ndc }) => { try { const drug = await getDrugByNDC(ndc); return formatDrugDetails(drug, ndc); } catch (error: any) { return createErrorResponse("fetching drug details", error); } }, );
  • Core handler function that queries the FDA drug label API by product NDC code to retrieve detailed drug information.
    export async function getDrugByNDC(ndc: string): Promise<DrugLabel | null> { try { const res = await superagent .get(`${FDA_API_BASE}/drug/label.json`) .query({ search: `openfda.product_ndc:${ndc}`, limit: 1, }) .set("User-Agent", USER_AGENT); return res.body.results?.[0] || null; } catch (error) { return null; } }
  • Zod input schema defining the required 'ndc' parameter as a string.
    { ndc: z.string().describe("National Drug Code (NDC) of the drug"), },
  • TypeScript interface defining the structure of FDA DrugLabel data used by the tool.
    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; };
  • Helper function that formats the raw FDA drug data into a user-friendly MCP response with sections for basic info, purpose, warnings, and interactions.
    export function formatDrugDetails(drug: any, ndc: string) { if (!drug) { return createMCPResponse(`No drug found with NDC: ${ndc}`); } let result = `**Drug Details for NDC: ${ndc}**\n\n`; result += `**Basic Information:**\n`; result += `- Brand Name: ${drug.openfda.brand_name?.[0] || "Not specified"}\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`; result += `- Last Updated: ${drug.effective_time}\n\n`; if (drug.purpose && drug.purpose.length > 0) { result += `**Purpose/Uses:**\n`; drug.purpose.forEach((purpose: string, index: number) => { result += `${index + 1}. ${purpose}\n`; }); result += "\n"; } if (drug.warnings && drug.warnings.length > 0) { result += `**Warnings:**\n`; drug.warnings.forEach((warning: string, index: number) => { result += `${index + 1}. ${warning.substring(0, 300)}${warning.length > 300 ? "..." : ""}\n`; }); result += "\n"; } if (drug.drug_interactions && drug.drug_interactions.length > 0) { result += `**Drug Interactions:**\n`; drug.drug_interactions.forEach((interaction: string, index: number) => { result += `${index + 1}. ${interaction.substring(0, 300)}${interaction.length > 300 ? "..." : ""}\n`; }); result += "\n"; } return createMCPResponse(result); }

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