Skip to main content
Glama
RowanErasmus

DailyMed MCP Server

by RowanErasmus

get_drug_details

Retrieve comprehensive drug information from the FDA DailyMed database using a SET ID, including labels, NDC codes, RxNorm mappings, and pharmacologic classifications.

Instructions

Get detailed information about a specific drug by its SET ID

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
setIdYesThe SET ID of the drug to get details for

Implementation Reference

  • The handler logic for 'get_drug_details' (implemented as `getSPLBySetId` in `SPLClient`).
    async getSPLBySetId(setId: string): Promise<SPLDocument> {
      if (!setId || typeof setId !== "string") {
        throw new Error("Valid SET ID is required");
      }
    
      return new Promise((resolve, reject) => {
        this.client
          .get(`/spls/${setId}.xml`)
          .then((response) => {
            parseString(response.data, (err, result) => {
              if (err) {
                reject(new Error(`Failed to parse XML: ${err.message}`));
                return;
              }
    
              try {
                // Extract basic information
                const document = result?.document;
                if (!document) {
                  throw new Error("Invalid SPL document structure");
                }
    
                const title = extractTextContent(document.title) || "No title available";
                const effectiveTime = document.effectiveTime?.[0]?.$?.value || "Unknown";
                const versionNumber = document.versionNumber?.[0]?.$?.value || "1";
    
                // Extract sections
                const sections: SPLSection[] = [];
                const component = document.component?.[0];
                if (component?.structuredBody?.[0]?.component) {
                  const bodyComponents = component.structuredBody[0].component;
                  for (const comp of bodyComponents) {
                    const section = comp.section?.[0];
                    if (section) {
                      const sectionTitle = extractTextContent(section.title) || "Untitled Section";
                      
                      let content = "";
                      if (section.text?.[0]) {
                        const textElement = section.text[0];
                        
                        // Handle different content types
                        if (textElement.paragraph) {
                          content = textElement.paragraph.map((p: any) => extractTextContent(p)).join("\n\n");
                        } else if (textElement.list) {
                          content = textElement.list.map((list: any) => {
                            if (list.item) {
                              return extractListContent(list.item);
                            }
                            return "";
                          }).join("\n\n");
                        } else if (textElement.table) {
                          content = textElement.table.map((table: any) => extractTableContent(table)).join("\n\n");
                        } else {
                          content = extractTextContent(textElement);
                        }
                      }
                      
                      if (content.trim()) {
                        sections.push({
                          id: section.id?.[0]?.$?.root,
                          title: sectionTitle,
                          content: content.trim(),
                        });
                      }
                    }
                  }
                }
    
                // Get mapping data for this setId
                const rxNormMappings = this.mappingService.getRxNormMappings(setId);
                const pharmacologicClassMappings = this.mappingService.getPharmacologicClassMappings(setId);
    
                // Filter out redundant fields from mappings
                const filteredRxNormMappings = rxNormMappings.map(mapping => ({
                  rxcui: mapping.rxcui,
                  rxstring: mapping.rxstring,
                  rxtty: mapping.rxtty,
                }));
    
                const filteredPharmacologicClassMappings = pharmacologicClassMappings.map(mapping => ({
                  pharmaSetId: mapping.pharmaSetId,
                  pharmaVersion: mapping.pharmaVersion,
                }));
    
                resolve({
                  setId: setId,
                  title: title || "No title available",
                  effectiveTime: effectiveTime,
                  versionNumber: versionNumber,
                  sections: sections,
                  spl_medguide: undefined,
                  spl_patient_package_insert: undefined,
                  spl_product_data_elements: undefined,
                  rxNormMappings: filteredRxNormMappings.length > 0 ? filteredRxNormMappings : undefined,
                  pharmacologicClassMappings: filteredPharmacologicClassMappings.length > 0 ? filteredPharmacologicClassMappings : undefined,
                });
              } catch (parseError) {
                reject(
                  new Error(
                    `Failed to extract data from XML: ${parseError instanceof Error ? parseError.message : "Unknown error"}`,
                  ),
                );
              }
            });
          })
          .catch((error) => {
            reject(
              new Error(
                `Failed to fetch SPL: ${error instanceof Error ? error.message : "Unknown error"}`,
              ),
            );
          });
      });
    }
  • src/tools.ts:12-25 (registration)
    Registration of the 'get_drug_details' tool in `src/tools.ts`.
    {
      name: "get_drug_details",
      description: "Get detailed information about a specific drug by its SET ID",
      inputSchema: {
        type: "object",
        properties: {
          setId: {
            type: "string",
            description: "The SET ID of the drug to get details for",
          },
        },
        required: ["setId"],
      },
    },
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries full burden but only states it 'gets' information, implying a read-only operation. It lacks details on permissions, rate limits, response format, or error handling, leaving significant behavioral gaps for an agent to understand.

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, direct sentence with no wasted words, efficiently stating the purpose. It's appropriately sized for a simple tool and front-loaded with the core action.

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?

For a tool with no annotations and no output schema, the description is incomplete. It doesn't explain what 'detailed information' includes, the response structure, or potential errors, making it inadequate for an agent to fully utilize the tool.

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 description adds minimal semantics by specifying the parameter is a SET ID for the drug, but the input schema already has 100% coverage with a clear description. No additional details like format or examples are provided, so it meets the baseline for high schema coverage.

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 verb 'Get' and resource 'detailed information about a specific drug', specifying it's by SET ID. It distinguishes from siblings like 'get_all_drug_names' or 'search_drugs_by_pharmacologic_class' by focusing on details for a single drug, though it doesn't explicitly contrast them.

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. It doesn't mention prerequisites, such as needing a SET ID from another tool, or compare it to siblings like 'get_drug_history' or 'get_drug_ndcs' that might offer different details.

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/RowanErasmus/dailymed-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server