get_product
Retrieve detailed product information by specifying the product ID to efficiently manage and analyze CS-Cart store inventory and listings.
Instructions
Get detailed information about a specific product
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| product_id | Yes | Product ID |
Implementation Reference
- src/index.js:459-462 (handler)The getProduct method that executes the core tool logic: fetches the specific product from CS-Cart API and returns it as JSON text.async getProduct(args) { const result = await this.makeRequest('GET', `/products/${args.product_id}`); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] }; }
- src/index.js:78-87 (schema)Input schema defining the required product_id parameter for the get_product tool.inputSchema: { type: 'object', properties: { product_id: { type: 'number', description: 'Product ID', }, }, required: ['product_id'], },
- src/index.js:75-88 (registration)Registration of the get_product tool in the ListToolsRequestSchema handler, including name, description, and input schema.{ name: 'get_product', description: 'Get detailed information about a specific product', inputSchema: { type: 'object', properties: { product_id: { type: 'number', description: 'Product ID', }, }, required: ['product_id'], }, },
- src/index.js:392-393 (registration)Dispatch registration in the CallToolRequestSchema switch statement that calls the getProduct handler.case 'get_product': return await this.getProduct(args);
- src/index.js:424-440 (helper)Helper method used by the getProduct handler to perform authenticated API requests to the CS-Cart backend.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; }