rxnorm_ingredients
Identify the active ingredients in a medication by providing its RxCUI. Returns ingredient names and RxCUIs for single or multi-ingredient drugs.
Instructions
Get active ingredients for a drug by RxCUI.
Use this tool to:
Find the active ingredients in a medication
Check for single vs. multiple ingredient products
Identify the generic components of brand drugs
Returns ingredient RxCUIs and names.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| rxcui | Yes | RxCUI of the drug |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| rxcui | Yes | ||
| ingredients | Yes |
Implementation Reference
- src/tools/rxnorm.ts:400-423 (handler)Main handler function for rxnorm_ingredients. Parses params using RxNormByRxcuiParamsSchema, calls client.getIngredients(), and returns both a text-formatted response and structured data (RxNormIngredientsOutput).
async function handleRxNormIngredients(args: Record<string, unknown>): Promise<CallToolResult> { try { const params = RxNormByRxcuiParamsSchema.parse(args); const client = getRxNormClient(); const ingredients = await client.getIngredients(params.rxcui); const structured: RxNormIngredientsOutput = { rxcui: params.rxcui, ingredients: ingredients.map((ing) => ({ rxcui: ing.rxcui, name: ing.name, tty: ing.tty, is_multiple: ing.isMultiple, })), }; return { content: [{ type: 'text', text: formatIngredients(params.rxcui, ingredients) }], structuredContent: structured, }; } catch (error) { return handleToolError(error); } } - src/tools/rxnorm.ts:503-507 (registration)Registration of rxnormIngredientsTool and its handler (handleRxNormIngredients) via toolRegistry.register().
toolRegistry.register(rxnormSearchTool, handleRxNormSearch); toolRegistry.register(rxnormConceptTool, handleRxNormConcept); toolRegistry.register(rxnormIngredientsTool, handleRxNormIngredients); toolRegistry.register(rxnormClassesTool, handleRxNormClasses); toolRegistry.register(rxnormNDCTool, handleRxNormNDC); - src/types/index.ts:320-330 (schema)Output schema (RxNormIngredientsOutputSchema): defines the structured shape with rxcui and an array of ingredients (each having rxcui, name, tty, is_multiple).
export const RxNormIngredientsOutputSchema = z.object({ rxcui: z.string(), ingredients: z.array( z.object({ rxcui: z.string(), name: z.string(), tty: z.string(), is_multiple: z.boolean(), }), ), }); - src/types/index.ts:259-262 (schema)Input schema (RxNormByRxcuiParamsSchema): accepts a single 'rxcui' parameter.
/** Shared shape for rxnorm_ingredients / rxnorm_classes */ export const RxNormByRxcuiParamsSchema = z.object({ rxcui: RxCUISchema.describe('RxCUI of the drug'), }); - src/tools/rxnorm.ts:205-230 (helper)Helper function formatIngredients() that renders the ingredients data as a Markdown table for text output.
function formatIngredients(rxcui: string, ingredients: RxNormIngredient[]): string { const lines: string[] = []; lines.push(`# Ingredients for RxCUI ${rxcui}`); lines.push(''); if (ingredients.length === 0) { lines.push('No ingredients found for this concept.'); lines.push(''); lines.push('This may mean:'); lines.push('- The RxCUI is already an ingredient'); lines.push('- The concept does not have defined ingredients'); } else { lines.push(`Found ${ingredients.length} ingredient(s):`); lines.push(''); lines.push('| RxCUI | Name | Type |'); lines.push('|-------|------|------|'); for (const ing of ingredients) { const type = ing.isMultiple ? 'Multiple Ingredient' : 'Single Ingredient'; lines.push(`| ${ing.rxcui} | ${ing.name} | ${type} |`); } } return lines.join('\n'); }