get_categories
Retrieve the category tree structure from a product catalog to organize and navigate product hierarchies in SAP Commerce Cloud.
Instructions
Get the category tree from the product catalog
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/hybris-client.ts:424-445 (handler)The implementation of the getCategories method that fetches the category tree from the Hybris OCC API.
async getCategories(): Promise<Category[]> { interface CatalogResponse { catalogs: Array<{ id: string; catalogVersions: Array<{ id: string; categories: Category[]; }>; }>; } const result = await this.request<CatalogResponse>( `/occ/v2/${encodeURIComponent(this.config.baseSiteId!)}/catalogs` ); // Extract categories from the first catalog version matching our config const catalog = result.catalogs?.find(c => c.id === this.config.catalogId); if (!catalog) return []; const version = catalog.catalogVersions?.find(v => v.id === this.config.catalogVersion); return version?.categories || []; } - src/index.ts:393-395 (handler)The handler logic in index.ts that routes the "get_categories" tool call to the hybrisClient.getCategories method.
case 'get_categories': result = await hybrisClient.getCategories(); break; - src/index.ts:141-147 (registration)Tool definition for "get_categories" registered in the tools array.
name: 'get_categories', description: 'Get the category tree from the product catalog', inputSchema: { type: 'object', properties: {}, }, },