get_product
Retrieve detailed product information from CS-Cart stores using product ID for inventory management and customer support.
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 primary handler function for the 'get_product' tool. It makes a GET request to the CS-Cart API endpoint `/products/{product_id}` using the makeRequest helper and returns the JSON-formatted result.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:75-88 (registration)Registration of the 'get_product' tool in the ListToolsRequestSchema response, defining its 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:78-87 (schema)The 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:424-440 (helper)Helper method used by the get_product handler (and others) to perform authenticated API requests to the CS-Cart server using axios.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:392-393 (handler)Dispatch case in the CallToolRequestSchema handler that routes calls to the 'get_product' tool to its implementation method.case 'get_product': return await this.getProduct(args);