create_product
Add new products to your CS-Cart store with required details like product name, price, categories, description, stock quantity, and shipping cost. Manage product status and enhance inventory efficiently.
Instructions
Create a new product in the CS-Cart store
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| amount | No | Product quantity in stock | |
| category_ids | No | Array of category IDs | |
| description | No | Product description | |
| full_description | No | Full product description | |
| price | Yes | Product price | |
| product | Yes | Product name | |
| shipping_freight | No | Shipping cost | |
| status | No | Product status (A=Active, D=Disabled, H=Hidden) | A |
| weight | No | Product weight |
Implementation Reference
- src/index.js:464-467 (handler)The handler function that executes the create_product tool by making a POST request to the CS-Cart API /products endpoint with the provided args and returning the response as formatted JSON text content.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 for the create_product tool, defining the expected object structure with properties like product name, price (required), optional category_ids, descriptions, status, stock amount, weight, and shipping freight.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:89-138 (registration)The tool registration object in the setTools array, specifying the name 'create_product', description, and linking to the input schema for MCP tool discovery.{ 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)Supporting helper method used by the create_product handler (and others) to perform authenticated HTTP requests to the CS-Cart API endpoints.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; }
- src/index.js:394-395 (registration)Dispatcher switch case in the CallToolRequestHandler that routes calls to the create_product handler method.case 'create_product': return await this.createProduct(args);