Skip to main content
Glama
backworkai
by backworkai

lookup_code

Look up medical codes (CPT, HCPCS, ICD-10, NDC) to get descriptions, RVU values, and Medicare coverage policies for billing and compliance verification.

Instructions

Look up a medical code (CPT, HCPCS, ICD-10, or NDC) and get coverage information. Returns code details, descriptions, RVU values, and related Medicare policies. Use this to understand what a code means and whether it's covered.

Examples:

  • lookup_code("76942") - ultrasound guidance

  • lookup_code("J0585") - Botox injection

  • lookup_code("M54.5") - low back pain diagnosis

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYesThe medical code to look up (e.g., 76942, J0585, M54.5)
code_systemNoCode system hint - auto-detected if not provided
jurisdictionNoMAC jurisdiction code to filter policies (e.g., JM, JH)
includeNoAdditional data: 'rvu', 'policies', or 'rvu,policies'
fuzzyNoEnable fuzzy matching for typos/partial codes

Implementation Reference

  • The asynchronous handler function that executes the lookup_code tool. It makes an API request to Verity's /codes/lookup endpoint, handles the response, formats it using formatCode, and returns structured content or error messages.
      async ({ code, code_system, jurisdiction, include, fuzzy }) => {
        try {
          const result = await verityRequest<any>("/codes/lookup", {
            params: {
              code,
              code_system,
              jurisdiction,
              include: include || "rvu,policies",
              fuzzy: fuzzy ? "true" : "false",
            },
          });
    
          if (!result.data.found && (!result.data.suggestions || result.data.suggestions.length === 0)) {
            return {
              content: [
                {
                  type: "text",
                  text: `Code "${code}" not found. Try:\n- Check spelling\n- Use a different code system\n- Search for the procedure name using search_policies`,
                },
              ],
            };
          }
    
          return {
            content: [{ type: "text", text: formatCode(result.data) }],
          };
        } catch (error) {
          return {
            content: [{ type: "text", text: `Error looking up code: ${error instanceof Error ? error.message : String(error)}` }],
          };
        }
      }
    );
  • Zod input schema defining the parameters for the lookup_code tool: code (required), code_system (optional enum), jurisdiction (optional), include (optional), fuzzy (optional boolean).
    inputSchema: {
      code: z.string().min(1).max(20).describe("The medical code to look up (e.g., 76942, J0585, M54.5)"),
      code_system: z
        .enum(["CPT", "HCPCS", "ICD10CM", "ICD10PCS", "NDC"])
        .optional()
        .describe("Code system hint - auto-detected if not provided"),
      jurisdiction: z.string().max(10).optional().describe("MAC jurisdiction code to filter policies (e.g., JM, JH)"),
      include: z.string().optional().describe("Additional data: 'rvu', 'policies', or 'rvu,policies'"),
      fuzzy: z.boolean().default(true).describe("Enable fuzzy matching for typos/partial codes"),
    },
  • src/index.ts:231-233 (registration)
    Registration of the 'lookup_code' tool on the MCP server using server.registerTool, including description, inputSchema, and handler function.
    // 1. lookup_code - Look up medical codes
    server.registerTool(
      "lookup_code",
  • Helper function formatCode used by the lookup_code handler to format the API response into a readable string, including code details, RVU data, related policies, and suggestions.
    function formatCode(code: any): string {
      const lines: string[] = [];
      lines.push(`Code: ${code.code} (${code.code_system})`);
      if (code.description) lines.push(`Description: ${code.description}`);
      if (code.short_description) lines.push(`Short: ${code.short_description}`);
      if (code.category) lines.push(`Category: ${code.category}`);
      if (code.is_active !== undefined) lines.push(`Active: ${code.is_active ? "Yes" : "No"}`);
    
      if (code.rvu) {
        lines.push("\nRVU Data:");
        if (code.rvu.work_rvu) lines.push(`  Work RVU: ${code.rvu.work_rvu}`);
        if (code.rvu.total_rvu_facility) lines.push(`  Total RVU (Facility): ${code.rvu.total_rvu_facility}`);
        if (code.rvu.total_rvu_nonfacility) lines.push(`  Total RVU (Non-Facility): ${code.rvu.total_rvu_nonfacility}`);
        if (code.rvu.facility_price) lines.push(`  Facility Price: $${code.rvu.facility_price}`);
        if (code.rvu.non_facility_price) lines.push(`  Non-Facility Price: $${code.rvu.non_facility_price}`);
        if (code.rvu.global_days) lines.push(`  Global Days: ${code.rvu.global_days}`);
      }
    
      if (code.policies && code.policies.length > 0) {
        lines.push("\nRelated Policies:");
        code.policies.forEach((p: any) => {
          lines.push(`  - ${p.policy_id}: ${p.title}`);
          lines.push(`    Type: ${p.policy_type}, Disposition: ${p.disposition}`);
          if (p.jurisdiction) lines.push(`    Jurisdiction: ${p.jurisdiction}`);
        });
      }
    
      if (code.suggestions && code.suggestions.length > 0) {
        lines.push("\nSuggested Codes:");
        code.suggestions.slice(0, 5).forEach((s: any) => {
          lines.push(`  - ${s.code} (${s.code_system}): ${s.description || "No description"}`);
          lines.push(`    Match: ${s.match_type}, Score: ${(s.score * 100).toFixed(0)}%`);
        });
      }
    
      return lines.join("\n");
    }
Behavior3/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It does well by stating what the tool returns (code details, descriptions, RVU values, Medicare policies) and providing concrete examples. However, it doesn't mention important behavioral aspects like rate limits, authentication requirements, error handling, or whether this is a read-only operation (though implied by 'look up').

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 perfectly structured: a clear purpose statement, followed by what it returns, then usage guidance, and finally concrete examples. Every sentence adds value with zero waste. The examples are relevant and illustrative without being verbose.

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

Completeness4/5

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

For a tool with 5 parameters, 100% schema coverage, but no annotations or output schema, the description does quite well. It explains the tool's purpose, what it returns, and when to use it. The examples provide concrete usage patterns. The main gap is the lack of output format details (since no output schema exists), but the description compensates by listing the types of information returned.

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%, so the schema already fully documents all 5 parameters. The description adds minimal parameter semantics beyond the schema - it mentions the types of codes (CPT, HCPCS, ICD-10, NDC) which aligns with the code_system enum, and the examples show code formats. This meets the baseline of 3 when schema coverage is high.

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's purpose: 'Look up a medical code... and get coverage information.' It specifies the exact action (look up), resource (medical codes), and output (coverage info, code details, descriptions, RVU values, Medicare policies). The examples reinforce this by showing specific code lookups, distinguishing it from sibling tools like check_prior_auth or search_policies.

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 provides clear context for when to use this tool: 'Use this to understand what a code means and whether it's covered.' This gives practical guidance on its primary use case. However, it doesn't explicitly mention when NOT to use it or name specific alternatives among the sibling tools, which prevents a perfect score.

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/backworkai/verity_mcp'

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