UNPKG

@atlas-kitchen/atlas-mcp

Version:

Model Context Protocol server for Atlas restaurant management system - enables Claude to interact with restaurant orders, menus, and reports

93 lines 4.93 kB
import { z } from 'zod'; const GetSalesReportSchema = z.object({ startDate: z.string(), endDate: z.string(), brandIds: z.array(z.number()).optional(), outletIds: z.array(z.number()).optional(), stationIds: z.array(z.number()).optional(), promoCodes: z.array(z.string()).optional(), includeCancelledOrders: z.boolean().optional(), daysOfWeek: z.array(z.number()).optional(), orderSources: z.array(z.string()).optional(), diningOptions: z.array(z.string()).optional(), }); function validateDateRange(startDate, endDate, maxDays) { const start = new Date(startDate); const end = new Date(endDate); if (isNaN(start.getTime()) || isNaN(end.getTime())) { return 'Invalid date format. Use YYYY-MM-DD.'; } if (end < start) { return 'endDate must not be before startDate.'; } const diffMs = end.getTime() - start.getTime(); const diffDays = diffMs / (1000 * 60 * 60 * 24); if (diffDays > maxDays) { return `Date range must not exceed ${maxDays} days. Requested: ${Math.ceil(diffDays)} days.`; } return null; } export function createReportingTools(client) { return [ { name: 'atlas_get_sales_report', description: 'Get a sales summary report for a date range (max 90 days). Returns sales totals, breakdowns by day/hour, payment methods, outlets, dining options, order sources, promotions, and brands. Both startDate and endDate are required (YYYY-MM-DD).', inputSchema: { type: 'object', properties: { startDate: { type: 'string', description: 'Start date (ISO format YYYY-MM-DD, required)' }, endDate: { type: 'string', description: 'End date (ISO format YYYY-MM-DD, required). Max 90 days from startDate.' }, brandIds: { type: 'array', items: { type: 'number' }, description: 'Filter by brand IDs' }, outletIds: { type: 'array', items: { type: 'number' }, description: 'Filter by outlet IDs' }, stationIds: { type: 'array', items: { type: 'number' }, description: 'Filter by station IDs' }, promoCodes: { type: 'array', items: { type: 'string' }, description: 'Filter by promo codes' }, includeCancelledOrders: { type: 'boolean', description: 'Include cancelled orders (default: false)' }, daysOfWeek: { type: 'array', items: { type: 'number' }, description: 'ISO day of week (1=Monday, 7=Sunday)' }, orderSources: { type: 'array', items: { type: 'string' }, description: 'Filter by order sources' }, diningOptions: { type: 'array', items: { type: 'string' }, description: 'Filter by dining options' }, }, required: ['startDate', 'endDate'], }, handler: async (input) => { const parsed = GetSalesReportSchema.parse(input); const { startDate, endDate, ...filterOptions } = parsed; const dateError = validateDateRange(startDate, endDate, 90); if (dateError) { return { success: false, error: dateError }; } try { const filters = {}; if (filterOptions.brandIds) filters.brandIds = filterOptions.brandIds; if (filterOptions.outletIds) filters.outletIds = filterOptions.outletIds; if (filterOptions.stationIds) filters.stationIds = filterOptions.stationIds; if (filterOptions.promoCodes) filters.promoCodes = filterOptions.promoCodes; if (filterOptions.includeCancelledOrders !== undefined) filters.includeCancelledOrders = filterOptions.includeCancelledOrders; if (filterOptions.daysOfWeek) filters.daysOfWeek = filterOptions.daysOfWeek; if (filterOptions.orderSources) filters.orderSources = filterOptions.orderSources; if (filterOptions.diningOptions) filters.diningOptions = filterOptions.diningOptions; const dateRange = { start_date: startDate, end_date: endDate }; const report = await client.getSalesReport(filters, dateRange); return { success: true, report, }; } catch (error) { return { success: false, error: error.message || 'Failed to fetch sales report', }; } }, }, ]; } //# sourceMappingURL=reports.js.map