Skip to main content
Glama

search-drug-nomenclature

Find standardized drug information using RxNorm database to identify correct medication names, dosages, and formulations for accurate prescribing and record-keeping.

Instructions

Search for drug information using RxNorm (standardized drug nomenclature)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesDrug name to search for in RxNorm database

Implementation Reference

  • Main handler function that performs the actual API call to RxNorm database to search for drugs by name and returns standardized drug nomenclature data.
    export async function searchRxNormDrugs(query: string): Promise<RxNormDrug[]> { try { const res = await superagent .get(`${RXNAV_API_BASE}/drugs.json`) .query({ name: query }) .set("User-Agent", USER_AGENT); const drugGroup = res.body.drugGroup; if (!drugGroup || !drugGroup.conceptGroup) { return []; } // Find concept groups that have conceptProperties const results: RxNormDrug[] = []; for (const conceptGroup of drugGroup.conceptGroup) { if ( conceptGroup.conceptProperties && Array.isArray(conceptGroup.conceptProperties) ) { for (const concept of conceptGroup.conceptProperties) { // Transform the API response to match our RxNormDrug type results.push({ rxcui: concept.rxcui || "", name: concept.name || "", synonym: concept.synonym ? Array.isArray(concept.synonym) ? concept.synonym : [concept.synonym] : [], tty: concept.tty || "", language: concept.language || "", suppress: concept.suppress || "", umlscui: concept.umlscui ? Array.isArray(concept.umlscui) ? concept.umlscui : [concept.umlscui] : [], }); } } } return results; } catch (error) { console.error("Error searching RxNorm drugs:", error); return []; } }
  • src/index.ts:157-171 (registration)
    MCP tool registration including input schema (query string) and handler that delegates to searchRxNormDrugs and formatRxNormDrugs functions.
    server.tool( "search-drug-nomenclature", "Search for drug information using RxNorm (standardized drug nomenclature)", { query: z.string().describe("Drug name to search for in RxNorm database"), }, async ({ query }) => { try { const drugs = await searchRxNormDrugs(query); return formatRxNormDrugs(drugs, query); } catch (error: any) { return createErrorResponse("searching RxNorm", error); } }, );
  • Helper function that formats the RxNorm search results into a readable MCP response.
    export function formatRxNormDrugs(drugs: any[], query: string) { if (drugs.length === 0) { return createMCPResponse( `No drugs found in RxNorm database for "${query}". Try a different search term.`, ); } let result = `**RxNorm Drug Search: "${query}"**\n\n`; result += `Found ${drugs.length} drug(s)\n\n`; drugs.forEach((drug, index) => { result += `${index + 1}. **${drug.name}**\n`; result += ` RxCUI: ${drug.rxcui}\n`; result += ` Term Type: ${drug.tty}\n`; result += ` Language: ${drug.language}\n`; if (drug.synonym && drug.synonym.length > 0) { result += ` Synonyms: ${drug.synonym.slice(0, 3).join(", ")}${drug.synonym.length > 3 ? "..." : ""}\n`; } result += "\n"; }); return createMCPResponse(result); }
  • TypeScript type definition for RxNormDrug, defining the structure of the output data from the search.
    export type RxNormDrug = { rxcui: string; name: string; synonym: string[]; tty: string; language: string; suppress: string; umlscui: string[]; };
  • API base URL constant used by the search handler for RxNorm queries.
    export const RXNAV_API_BASE = "https://rxnav.nlm.nih.gov/REST";

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