Skip to main content
Glama
backworkai
by backworkai

check_prior_auth

Determine Medicare prior authorization requirements for medical procedures by checking CPT/HCPCS codes against coverage policies and providing documentation checklists.

Instructions

Check if procedures require prior authorization for Medicare. Returns PA requirement, confidence level, matched LCD/NCD policies, and documentation checklist. Essential for determining Medicare coverage requirements before procedures.

Examples:

  • check_prior_auth(["76942"]) - check PA for ultrasound guidance

  • check_prior_auth(["76942"], { state: "TX" }) - check for Texas patient (determines MAC jurisdiction)

  • check_prior_auth(["J0585", "64493"]) - check multiple procedure codes

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
procedure_codesYesCPT/HCPCS codes to check (1-10 codes)
stateNoTwo-letter state code to determine MAC jurisdiction (e.g., TX, CA)

Implementation Reference

  • The tool handler function. Destructures input parameters procedure_codes and optional state, sends POST request to Verity API /prior-auth/check, formats response with formatPriorAuth, returns formatted text content or error message.
    async ({ procedure_codes, state }) => {
      try {
        const result = await verityRequest<any>("/prior-auth/check", {
          method: "POST",
          body: { procedure_codes, state },
        });
    
        return {
          content: [{ type: "text", text: formatPriorAuth(result.data) }],
        };
      } catch (error) {
        return {
          content: [{ type: "text", text: `Error checking prior auth: ${error instanceof Error ? error.message : String(error)}` }],
        };
      }
    }
  • Input schema using Zod validation: array of 1-10 procedure codes (required), optional 2-letter state code.
    inputSchema: {
      procedure_codes: z
        .array(z.string())
        .min(1)
        .max(10)
        .describe("CPT/HCPCS codes to check (1-10 codes)"),
      state: z
        .string()
        .length(2)
        .optional()
        .describe("Two-letter state code to determine MAC jurisdiction (e.g., TX, CA)"),
    },
  • src/index.ts:653-693 (registration)
    MCP server tool registration call including name, description, input schema, and inline handler function.
    server.registerTool(
      "check_prior_auth",
      {
        description: `Check if procedures require prior authorization for Medicare.
    Returns PA requirement, confidence level, matched LCD/NCD policies, and documentation checklist.
    Essential for determining Medicare coverage requirements before procedures.
    
    Examples:
    - check_prior_auth(["76942"]) - check PA for ultrasound guidance
    - check_prior_auth(["76942"], { state: "TX" }) - check for Texas patient (determines MAC jurisdiction)
    - check_prior_auth(["J0585", "64493"]) - check multiple procedure codes`,
        inputSchema: {
          procedure_codes: z
            .array(z.string())
            .min(1)
            .max(10)
            .describe("CPT/HCPCS codes to check (1-10 codes)"),
          state: z
            .string()
            .length(2)
            .optional()
            .describe("Two-letter state code to determine MAC jurisdiction (e.g., TX, CA)"),
        },
      },
      async ({ procedure_codes, state }) => {
        try {
          const result = await verityRequest<any>("/prior-auth/check", {
            method: "POST",
            body: { procedure_codes, state },
          });
    
          return {
            content: [{ type: "text", text: formatPriorAuth(result.data) }],
          };
        } catch (error) {
          return {
            content: [{ type: "text", text: `Error checking prior auth: ${error instanceof Error ? error.message : String(error)}` }],
          };
        }
      }
    );
  • Helper function to format the prior authorization check API response into a human-readable string, including PA requirement, confidence, reason, MAC info, matched policies, documentation checklist, and criteria summaries.
    function formatPriorAuth(result: any): string {
      const lines: string[] = [];
    
      // Main determination
      lines.push(`Prior Authorization Required: ${result.pa_required ? "YES" : "NO"}`);
      lines.push(`Confidence: ${result.confidence.toUpperCase()}`);
      lines.push(`Reason: ${result.reason}`);
    
      // MAC info
      if (result.mac) {
        lines.push(`\nMAC: ${result.mac.name} (${result.mac.jurisdiction})`);
        if (result.mac.states) lines.push(`States: ${result.mac.states.join(", ")}`);
      }
    
      // Matched policies
      if (result.matched_policies?.length > 0) {
        lines.push("\n--- Matched Policies ---");
        result.matched_policies.forEach((p: any) => {
          lines.push(`\n${p.policy_id}: ${p.title}`);
          lines.push(`Type: ${p.policy_type}${p.jurisdiction ? ` | Jurisdiction: ${p.jurisdiction}` : ""}`);
          if (p.codes?.length > 0) {
            lines.push("Codes:");
            p.codes.forEach((c: any) => {
              lines.push(`  - ${c.code} (${c.code_system}): ${c.disposition}`);
            });
          }
        });
      }
    
      // Documentation checklist
      if (result.documentation_checklist?.length > 0) {
        lines.push("\n--- Documentation Checklist ---");
        result.documentation_checklist.forEach((item: string, i: number) => {
          lines.push(`${i + 1}. ${item}`);
        });
      }
    
      // Criteria details
      if (result.criteria_details) {
        const cd = result.criteria_details;
        if (cd.indications?.length > 0) {
          lines.push("\n--- Indications ---");
          cd.indications.slice(0, 5).forEach((ind: any) => {
            lines.push(`- ${ind.text.slice(0, 200)}${ind.text.length > 200 ? "..." : ""}`);
          });
          if (cd.pagination?.indications?.total > 5) {
            lines.push(`... and ${cd.pagination.indications.total - 5} more indications`);
          }
        }
    
        if (cd.limitations?.length > 0) {
          lines.push("\n--- Limitations ---");
          cd.limitations.slice(0, 5).forEach((lim: any) => {
            lines.push(`- ${lim.text.slice(0, 200)}${lim.text.length > 200 ? "..." : ""}`);
          });
          if (cd.pagination?.limitations?.total > 5) {
            lines.push(`... and ${cd.pagination.limitations.total - 5} more limitations`);
          }
        }
      }
    
      return lines.join("\n");
    }
  • Shared utility function for making authenticated HTTP requests to the Verity API backend, used by all tools including check_prior_auth. Handles GET/POST, params, auth, error handling.
    async function verityRequest<T>(
      endpoint: string,
      options: {
        method?: "GET" | "POST";
        params?: Record<string, string | number | boolean | undefined>;
        body?: unknown;
      } = {}
    ): Promise<T> {
      const { method = "GET", params, body } = options;
    
      // Build URL with query params
      const url = new URL(`${VERITY_API_BASE}${endpoint}`);
      if (params) {
        Object.entries(params).forEach(([key, value]) => {
          if (value !== undefined && value !== null && value !== "") {
            url.searchParams.append(key, String(value));
          }
        });
      }
    
      const headers: Record<string, string> = {
        Authorization: `Bearer ${VERITY_API_KEY}`,
        "Content-Type": "application/json",
        Accept: "application/json",
      };
    
      const response = await fetch(url.toString(), {
        method,
        headers,
        body: body ? JSON.stringify(body) : undefined,
      });
    
      const data = await response.json();
    
      if (!response.ok) {
        const errorMsg = data.error?.message || `API error: ${response.status}`;
        const hint = data.error?.hint || "";
        throw new Error(hint ? `${errorMsg}. Hint: ${hint}` : errorMsg);
      }
    
      return data as T;
    }
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 adds useful context by detailing the return values (PA requirement, confidence level, matched policies, documentation checklist), which helps the agent understand what to expect. However, it lacks information on potential errors, rate limits, or authentication needs, leaving some behavioral aspects unspecified.

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 appropriately sized and front-loaded, starting with the core purpose and key return values, followed by essential usage context and practical examples. Every sentence adds value without redundancy, making it efficient and well-structured for quick comprehension.

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?

Given the complexity of checking prior authorizations, no annotations, and no output schema, the description does a good job by explaining the purpose, usage, and return values. However, it could be more complete by detailing error handling or output structure, which would help the agent better anticipate results. It compensates well but has minor gaps.

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 both parameters thoroughly. The description adds minimal value beyond the schema by implying the purpose of parameters in examples (e.g., state determines MAC jurisdiction), but it does not provide additional syntax or format details. This meets the baseline score 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 specific action ('Check if procedures require prior authorization for Medicare') and resource ('procedures'), distinguishing it from siblings like 'compare_policies' or 'lookup_code' by focusing on authorization requirements rather than policy comparison or code lookup. It explicitly mentions Medicare coverage, making the purpose distinct and well-defined.

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 usage ('Essential for determining Medicare coverage requirements before procedures') and includes examples that illustrate when to use the tool, such as checking single or multiple codes and specifying state jurisdiction. However, it does not explicitly state when not to use it or name alternatives among sibling tools, leaving some guidance implicit.

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