forecast_demand
Predict product demand using historical sales data and seasonal patterns to optimize inventory planning for art supplies.
Instructions
Forecast product demand based on historical sales data and seasonal trends.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| period | Yes | Forecast period: week, month, quarter | |
| sku | Yes | Product SKU |
Implementation Reference
- src/index.ts:1064-1083 (handler)The handler function for the 'forecast_demand' tool. It takes SKU and period as input, finds the product in mock inventory, computes a simple forecast using a baseline sales rate adjusted by period multiplier, compares to current stock, and returns a formatted text response with forecast details and stock warning if necessary.case 'forecast_demand': { const sku = String(args?.sku || ''); const period = String(args?.period || 'month'); const item = storeData.inventory.find(i => i.id === sku); if (!item) { return { content: [{ type: 'text', text: `❌ Product ${sku} not found` }] }; } const baselineSales = 50; const periodMultiplier = period === 'week' ? 0.25 : period === 'month' ? 1 : 3; const forecast = Math.round(baselineSales * periodMultiplier); return { content: [{ type: 'text', text: `📈 Demand Forecast: ${item.name}\n\n📅 Period: Next ${period}\n📊 Forecasted Sales: ~${forecast} units\n📦 Current Stock: ${item.quantity} units\n\n${item.quantity < forecast ? `⚠️ WARNING: Current stock may not meet demand!\n💡 Recommended order: ${forecast - item.quantity + item.reorderLevel} units` : '✅ Current stock sufficient for forecasted demand'}` }] }; }
- src/index.ts:348-358 (schema)The tool schema definition including name, description, and inputSchema specifying required 'sku' and 'period' parameters.name: 'forecast_demand', description: 'Forecast product demand based on historical sales data and seasonal trends.', inputSchema: { type: 'object', properties: { sku: { type: 'string', description: 'Product SKU' }, period: { type: 'string', description: 'Forecast period: week, month, quarter' }, }, required: ['sku', 'period'], }, },
- src/index.ts:516-518 (registration)Registers all tools (including 'forecast_demand') via the ListToolsRequestHandler which returns the full tools array containing the forecast_demand schema.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools }; });
- src/dashboard.ts:70-70 (registration)Mock tool registration in dashboard toolsData for UI display and test endpoint simulation.{ name: 'forecast_demand', description: 'Demand forecasting', category: 'Reporting' },