Get Meal Plan
get_meal_planRetrieve scheduled meal events from AnyList for a specific date range to analyze eating patterns and plan future meals.
Instructions
Get meal plan events for a date range. Defaults to the current week (Mon-Sun). Use a 6-week lookback (e.g. start_date 6 weeks ago) to understand recent eating patterns when recommending new meals.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| start_date | No | Start date in YYYY-MM-DD format (defaults to this Monday) | |
| end_date | No | End date in YYYY-MM-DD format (defaults to this Sunday) |
Implementation Reference
- src/tools/meal-plan.ts:30-64 (handler)The handler logic for 'get_meal_plan' which fetches, filters, and formats meal plan events.
async ({ start_date, end_date }) => { try { const client = AnyListClient.getInstance(); const events = await client.getMealPlanningCalendarEvents(); const { start: defaultStart, end: defaultEnd } = getWeekBounds(); const start = start_date ? new Date(start_date + 'T00:00:00') : defaultStart; const end = end_date ? new Date(end_date + 'T23:59:59') : defaultEnd; const filtered = events .filter((e) => { const d = new Date(e.date); return d >= start && d <= end; }) .sort((a, b) => new Date(a.date).getTime() - new Date(b.date).getTime()); const result = filtered.map((e) => ({ id: e.identifier, date: e.date instanceof Date ? e.date.toISOString().slice(0, 10) : String(e.date).slice(0, 10), title: e.title ?? null, label: e.label?.name ?? null, recipeName: e.recipe?.name ?? null, recipeId: e.recipeId ?? null, })); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }], }; } catch (error) { return { content: [{ type: 'text', text: `Error fetching meal plan: ${error instanceof Error ? error.message : String(error)}` }], isError: true, }; } }, - src/tools/meal-plan.ts:19-29 (registration)The registration details for 'get_meal_plan' tool, including its schema and description.
server.registerTool( 'get_meal_plan', { title: 'Get Meal Plan', description: 'Get meal plan events for a date range. Defaults to the current week (Mon-Sun). Use a 6-week lookback (e.g. start_date 6 weeks ago) to understand recent eating patterns when recommending new meals.', inputSchema: z.object({ start_date: z.string().optional().describe('Start date in YYYY-MM-DD format (defaults to this Monday)'), end_date: z.string().optional().describe('End date in YYYY-MM-DD format (defaults to this Sunday)'), }), },