Skip to main content
Glama

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;
    }

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

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