get_customer_recommendations
Generate personalized art supply recommendations for customers based on their purchase history and preferences to enhance shopping experience and increase sales.
Instructions
Get personalized product recommendations based on customer purchase history and preferences.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| customerId | Yes | Customer ID |
Implementation Reference
- src/index.ts:694-717 (handler)Handler function that finds a customer by ID, matches their preferences against inventory items to generate personalized product recommendations, and returns a formatted list of up to 5 suggested products with prices and stock levels.case 'get_customer_recommendations': { const customerId = String(args?.customerId || ''); const customer = storeData.customers.find(c => c.id === customerId); if (!customer) { return { content: [{ type: 'text', text: `❌ Customer ${customerId} not found` }] }; } const recommendations = storeData.inventory.filter(item => customer.preferences.some(pref => item.name.toLowerCase().includes(pref.toLowerCase()) || item.category.toLowerCase().includes(pref.toLowerCase()) ) ).slice(0, 5); return { content: [{ type: 'text', text: `🎯 Personalized recommendations for ${customer.name}:\n\nBased on preferences: ${customer.preferences.join(', ')}\n\n${recommendations.map(item => `• ${item.name} - $${item.price}\n ${item.quantity} in stock` ).join('\n')}` }] }; }
- src/index.ts:140-150 (schema)Tool schema definition including name, description, and input schema requiring a customerId string.{ name: 'get_customer_recommendations', description: 'Get personalized product recommendations based on customer purchase history and preferences.', inputSchema: { type: 'object', properties: { customerId: { type: 'string', description: 'Customer ID' }, }, required: ['customerId'], }, },
- src/index.ts:516-518 (registration)Registration of the ListToolsRequestSchema handler which returns the full list of tools including get_customer_recommendations via the 'tools' array.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools }; });