create_product
Add new products to your CS-Cart store by specifying name, price, categories, and inventory details to expand your online catalog.
Instructions
Create a new product in the CS-Cart store
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| product | Yes | Product name | |
| price | Yes | Product price | |
| category_ids | No | Array of category IDs | |
| description | No | Product description | |
| full_description | No | Full product description | |
| status | No | Product status (A=Active, D=Disabled, H=Hidden) | A |
| amount | No | Product quantity in stock | |
| weight | No | Product weight | |
| shipping_freight | No | Shipping cost |
Implementation Reference
- src/index.js:464-467 (handler)The main handler function for the 'create_product' tool. It makes a POST request to the CS-Cart API endpoint '/products' using the provided arguments and returns the formatted API response.async createProduct(args) { const result = await this.makeRequest('POST', '/products', args); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] }; }
- src/index.js:92-137 (schema)Input schema defining the parameters, types, descriptions, defaults, and required fields for the 'create_product' tool.inputSchema: { type: 'object', properties: { product: { type: 'string', description: 'Product name', }, price: { type: 'number', description: 'Product price', }, category_ids: { type: 'array', items: { type: 'number' }, description: 'Array of category IDs', }, description: { type: 'string', description: 'Product description', }, full_description: { type: 'string', description: 'Full product description', }, status: { type: 'string', description: 'Product status (A=Active, D=Disabled, H=Hidden)', enum: ['A', 'D', 'H'], default: 'A', }, amount: { type: 'number', description: 'Product quantity in stock', default: 0, }, weight: { type: 'number', description: 'Product weight', }, shipping_freight: { type: 'number', description: 'Shipping cost', }, }, required: ['product', 'price'], },
- src/index.js:394-395 (registration)Registration/dispatch in the CallToolRequest handler switch statement that routes calls to the createProduct handler method.case 'create_product': return await this.createProduct(args);
- src/index.js:89-138 (registration)Tool registration in the ListToolsRequest response, including name, description, and reference to input schema.{ name: 'create_product', description: 'Create a new product in the CS-Cart store', inputSchema: { type: 'object', properties: { product: { type: 'string', description: 'Product name', }, price: { type: 'number', description: 'Product price', }, category_ids: { type: 'array', items: { type: 'number' }, description: 'Array of category IDs', }, description: { type: 'string', description: 'Product description', }, full_description: { type: 'string', description: 'Full product description', }, status: { type: 'string', description: 'Product status (A=Active, D=Disabled, H=Hidden)', enum: ['A', 'D', 'H'], default: 'A', }, amount: { type: 'number', description: 'Product quantity in stock', default: 0, }, weight: { type: 'number', description: 'Product weight', }, shipping_freight: { type: 'number', description: 'Shipping cost', }, }, required: ['product', 'price'], }, },
- src/index.js:424-440 (helper)Shared helper method used by createProduct (and other tools) to make authenticated API requests to the CS-Cart server.async makeRequest(method, endpoint, data = null) { const config = { method, url: `${process.env.CSCART_API_URL}${endpoint}`, headers: { 'Content-Type': 'application/json', 'Authorization': `Basic ${Buffer.from(`${process.env.CSCART_API_EMAIL}:${process.env.CSCART_API_KEY}`).toString('base64')}`, }, }; if (data) { config.data = data; } const response = await axios(config); return response.data; }