Skip to main content
Glama
RowanErasmus

DailyMed MCP Server

by RowanErasmus

get_drug_ndcs

Retrieve National Drug Code (NDC) identifiers for medications using their DailyMed SET ID to facilitate accurate drug identification and inventory management.

Instructions

Get NDC codes for a specific drug by its SET ID

Input Schema

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

Implementation Reference

  • The handler function `getSPLNDCs` in `SPLClient` class fetches NDC codes for a specific drug SET ID.
    async getSPLNDCs(setId: string): Promise<any[]> {
      if (!setId || typeof setId !== "string") {
        throw new Error("Valid SET ID is required");
      }
    
      try {
        const response = await this.client.get(`/spls/${setId}/ndcs.json`);
    
        if (
          response.data &&
          response.data.data &&
          Array.isArray(response.data.data)
        ) {
          return response.data.data.map((item: any) => ({
            ndc: item.ndc,
            packageNdc: item.package_ndc,
            productNdc: item.product_ndc,
          }));
        } else {
          throw new Error("Unexpected response structure for SPL NDCs");
        }
      } catch (error) {
        throw new Error(
          `Failed to fetch SPL NDCs: ${error instanceof Error ? error.message : "Unknown error"}`,
        );
      }
    }
  • src/index.ts:87-96 (registration)
    The tool "get_drug_ndcs" is registered and handled in `src/index.ts` within the `setupHandlers` method of the `DailyMedServer` class, delegating the call to the `DailyMedClient`.
    case "get_drug_ndcs":
      const ndcs = await this.client.getSPLNDCs(args.setId as string);
      return {
        content: [
          {
            type: "text",
            text: JSON.stringify(ndcs, null, 2),
          },
        ],
      };
  • The tool definition and input schema for "get_drug_ndcs" are defined in `src/tools.ts`.
      name: "get_drug_ndcs",
      description: "Get NDC codes for a specific drug by its SET ID",
      inputSchema: {
        type: "object",
        properties: {
          setId: {
            type: "string",
            description: "The SET ID of the drug to get NDCs for",
          },
        },
        required: ["setId"],
      },
    },

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