update_product_stock
Adjust product stock quantity in CS-Cart by specifying the product ID and new stock amount. Simplifies inventory management for e-commerce stores.
Instructions
Update product stock quantity
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| amount | Yes | New stock quantity | |
| product_id | Yes | Product ID |
Implementation Reference
- src/index.js:480-484 (handler)The handler function that updates the product stock by making a PUT request to the CS-Cart API endpoint `/products/{product_id}` 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:208-221 (schema)Input schema defining the parameters for the update_product_stock tool: product_id (number, required) and amount (number, required).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:206-222 (registration)Tool registration in the ListTools response, including name, description, and input schema.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)Dispatch case in the CallToolRequest handler that routes to the updateProductStock method.case 'update_product_stock': return await this.updateProductStock(args);