Skip to main content
Glama

loinc_answers

Read-onlyIdempotent

Retrieve the list of valid answers and response codes for any LOINC questionnaire item. Use for data entry validation and standardized answer lookup.

Instructions

Get the list of valid answers for a LOINC questionnaire item.

Use this tool to:

  • Find valid response options for survey questions

  • Get answer codes for data entry validation

  • Look up standardized answer lists

Only applicable to LOINC codes that represent questions with defined answer sets.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
loinc_numYesLOINC number (e.g., "2339-0")

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
loinc_numYes
answersYes

Implementation Reference

  • Handler function for the loinc_answers tool. Parses LOINC number from args, calls NLM client to get answers, then returns formatted text and structured output.
    async function handleLOINCAnswers(args: Record<string, unknown>): Promise<CallToolResult> {
      try {
        const params = LOINCByCodeParamsSchema.parse(args);
        const client = getNLMClient();
        const answers = await client.getLOINCAnswers(params.loinc_num);
    
        const structured: LOINCAnswersOutput = {
          loinc_num: params.loinc_num,
          answers: answers.map((a) => ({
            sequence: a.sequence,
            answer_code: a.answerCode,
            answer_string: a.answerString,
          })),
        };
    
        return {
          content: [{ type: 'text', text: formatLOINCAnswers(params.loinc_num, answers) }],
          structuredContent: structured,
        };
      } catch (error) {
        return handleToolError(error);
      }
    }
  • Zod output schema defining the shape of structured output for loinc_answers tool (loinc_num + array of answer objects).
    export const LOINCAnswersOutputSchema = z.object({
      loinc_num: z.string(),
      answers: z.array(
        z.object({
          sequence: z.number().int(),
          answer_code: z.string(),
          answer_string: z.string(),
        }),
      ),
    });
  • TypeScript type inferred from LOINCAnswersOutputSchema.
    export type LOINCAnswersOutput = z.infer<typeof LOINCAnswersOutputSchema>;
  • Registration of the loinc_answers tool with the tool registry, linking the tool definition to its handler.
    toolRegistry.register(loincAnswersTool, handleLOINCAnswers);
    toolRegistry.register(loincPanelsTool, handleLOINCPanels);
  • Helper function that formats LOINC answers into a human-readable markdown table.
    function formatLOINCAnswers(loincNum: string, answers: LOINCAnswer[]): string {
      const lines: string[] = [];
    
      lines.push(`# Answers for ${loincNum}`);
      lines.push('');
    
      if (answers.length === 0) {
        lines.push('No predefined answers available for this LOINC code.');
        lines.push('');
        lines.push('This may mean:');
        lines.push('- The code represents a numeric measurement (not a questionnaire)');
        lines.push('- The code has free-text responses');
        lines.push('- Answer list is not defined in LOINC');
      } else {
        lines.push(`Found ${answers.length} answer(s):`);
        lines.push('');
        lines.push('| # | Code | Answer |');
        lines.push('|---|------|--------|');
    
        for (const answer of answers) {
          lines.push(`| ${answer.sequence} | ${answer.answerCode} | ${answer.answerString} |`);
        }
      }
    
      return lines.join('\n');
    }
Behavior3/5

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

Annotations already indicate readOnly, idempotent, and non-destructive. The description adds that it returns a list of valid answers but doesn't detail output structure or any additional behaviors. Given annotations, this is adequate but not enriched.

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: two sentences plus bullet points. It is front-loaded with the main purpose, and every sentence adds value without 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 single-parameter, read-only tool with an output schema, the description covers what it does, use cases, and a constraint. The output schema handles return values. It is complete for the tool's complexity.

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?

Schema description coverage is 100% with a clear pattern and example. The description doesn't add new parameter info beyond implying the LOINC code must be a question with answer sets, which is not a parameter semantic but a usage condition. Baseline 3 is appropriate.

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 it gets the list of valid answers for a LOINC questionnaire item and lists specific use cases. It is differentiated from sibling tools like loinc_details (general info) and loinc_panels (panel structure).

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

Usage Guidelines4/5

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

The description gives clear usage contexts (finding response options, data entry validation, standardized answer lists) and a condition ('Only applicable to LOINC codes that represent questions with defined answer sets'). It does not explicitly exclude or mention alternatives, but the context is sufficient.

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