Skip to main content
Glama

get_delivery_options

Check delivery and warehouse pickup availability for Costco items by entering your ZIP code. Optionally specify an item number to verify availability for specific products.

Instructions

Check delivery and warehouse pickup availability for cart items or a specific product

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
zip_codeYesZIP code to check delivery options
item_numberNoCostco item number to check availability for (optional, checks cart if omitted)

Implementation Reference

  • The handleGetDeliveryOptions function implements the tool logic. It navigates to a product page (if itemNumber provided) or the cart page, enters the ZIP code, and scrapes delivery options including warehouse pickup availability and online delivery information.
    async function handleGetDeliveryOptions(zipCode: string, itemNumber?: string) {
      return withPage(async (page: Page) => {
        // If itemNumber provided, check product page; otherwise check cart
        if (itemNumber) {
          await page.goto(`https://www.costco.com/p.${itemNumber}.product.html`, {
            waitUntil: "domcontentloaded",
            timeout: 30000,
          });
        } else {
          await page.goto("https://www.costco.com/CheckoutCartDisplayView", {
            waitUntil: "domcontentloaded",
            timeout: 30000,
          });
        }
        await page.waitForTimeout(2000);
    
        // Try to enter zip code for delivery estimate
        try {
          const zipInputEl = await page.$(
            'input[placeholder*="ZIP" i], input[name*="zip" i], input[id*="zip" i]'
          );
          if (zipInputEl) {
            await zipInputEl.fill(zipCode);
            await zipInputEl.press("Enter");
            await page.waitForTimeout(2000);
          }
        } catch {
          // Continue without zip entry
        }
    
        const deliveryInfo = await page.evaluate(() => {
          const deliveryEls = Array.from(
            document.querySelectorAll(
              '[class*="delivery"], [class*="shipping"], [automation-id*="delivery"], [automation-id*="shipping"]'
            )
          );
    
          const options: string[] = [];
          for (const el of deliveryEls) {
            const text = el.textContent?.trim();
            if (text && text.length > 5 && text.length < 300) {
              options.push(text);
            }
          }
    
          // Check for warehouse pickup availability
          const warehouseEl = document.querySelector(
            '[class*="warehouse-pickup"], [class*="in-warehouse"], [automation-id*="warehouse"]'
          );
          const warehouseText = warehouseEl?.textContent?.trim() ?? "";
    
          // Check online delivery
          const onlineDeliveryEl = document.querySelector(
            '[class*="online-only"], [class*="delivery-available"], [automation-id*="online-delivery"]'
          );
          const onlineDeliveryText = onlineDeliveryEl?.textContent?.trim() ?? "";
    
          return { options: options.slice(0, 5), warehouseText, onlineDeliveryText };
        });
    
        const lines = [`**Delivery Options for ZIP: ${zipCode}**\n`];
    
        if (deliveryInfo.warehouseText) {
          lines.push(`Warehouse Pickup: ${deliveryInfo.warehouseText}`);
        }
        if (deliveryInfo.onlineDeliveryText) {
          lines.push(`Online Delivery: ${deliveryInfo.onlineDeliveryText}`);
        }
        if (deliveryInfo.options.length > 0) {
          lines.push(`\nDelivery details:`);
          deliveryInfo.options.forEach((opt) => lines.push(`  - ${opt}`));
        }
    
        if (lines.length === 1) {
          lines.push("No delivery options found. Please check the Costco website directly.");
        }
    
        return ok(lines.join("\n"));
      });
    }
  • Tool schema definition for 'get_delivery_options' with inputSchema specifying zip_code (required) and item_number (optional) parameters, along with the tool description.
      name: "get_delivery_options",
      description: "Check delivery and warehouse pickup availability for cart items or a specific product",
      inputSchema: {
        type: "object",
        properties: {
          zip_code: {
            type: "string",
            description: "ZIP code to check delivery options",
          },
          item_number: {
            type: "string",
            description: "Costco item number to check availability for (optional, checks cart if omitted)",
          },
        },
        required: ["zip_code"],
      },
    },
  • src/index.ts:325-329 (registration)
    The tool call routing in the CallToolRequestSchema handler that maps 'get_delivery_options' to the handleGetDeliveryOptions function with zip_code and item_number arguments.
    case "get_delivery_options":
      return await handleGetDeliveryOptions(
        a.zip_code as string,
        a.item_number as string | undefined
      );
  • Helper functions ok() and err() used by handleGetDeliveryOptions to format successful responses and error messages.
    function ok(text: string) {
      return { content: [{ type: "text" as const, text }] };
    }
    
    function err(text: string) {
      return { content: [{ type: "text" as const, text: `Error: ${text}` }], isError: true };
    }
  • The withPage helper function used by handleGetDeliveryOptions to execute browser automation in a managed context with stealth scripting and session cookie handling.
    export async function withPage<T>(
      fn: (page: Page) => Promise<T>,
      headless = true
    ): Promise<T> {
      const ctx = await getBrowserContext(headless);
      const page = await ctx.newPage();
      await page.addInitScript(STEALTH_INIT_SCRIPT);
      try {
        const result = await fn(page);
        await saveSessionCookies();
        return result;
      } finally {
        await page.close();
      }
    }
Behavior2/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 states the tool checks availability but doesn't describe what 'availability' means (e.g., real-time stock levels, delivery timeframes), whether it requires authentication, rate limits, or what the response format looks like. This leaves significant gaps for a tool that likely queries external systems.

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 that front-loads the core purpose without unnecessary words. Every part earns its place by specifying what's being checked and the optional scope, making it highly concise and well-structured.

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

Completeness3/5

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

Given no annotations and no output schema, the description is incomplete for a tool that likely returns complex availability data. It adequately states the purpose but lacks details on behavioral traits, response format, or error handling. For a tool with 2 parameters and external dependencies, more context would be beneficial.

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 input schema already documents both parameters thoroughly. The description adds minimal value beyond the schema by mentioning 'cart items or a specific product', which loosely maps to the optional 'item_number' parameter. No additional syntax or format details are provided, meeting the baseline for high schema coverage.

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 with specific verbs ('check delivery and warehouse pickup availability') and resources ('cart items or a specific product'), making it immediately understandable. However, it doesn't explicitly differentiate from sibling tools like 'check_warehouse_stock' or 'get_warehouse_locations', which might offer overlapping functionality.

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

Usage Guidelines3/5

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

The description implies usage by mentioning 'cart items or a specific product', but doesn't provide explicit guidance on when to use this tool versus alternatives like 'check_warehouse_stock' or 'get_warehouse_locations'. It hints at context (checking availability) but lacks clear when/when-not instructions or named alternatives.

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/markswendsen-code/mcp-costco'

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