woolworths_get_categories
Retrieve all available product categories from Woolworths Australia to browse and navigate their online shopping platform effectively.
Instructions
Get the list of available product categories
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:443-458 (handler)The main handler function for the 'woolworths_get_categories' tool. It makes an API request to Woolworths' categories endpoint using session cookies and returns the categories or an error.async function handleGetCategories(args: any): Promise<any> { const url = `https://www.woolworths.com.au/apis/ui/PiesCategoriesWithSpecials`; try { const data = await makeWoolworthsRequest(url); return { success: true, categories: data, }; } catch (error: any) { return { success: false, error: error.message, }; } }
- src/index.ts:135-142 (schema)The tool schema definition, including name, description, and empty input schema, registered in the TOOLS array.{ name: "woolworths_get_categories", description: "Get the list of available product categories", inputSchema: { type: "object", properties: {}, }, },
- src/index.ts:651-653 (registration)Registration of the tool handler in the switch statement for CallToolRequestSchema.case "woolworths_get_categories": result = await handleGetCategories(args || {}); break;
- src/index.ts:210-248 (helper)Helper function used by the handler to make authenticated API requests to Woolworths endpoints with 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(); }