get_categories
Retrieve product categories from CS-Cart stores to organize inventory, filter by parent category and status for efficient catalog management.
Instructions
Get list of product categories
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "get_categories"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| parent_id | No | Parent category ID (0 for root categories) | |
| status | No | Category status filter (A=Active, D=Disabled, H=Hidden) |
Implementation Reference
- src/index.js:487-498 (handler)The core handler function for the 'get_categories' tool. Constructs URLSearchParams from input arguments (parent_id and status), builds the /categories endpoint, calls the shared makeRequest('GET'), and returns the API response as formatted JSON text content.
async getCategories(args) { const params = new URLSearchParams(); if (args.parent_id !== undefined) params.append('parent_id', args.parent_id.toString()); if (args.status) params.append('status', args.status); const queryString = params.toString(); const endpoint = `/categories${queryString ? `?${queryString}` : ''}`; const result = await this.makeRequest('GET', endpoint); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] }; } - src/index.js:226-243 (registration)Tool registration in the ListToolsRequestSchema handler's tools array, defining the name, description, and inputSchema for get_categories.
name: 'get_categories', description: 'Get list of product categories', inputSchema: { type: 'object', properties: { parent_id: { type: 'number', description: 'Parent category ID (0 for root categories)', default: 0, }, status: { type: 'string', description: 'Category status filter (A=Active, D=Disabled, H=Hidden)', enum: ['A', 'D', 'H'], }, }, }, }, - src/index.js:402-403 (registration)Dispatch case in the CallToolRequestSchema switch statement that calls the getCategories handler for this tool.
case 'get_categories': return await this.getCategories(args); - src/index.js:228-242 (schema)Input schema defining optional parameters: parent_id (number, default 0) and status (string enum ['A','D','H']).
inputSchema: { type: 'object', properties: { parent_id: { type: 'number', description: 'Parent category ID (0 for root categories)', default: 0, }, status: { type: 'string', description: 'Category status filter (A=Active, D=Disabled, H=Hidden)', enum: ['A', 'D', 'H'], }, }, },