update_product_stock
Modify inventory levels for products in CS-Cart stores by specifying product ID and new quantity to maintain accurate stock counts.
Instructions
Update product stock quantity
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| product_id | Yes | Product ID | |
| amount | Yes | New stock quantity |
Implementation Reference
- src/index.js:480-484 (handler)The handler function for 'update_product_stock' that updates the stock quantity of a product by making a PUT request to the CS-Cart API with the new amount.async updateProductStock(args) { const productData = { amount: args.amount }; const result = await this.makeRequest('PUT', `/products/${args.product_id}`, productData); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] }; }
- src/index.js:205-222 (schema)Defines the tool schema including name, description, and input schema for validating arguments (product_id and amount).{ name: 'update_product_stock', description: 'Update product stock quantity', inputSchema: { type: 'object', properties: { product_id: { type: 'number', description: 'Product ID', }, amount: { type: 'number', description: 'New stock quantity', }, }, required: ['product_id', 'amount'], }, },
- src/index.js:400-401 (registration)Registers the tool handler in the CallToolRequestSchema switch statement, dispatching calls to updateProductStock.case 'update_product_stock': return await this.updateProductStock(args);