Skip to main content
Glama

lookup_icd_code

Retrieve ICD-10 codes by searching for a specific code or medical condition description. Supports customizable result limits for precise healthcare data lookup.

Instructions

Look up ICD-10 codes by code or description

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeNoICD-10 code to look up (optional if description is provided)
descriptionNoMedical condition description to search for (optional if code is provided)
max_resultsNoMaximum number of results to return

Implementation Reference

  • The primary handler function implementing the lookup_icd_code tool. It queries the Clinical Tables API for ICD-10 codes based on provided code or description, applies caching, validates inputs, and formats the response.
    async lookupICDCode(code = '', description = '', maxResults = 10) {
      // Either code or description must be provided
      if (!code && !description) {
        return this.formatErrorResponse('Either code or description is required');
      }
      
      // Validate max_results
      let validMaxResults;
      try {
        validMaxResults = parseInt(maxResults);
        if (validMaxResults < 1) {
          validMaxResults = 10;
        } else if (validMaxResults > 50) {
          validMaxResults = 50; // Limit to reasonable number
        }
      } catch (error) {
        validMaxResults = 10;
      }
      
      // Create cache key
      const cacheKey = this.getCacheKey('icd_code', code, description, validMaxResults);
      
      // Check cache first
      const cachedResult = this.cache.get(cacheKey);
      if (cachedResult) {
        console.error(`Cache hit for ICD-10 code lookup: ${code || description}`);
        return cachedResult;
      }
      
      try {
        console.error(`Looking up ICD-10 code for: code=${code}, description=${description}`);
        
        // Build query parameters
        const params = {
          sf: 'code,name',
          terms: code || description,
          maxList: validMaxResults
        };
        
        const url = this.buildUrl(this.baseUrl, params);
        
        // Make the request
        const data = await this.makeRequest(url);
        
        // Process the response
        let codes = [];
        let totalResults = 0;
        
        if (data && Array.isArray(data[3])) {
          codes = data[3].map(item => ({
            code: item[0] || '',
            description: item[1] || '',
            category: item[2] || ''
          }));
          totalResults = codes.length;
        }
        
        // Create result object
        const result = this.formatSuccessResponse({
          search_type: code ? 'code' : 'description',
          search_term: code || description,
          total_results: totalResults,
          codes: codes
        });
        
        // Cache for 24 hours (86400 seconds)
        this.cache.set(cacheKey, result, 86400);
        
        return result;
        
      } catch (error) {
        console.error(`Error looking up ICD-10 code: ${error.message}`);
        return this.formatErrorResponse(`Error looking up ICD-10 code: ${error.message}`);
      }
    }
  • The input schema definition for the lookup_icd_code tool as registered in the MCP server's tool list response.
    {
      name: "lookup_icd_code",
      description: "Look up ICD-10 codes by code or description",
      inputSchema: {
        type: "object",
        properties: {
          code: {
            type: "string",
            description: "ICD-10 code to look up (optional if description is provided)",
          },
          description: {
            type: "string",
            description: "Medical condition description to search for (optional if code is provided)",
          },
          max_results: {
            type: "number",
            description: "Maximum number of results to return",
            default: 10,
            minimum: 1,
            maximum: 50,
          },
        },
      },
    },
  • The registration/dispatch case in the MCP CallToolRequest handler that routes calls to the lookup_icd_code tool.
    case "lookup_icd_code":
      result = await medicalTerminologyTool.lookupICDCode(args.code, args.description, args.max_results);
      break;
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the lookup action but doesn't describe traits like whether it's read-only, requires authentication, has rate limits, returns structured data, or handles errors. For a tool with zero annotation coverage, this is a significant gap in transparency.

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, efficient sentence with zero waste. It's front-loaded with the core purpose and appropriately sized for a simple lookup tool, making it easy to parse quickly.

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?

Given the lack of annotations and output schema, the description is incomplete. It doesn't explain what the tool returns (e.g., code details, descriptions), behavioral aspects, or error handling. For a tool with 3 parameters and no structured output info, more context is needed to guide effective use.

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 schema description coverage is 100%, so the schema already documents all parameters (code, description, max_results) with details like optionality and constraints. The description adds no additional meaning beyond what the schema provides, such as explaining search logic or result format. Baseline 3 is appropriate when the schema does the heavy lifting.

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 tool's purpose: 'Look up ICD-10 codes by code or description.' It specifies the verb ('look up'), resource ('ICD-10 codes'), and two search methods. However, it doesn't explicitly distinguish this from sibling tools like 'health_topics' or 'pubmed_search', which might also involve medical information retrieval but for different resources.

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 sibling tools or clarify scenarios where this lookup is preferred over others (e.g., 'clinical_trials_search' for trial data). Usage is implied by the purpose but lacks explicit context or exclusions.

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

Related 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/Cicatriiz/healthcare-mcp-public'

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