Skip to main content
Glama

woolworths_update_cart_quantity

Change product quantities in your Woolworths shopping cart by specifying the stockcode and desired amount to update your order.

Instructions

Update the quantity of a product in the shopping cart/trolley

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
stockcodeYesThe product stockcode/ID
quantityYesNew quantity

Implementation Reference

  • The main handler function for the 'woolworths_update_cart_quantity' tool. It sends a POST request to the Woolworths trolley update API with the specified stockcode and new quantity, using session cookies for authentication.
    async function handleUpdateCartQuantity(args: any): Promise<any> {
      const stockcode = args.stockcode;
      const quantity = args.quantity;
    
      const url = `https://www.woolworths.com.au/api/v3/ui/trolley/update`;
    
      try {
        const data = await makeWoolworthsRequest(url, {
          method: "POST",
          headers: {
            "Content-Type": "application/json",
          },
          body: JSON.stringify({
            items: [
              {
                stockcode,
                quantity,
                source: "ProductDetail",
                diagnostics: "0",
                searchTerm: null,
                evaluateRewardPoints: false,
                offerId: null,
                profileId: null,
                priceLevel: null,
              },
            ],
          }),
        });
        return {
          success: true,
          cart: data,
        };
      } catch (error: any) {
        return {
          success: false,
          error: error.message,
        };
      }
    }
  • The tool schema definition, including name, description, and inputSchema with required stockcode (number) and quantity (number). Part of the TOOLS array registered for ListTools.
    {
      name: "woolworths_update_cart_quantity",
      description: "Update the quantity of a product in the shopping cart/trolley",
      inputSchema: {
        type: "object",
        properties: {
          stockcode: {
            type: "number",
            description: "The product stockcode/ID",
          },
          quantity: {
            type: "number",
            description: "New quantity",
          },
        },
        required: ["stockcode", "quantity"],
      },
    },
  • src/index.ts:667-669 (registration)
    Registration in the switch statement of the CallToolRequestSchema handler, which dispatches tool calls to the corresponding handleUpdateCartQuantity function.
    case "woolworths_update_cart_quantity":
      result = await handleUpdateCartQuantity(args || {});
      break;
  • Helper function used by the handler to make authenticated API requests to Woolworths, including cookie headers from the session.
    async function makeWoolworthsRequest(
      url: string,
      options: any = {}
    ): Promise<any> {
      if (sessionCookies.length === 0) {
        throw new Error(
          "No session cookies available. Please use woolworths_get_cookies first."
        );
      }
    
      const headers = {
        "User-Agent":
          "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
        Accept: "*/*",
        "Accept-Language": "en-US,en;q=0.9",
        Origin: "https://www.woolworths.com.au",
        Referer: "https://www.woolworths.com.au/",
        "sec-fetch-dest": "empty",
        "sec-fetch-mode": "cors",
        "sec-fetch-site": "same-origin",
        Priority: "u=1, i",
        Cookie: getCookieHeader(),
        ...options.headers,
      };
    
      const response = await fetch(url, {
        ...options,
        headers,
      });
    
      if (!response.ok) {
        const errorText = await response.text();
        throw new Error(
          `API request failed: ${response.status} ${response.statusText}. ${errorText}`
        );
      }
    
      return response.json();
    }
  • Helper function to format session cookies into a Cookie header string, used in makeWoolworthsRequest.
    function getCookieHeader(): string {
      return sessionCookies.map((c) => `${c.name}=${c.value}`).join("; ");
    }
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 updates quantity but doesn't mention critical aspects like whether this requires authentication, if it's idempotent, what happens with invalid stockcodes or quantities, or if there are rate limits. For a mutation 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 that directly states the tool's function without any fluff. It's front-loaded with the core action and resource, making it easy to parse quickly. Every word earns its place, achieving optimal conciseness.

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 tool modifies cart state (a mutation) with no annotations and no output schema, the description is incomplete. It doesn't cover behavioral traits like side effects, error handling, or response format, which are crucial for safe invocation. For a 2-parameter mutation tool in a sibling-rich context, this leaves too many unknowns.

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 input schema has 100% description coverage, with clear parameter definitions ('stockcode' as product ID, 'quantity' as new quantity). The description adds no additional semantic context beyond what's in the schema (e.g., it doesn't explain format constraints or valid ranges). This meets the baseline for high schema coverage but doesn't enhance understanding.

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 action ('Update the quantity') and target resource ('of a product in the shopping cart/trolley'), making the purpose immediately understandable. However, it doesn't explicitly differentiate from sibling tools like 'woolworths_add_to_cart' or 'woolworths_remove_from_cart', which also modify cart contents, so it falls short of a perfect score.

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. For example, it doesn't specify if this is for existing items only (vs. 'woolworths_add_to_cart' for new items) or clarify edge cases like setting quantity to zero (which might overlap with 'woolworths_remove_from_cart'). This lack of context leaves the agent to infer usage from tool names alone.

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/elijah-g/Woolworths-mcp'

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