Skip to main content
Glama

atc_lookup

Read-onlyIdempotent

Resolve ATC codes (levels 1-4) to class names and hierarchy levels. Confirm code existence and identify anatomical, therapeutic, pharmacological, or chemical level.

Instructions

Look up an ATC code at level 1-4 to get its name and hierarchy level.

Use this tool to:

  • Resolve an ATC code (e.g., "A10BA") to its class name ("Biguanides")

  • Confirm a code exists in the current ATC index

  • Identify the level (anatomical / therapeutic / pharmacological / chemical)

Accepts codes 1-5 characters long: "A" (anatomical), "A10" (therapeutic), "A10B" (pharmacological), "A10BA" (chemical). Substance-level codes (7 chars, e.g., "A10BA02") are not exposed by this endpoint — use atc_classify with the drug name to retrieve the substance code.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
atc_codeYesATC code at level 1-4 (1-5 chars). Substance-level codes (7 chars, e.g., A10BA02) are not exposed by this endpoint — use atc_classify with the drug name instead.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
atc_codeYes
foundYes
detailsYes

Implementation Reference

  • The main handler function for the atc_lookup tool. Parses input (ATC code), calls the RxNorm client's getATCByCode, builds structured output, and returns formatted text.
    async function handleATCLookup(args: Record<string, unknown>): Promise<CallToolResult> {
      try {
        const params = ATCByCodeParamsSchema.parse(args);
        const client = getRxNormClient();
        const details = await client.getATCByCode(params.atc_code);
    
        const structured: ATCLookupOutput = {
          atc_code: params.atc_code,
          found: details !== null,
          details,
        };
    
        if (!details) {
          return {
            content: [
              {
                type: 'text',
                text: `# ATC code "${params.atc_code}" not found at level 1-4.\n\nIf this is a 7-character substance code (e.g., "A10BA02"), use atc_classify with the drug name instead — RxClass byId only exposes ATC1-4 codes.`,
              },
            ],
            structuredContent: structured,
          };
        }
    
        const lines: string[] = [
          `# ATC ${details.atc_code} — ${details.atc_name}`,
          '',
          `**Level:** ${details.atc_level_type}`,
        ];
    
        return {
          content: [{ type: 'text', text: lines.join('\n') }],
          structuredContent: structured,
        };
      } catch (error) {
        return handleToolError(error);
      }
    }
  • The client-side implementation that calls the NLM RxClass byId API endpoint to resolve an ATC code (level 1-4) to its name and level type. Uses caching.
    async getATCByCode(atcCode: string): Promise<RxNormATCClass | null> {
      const cacheKey = `atc:bycode:${atcCode.toUpperCase()}`;
    
      return cache.getOrSet(
        CACHE_PREFIX.RXNORM,
        cacheKey,
        async () => {
          try {
            const response = await this.request<RxClassByIdResponse>(
              '/rxclass/class/byId.json',
              { classId: atcCode },
            );
            const item = response.rxclassMinConceptList?.rxclassMinConcept?.[0];
            if (!item) return null;
            return {
              atc_code: item.classId,
              atc_name: item.className,
              atc_level_type: item.classType,
            };
          } catch (error) {
            if (error instanceof ApiError && error.code === 'NOT_FOUND') {
              return null;
            }
            throw error;
          }
        },
        DEFAULT_TTL.LOOKUP,
      );
    }
  • Input schema (ATCByCodeParamsSchema) for atc_lookup — validates the atc_code parameter as a 1-5 character ATC code via regex.
    export const ATCByCodeParamsSchema = z.object({
      atc_code: ATCCodeSchema.describe(
        'ATC code at level 1-4 (1-5 chars). Substance-level codes (7 chars, e.g., A10BA02) are not exposed by this endpoint — use atc_classify with the drug name instead.',
      ),
    });
  • Output schema (ATCLookupOutputSchema) defining the structured response shape: atc_code, found boolean, and nullable details.
    export const ATCLookupOutputSchema = z.object({
      atc_code: z.string(),
      found: z.boolean(),
      // Populated when found=true. Null when the code is unknown or
      // substance-level (RxClass byId doesn't expose the 7-char codes).
      details: ATCClassEntrySchema.nullable(),
    });
  • Registration of atc_lookup tool: toolRegistry.register(atcLookupTool, handleATCLookup) binds the tool definition to its handler.
    toolRegistry.register(atcLookupTool, handleATCLookup);
Behavior4/5

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

Annotations already declare readOnlyHint, destructiveHint, idempotentHint, and openWorldHint. The description adds value by detailing the output (name and hierarchy level) and input constraints (code lengths), without contradicting annotations.

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 concise and well-structured, with the main purpose in the first sentence followed by bullet points. Every sentence adds value with no redundancy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple tool with one parameter and an output schema, the description covers all essential aspects: purpose, input format, output details, and boundary conditions. It even directs to sibling tools for off-scope queries.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Input schema coverage is 100%, but the description adds extra meaning by explaining the hierarchical coding levels with examples (e.g., 'A' anatomical, 'A10' therapeutic). This goes beyond the schema's pattern and description.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool resolves an ATC code to its name and hierarchy level, with explicit examples and use cases. It effectively distinguishes from sibling tools like atc_classify and atc_members.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides explicit bullet points on when to use the tool, and importantly tells users when not to use it (substance-level codes) and directs them to an alternative (atc_classify). This is excellent guidance.

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/SidneyBissoli/medical-terminologies-mcp'

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