Skip to main content
Glama
davidashman

AnyList MCP Server

by davidashman

Add Recipe Ingredients to List

add_recipe_ingredients_to_list

Add recipe ingredients to a shopping list while automatically checking for duplicates and managing previously checked-off items.

Instructions

Add all ingredients from a single recipe to a shopping list. Defaults to the "Groceries" list. Checks for duplicates: skips items already on the list, unchecks previously checked-off items.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
recipe_nameNoRecipe name (case-insensitive match)
recipe_idNoRecipe identifier
list_nameNoTarget list name (defaults to "Groceries")Groceries

Implementation Reference

  • The `addRecipeIngredientsToList` function contains the core logic for processing recipe ingredients and adding them to the list, including handling duplicates and updating existing items.
    async function addRecipeIngredientsToList(
      client: AnyListClient,
      recipe: { name: string; ingredients: Array<{ name: string; rawIngredient: string; quantity: string }> },
      list: { getItemByName(name: string): { checked: boolean; save(): Promise<void> } | undefined; addItem(item: any): Promise<any> },
    ): Promise<{ added: string[]; skipped: string[]; unchecked: string[] }> {
      const added: string[] = [];
      const skipped: string[] = [];
      const unchecked: string[] = [];
    
      for (const ingredient of recipe.ingredients) {
        const ingredientName = ingredient.name || ingredient.rawIngredient;
        if (!ingredientName) continue;
    
        const existing = list.getItemByName(ingredientName);
        if (existing) {
          if (existing.checked) {
            existing.checked = false;
            await existing.save();
            unchecked.push(ingredientName);
          } else {
            skipped.push(ingredientName);
          }
          continue;
        }
    
        const item = client.createItem({
          name: ingredientName,
          quantity: ingredient.quantity || undefined,
        });
        await list.addItem(item);
        added.push(ingredientName);
      }
    
      return { added, skipped, unchecked };
    }
  • The `add_recipe_ingredients_to_list` tool is registered in the `registerGroceryTools` function, which maps the tool name to an async handler that uses `addRecipeIngredientsToList` and provides input schema validation via Zod.
    export function registerGroceryTools(server: McpServer) {
      server.registerTool(
        'add_recipe_ingredients_to_list',
        {
          title: 'Add Recipe Ingredients to List',
          description:
            'Add all ingredients from a single recipe to a shopping list. Defaults to the "Groceries" list. Checks for duplicates: skips items already on the list, unchecks previously checked-off items.',
          inputSchema: z.object({
            recipe_name: z.string().optional().describe('Recipe name (case-insensitive match)'),
            recipe_id: z.string().optional().describe('Recipe identifier'),
            list_name: z.string().default('Groceries').describe('Target list name (defaults to "Groceries")'),
          }),
        },
        async ({ recipe_name, recipe_id, list_name }) => {
          try {
            if (!recipe_name && !recipe_id) {
              return {
                content: [{ type: 'text', text: 'Error: provide either recipe_name or recipe_id' }],
                isError: true,
              };
            }
    
            const client = AnyListClient.getInstance();
            const recipe = await resolveRecipe(client, recipe_name, recipe_id);
            if (!recipe) {
              return {
                content: [{ type: 'text', text: `Recipe not found: ${recipe_name ?? recipe_id}` }],
                isError: true,
              };
            }
    
            await client.getLists();
            const list = client.getListByName(list_name);
            if (!list) {
              return {
                content: [{ type: 'text', text: `List not found: "${list_name}"` }],
                isError: true,
              };
            }
    
            const result = await addRecipeIngredientsToList(client, recipe, list);
    
            const lines: string[] = [`Ingredients from "${recipe.name}" → "${list_name}":`];
            if (result.added.length) lines.push(`  Added: ${result.added.join(', ')}`);
            if (result.unchecked.length) lines.push(`  Unchecked: ${result.unchecked.join(', ')}`);
            if (result.skipped.length) lines.push(`  Already on list: ${result.skipped.join(', ')}`);
    
            return {
              content: [{ type: 'text', text: lines.join('\n') }],
            };
          } catch (error) {
            return {
              content: [{ type: 'text', text: `Error adding ingredients: ${error instanceof Error ? error.message : String(error)}` }],
              isError: true,
            };
          }
        },
      );
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden and successfully discloses key behavioral traits: the duplicate-checking logic (skips existing, unchecks checked-off items) and default list targeting. It could be improved by mentioning error conditions or what happens if both recipe_name and recipe_id are provided.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Three well-structured sentences with zero waste: first establishes the core action, second covers defaults, third explains behavioral specifics (duplicate handling). Information is front-loaded and every sentence earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the simple flat schema with 3 parameters and no output schema, the description is nearly complete. It covers the primary function, default behavior, and side effects. Minor gap: it does not clarify the logical requirement that at least one of recipe_name or recipe_id must be provided (since both are marked optional in the schema).

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, providing detailed descriptions for all three parameters (recipe_name, recipe_id, list_name). The description reinforces the default 'Groceries' behavior but does not add significant semantic meaning beyond what the schema already provides, which is appropriate given the high schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action (Add), source (all ingredients from a single recipe), and target (shopping list). It effectively distinguishes from siblings like 'add_ingredient_to_list' and 'add_item_to_list' by specifying the recipe-to-list workflow.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies the use case through 'from a single recipe' and mentions the default 'Groceries' list, providing clear context. However, it does not explicitly state when to use this versus 'add_ingredients_to_list' or clarify that at least one recipe identifier (name or ID) must be provided since both are optional in the schema.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/davidashman/anylist-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server