rxnorm_classes
Retrieve therapeutic and pharmacologic classes for a drug by inputting its RxCUI. Returns class IDs, names, and classification sources.
Instructions
Get therapeutic and pharmacologic classes for a drug.
Use this tool to:
Find the drug class (e.g., "Beta-blockers", "NSAIDs")
Identify therapeutic categories
Look up mechanism of action classifications
Returns class IDs, names, and classification sources.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| rxcui | Yes | RxCUI of the drug |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| rxcui | Yes | ||
| classes | Yes |
Implementation Reference
- src/tools/rxnorm.ts:425-448 (handler)The main handler function for rxnorm_classes. Parses the rxcui parameter via RxNormByRxcuiParamsSchema, calls the RxNorm client's getDrugClasses method, maps results to RxNormClassesOutput structure, and returns both a formatted text response and structuredContent.
async function handleRxNormClasses(args: Record<string, unknown>): Promise<CallToolResult> { try { const params = RxNormByRxcuiParamsSchema.parse(args); const client = getRxNormClient(); const classes = await client.getDrugClasses(params.rxcui); const structured: RxNormClassesOutput = { rxcui: params.rxcui, classes: classes.map((c) => ({ class_id: c.classId, class_name: c.className, class_type: c.classType, source: c.source, })), }; return { content: [{ type: 'text', text: formatClasses(params.rxcui, classes) }], structuredContent: structured, }; } catch (error) { return handleToolError(error); } } - src/types/index.ts:332-342 (schema)RxNormClassesOutputSchema: Zod output schema for rxnorm_classes. Defines the response shape with rxcui and an array of classes (each with class_id, class_name, class_type, source). Also RxNormClassesOutput type (line 356).
export const RxNormClassesOutputSchema = z.object({ rxcui: z.string(), classes: z.array( z.object({ class_id: z.string(), class_name: z.string(), class_type: z.string(), source: z.string(), }), ), }); - src/types/index.ts:259-262 (schema)RxNormByRxcuiParamsSchema: The shared input schema used by rxnorm_classes (and rxnorm_ingredients). Takes a single 'rxcui' numeric string parameter.
/** Shared shape for rxnorm_ingredients / rxnorm_classes */ export const RxNormByRxcuiParamsSchema = z.object({ rxcui: RxCUISchema.describe('RxCUI of the drug'), }); - src/tools/rxnorm.ts:506-506 (registration)Tool registration - registers rxnormClassesTool (name: 'rxnorm_classes') with the toolRegistry, binding it to the handleRxNormClasses handler function.
toolRegistry.register(rxnormClassesTool, handleRxNormClasses); - src/tools/rxnorm.ts:232-252 (helper)formatClasses: Helper function that formats the drug class results into a human-readable Markdown table for the text response content.
function formatClasses(rxcui: string, classes: RxNormDrugClass[]): string { const lines: string[] = []; lines.push(`# Drug Classes for RxCUI ${rxcui}`); lines.push(''); if (classes.length === 0) { lines.push('No drug classes found for this concept.'); } else { lines.push(`Found ${classes.length} class(es):`); lines.push(''); lines.push('| Class ID | Class Name | Type | Source |'); lines.push('|----------|------------|------|--------|'); for (const cls of classes) { lines.push(`| ${cls.classId} | ${cls.className} | ${cls.classType} | ${cls.source || 'N/A'} |`); } } return lines.join('\n'); }