Skip to main content
Glama

woolworths_get_cart

Retrieve your current Woolworths shopping cart contents to view items, quantities, and prices before checkout.

Instructions

Get the contents of the shopping cart/trolley

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The core handler function for the 'woolworths_get_cart' tool. It makes an authenticated API request to the Woolworths trolley endpoint to fetch cart contents and returns the data or an error.
    async function handleGetCart(args: any): Promise<any> { const url = `https://www.woolworths.com.au/apis/ui/Trolley`; try { const data = await makeWoolworthsRequest(url); return { success: true, cart: data, }; } catch (error: any) { return { success: false, error: error.message, }; }
  • The tool's schema definition in the TOOLS array, specifying name, description, and input schema (empty object, no required parameters). Used for tool listing and validation.
    name: "woolworths_get_cart", description: "Get the contents of the shopping cart/trolley", inputSchema: { type: "object", properties: {}, }, },
  • src/index.ts:659-661 (registration)
    The switch case in the main tool request handler that registers and routes 'woolworths_get_cart' calls to the handleGetCart function.
    case "woolworths_get_cart": result = await handleGetCart(args || {}); break;
  • Helper function used by the handler to make authenticated requests to Woolworths API using session cookies.
    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(); }

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