Add Meal Plan Event
add_meal_plan_eventSchedule recipes or custom events on specific dates in your meal plan calendar. Add meals by recipe name, ID, or custom title with optional labels like Breakfast, Lunch, or Dinner.
Instructions
Schedule a recipe or titled event on a specific day in the meal plan calendar.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| date | Yes | Date in YYYY-MM-DD format | |
| recipe_name | No | Recipe name to schedule (case-insensitive match) | |
| recipe_id | No | Recipe identifier for exact lookup | |
| title | No | Event title (used if no recipe specified, or as override) | |
| label | No | Meal label, e.g. "Breakfast", "Lunch", "Dinner" (case-insensitive match) |
Implementation Reference
- src/tools/meal-plan.ts:67-80 (registration)Registration of the add_meal_plan_event tool.
server.registerTool( 'add_meal_plan_event', { title: 'Add Meal Plan Event', description: 'Schedule a recipe or titled event on a specific day in the meal plan calendar.', inputSchema: z.object({ date: z.string().describe('Date in YYYY-MM-DD format'), recipe_name: z.string().optional().describe('Recipe name to schedule (case-insensitive match)'), recipe_id: z.string().optional().describe('Recipe identifier for exact lookup'), title: z.string().optional().describe('Event title (used if no recipe specified, or as override)'), label: z.string().optional().describe('Meal label, e.g. "Breakfast", "Lunch", "Dinner" (case-insensitive match)'), }), }, - src/tools/meal-plan.ts:81-135 (handler)Handler implementation for add_meal_plan_event tool.
async ({ date, recipe_name, recipe_id, title, label }) => { try { const client = AnyListClient.getInstance(); let recipeId = recipe_id; let eventTitle = title; // Resolve recipe by name if needed if (!recipeId && recipe_name) { const recipes = await client.getRecipes(); const term = recipe_name.toLowerCase(); const recipe = recipes.find((r) => r.name?.toLowerCase() === term) ?? recipes.find((r) => r.name?.toLowerCase().includes(term)); if (!recipe) { return { content: [{ type: 'text', text: `Recipe not found: ${recipe_name}` }], isError: true, }; } recipeId = recipe.identifier; if (!eventTitle) eventTitle = recipe.name; } // Resolve label let labelId: string | undefined; if (label) { const labels = client.labels; const match = labels.find((l) => l.name?.toLowerCase() === label.toLowerCase()); if (match) { labelId = match.identifier; } } const event = await client.createEvent({ date: new Date(date + 'T12:00:00'), recipeId, title: eventTitle, labelId, }); await event.save(); return { content: [{ type: 'text', text: `Meal plan event created: "${eventTitle ?? 'Untitled'}" on ${date}${label ? ` (${label})` : ''}`, }], }; } catch (error) { return { content: [{ type: 'text', text: `Error creating meal plan event: ${error instanceof Error ? error.message : String(error)}` }], isError: true, }; } }, );