list_categories
Retrieve a structured list of product categories, including names, item counts, and special markers like discounts or hot items, to easily navigate the CoolPC catalog.
Instructions
Get a complete list of all product categories with statistics. Shows category names, product counts, and special markers (hot items, discounts). Useful for browsing available product types or understanding the catalog structure.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:1009-1031 (handler)The main handler function for 'list_categories' tool. It transforms the loaded productData into a structured list of categories including IDs, names, stats, and subcategory counts, then returns it as JSON text content.private listCategories() { const categories = this.productData.map(cat => ({ category_id: cat.category_id, category_name: cat.category_name, stats: cat.stats, subcategories: cat.subcategories.map(subcat => ({ name: subcat.name, product_count: subcat.products.length })) })); return { content: [ { type: "text", text: JSON.stringify({ total_categories: categories.length, categories, }, null, 2), }, ], }; }
- src/index.ts:270-273 (schema)Input schema for the 'list_categories' tool, defining an empty object (no input parameters required).inputSchema: { type: "object", properties: {}, },
- src/index.ts:267-274 (registration)Registration of the 'list_categories' tool in the ListToolsRequestHandler response, including name, description, and schema.{ name: "list_categories", description: "Get a complete list of all product categories with statistics. Shows category names, product counts, and special markers (hot items, discounts). Useful for browsing available product types or understanding the catalog structure.", inputSchema: { type: "object", properties: {}, }, },
- src/index.ts:319-320 (registration)Dispatch/registration case in the CallToolRequestHandler switch statement that invokes the listCategories handler method.case "list_categories": return this.listCategories();