get_daily_sales
Retrieve daily sales data including revenue, transaction count, and top-selling items for business analysis and reporting.
Instructions
Get sales summary for a specific date including revenue, transaction count, and top-selling items.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| date | No | Date in YYYY-MM-DD format (default: today) |
Implementation Reference
- src/index.ts:738-752 (handler)The core handler logic for the 'get_daily_sales' MCP tool. It fetches sales data for a given date from the mock storeData.sales array and formats a response with revenue, transaction count, average transaction value, and top-selling item.case 'get_daily_sales': { const date = String(args?.date || '2025-10-03'); const salesData = storeData.sales.find(s => s.date === date); if (!salesData) { return { content: [{ type: 'text', text: `No sales data found for ${date}` }] }; } return { content: [{ type: 'text', text: `📊 Sales Report for ${salesData.date}\n\n💵 Revenue: $${salesData.revenue.toFixed(2)}\n🛒 Transactions: ${salesData.transactions}\n📈 Avg Transaction: $${(salesData.revenue / salesData.transactions).toFixed(2)}\n🏆 Top Seller: ${salesData.topItem}` }] }; }
- src/index.ts:166-174 (schema)The tool schema definition including name, description, and input schema (optional date parameter). This is returned by the ListToolsRequestHandler.name: 'get_daily_sales', description: 'Get sales summary for a specific date including revenue, transaction count, and top-selling items.', inputSchema: { type: 'object', properties: { date: { type: 'string', description: 'Date in YYYY-MM-DD format (default: today)' }, }, }, },
- src/index.ts:516-518 (registration)Registration of the tools list via ListToolsRequestHandler, which includes 'get_daily_sales' in the 'tools' array.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools }; });
- src/index.ts:518-521 (registration)The CallToolRequestHandler switch statement registers and dispatches to the get_daily_sales case handler.}); // Handle tool calls server.setRequestHandler(CallToolRequestSchema, async (request) => {
- src/index.ts:42-47 (helper)Mock sales data used by the get_daily_sales handler.sales: [ { date: '2025-10-03', revenue: 456.78, transactions: 12, topItem: 'Acrylic Paint Set' }, { date: '2025-10-02', revenue: 623.45, transactions: 18, topItem: 'Canvas Panel 16x20"' }, { date: '2025-10-01', revenue: 389.90, transactions: 9, topItem: 'Oil Paint Starter Kit' }, { date: '2025-09-30', revenue: 712.34, transactions: 21, topItem: 'Drawing Pencil Set' }, ],