Skip to main content
Glama
davidashman

AnyList MCP Server

by davidashman

Batch Add Ingredients to List

add_ingredients_to_list

Add ingredients from multiple recipes to a shopping list while automatically removing duplicates across recipes. Defaults to the Groceries list for efficient meal planning.

Instructions

Add ingredients from multiple recipes to a shopping list at once. Defaults to the "Groceries" list. Handles duplicates across recipes: each ingredient is only added once.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
recipe_namesNoArray of recipe names
recipe_idsNoArray of recipe identifiers
list_nameNoTarget list name (defaults to "Groceries")Groceries

Implementation Reference

  • The handler function for 'add_ingredients_to_list' that resolves recipes and adds their ingredients to a specified list.
      async ({ recipe_names, recipe_ids, list_name }) => {
        try {
          if (!recipe_names?.length && !recipe_ids?.length) {
            return {
              content: [{ type: 'text', text: 'Error: provide recipe_names or recipe_ids (non-empty array)' }],
              isError: true,
            };
          }
    
          const client = AnyListClient.getInstance();
          const allRecipes = await client.getRecipes();
          await client.getLists();
          const list = client.getListByName(list_name);
          if (!list) {
            return {
              content: [{ type: 'text', text: `List not found: "${list_name}"` }],
              isError: true,
            };
          }
    
          const resolvedRecipes: typeof allRecipes = [];
          const notFound: string[] = [];
    
          // Resolve by IDs
          if (recipe_ids) {
            for (const id of recipe_ids) {
              const recipe = allRecipes.find((r) => r.identifier === id);
              if (recipe) resolvedRecipes.push(recipe);
              else notFound.push(id);
            }
          }
    
          // Resolve by names
          if (recipe_names) {
            for (const name of recipe_names) {
              const term = name.toLowerCase();
              const recipe = allRecipes.find((r) => r.name?.toLowerCase() === term)
                ?? allRecipes.find((r) => r.name?.toLowerCase().includes(term));
              if (recipe) resolvedRecipes.push(recipe);
              else notFound.push(name);
            }
          }
    
          const lines: string[] = [];
          let totalAdded = 0;
          let totalSkipped = 0;
          let totalUnchecked = 0;
    
          for (const recipe of resolvedRecipes) {
            const result = await addRecipeIngredientsToList(client, recipe, list);
            totalAdded += result.added.length;
            totalSkipped += result.skipped.length;
            totalUnchecked += result.unchecked.length;
            lines.push(`${recipe.name}: +${result.added.length} added, ${result.unchecked.length} unchecked, ${result.skipped.length} skipped`);
          }
    
          if (notFound.length) {
            lines.push(`\nNot found: ${notFound.join(', ')}`);
          }
    
          lines.unshift(
            `Batch add to "${list_name}": ${totalAdded} added, ${totalUnchecked} unchecked, ${totalSkipped} already on list`,
          );
    
          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,
          };
        }
      },
    );
  • Tool registration for 'add_ingredients_to_list'.
    server.registerTool(
      'add_ingredients_to_list',
      {
        title: 'Batch Add Ingredients to List',
        description:
          'Add ingredients from multiple recipes to a shopping list at once. Defaults to the "Groceries" list. Handles duplicates across recipes: each ingredient is only added once.',
        inputSchema: z.object({
          recipe_names: z.array(z.string()).optional().describe('Array of recipe names'),
          recipe_ids: z.array(z.string()).optional().describe('Array of recipe identifiers'),
          list_name: z.string().default('Groceries').describe('Target list name (defaults to "Groceries")'),
        }),
      },
  • Zod schema definition for the 'add_ingredients_to_list' tool inputs.
    inputSchema: z.object({
      recipe_names: z.array(z.string()).optional().describe('Array of recipe names'),
      recipe_ids: z.array(z.string()).optional().describe('Array of recipe identifiers'),
      list_name: z.string().default('Groceries').describe('Target list name (defaults to "Groceries")'),
    }),
Behavior4/5

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

No annotations provided, so description carries full burden. It discloses critical deduplication logic ('each ingredient is only added once') and default list behavior ('Defaults to the Groceries list'). Missing error handling behavior and return value description.

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?

Two well-structured sentences with zero waste. First sentence establishes core purpose; second covers default behavior and deduplication. Information is front-loaded and appropriately sized for the tool's complexity.

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?

Adequate for a 3-parameter tool with no output schema. Covers purpose, defaults, and deduplication. Deducted one point because it fails to clarify parameter relationships (whether recipe_names and recipe_ids are alternatives) and provides no return value information.

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 has 100% description coverage, establishing baseline 3. Description reinforces the default list value but does not add syntax details or clarify the relationship between 'recipe_names' and 'recipe_ids' parameters (mutually exclusive vs. complementary).

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?

Description provides specific verb ('Add'), resource ('ingredients from multiple recipes'), and scope ('at once'). The phrase 'multiple recipes' effectively distinguishes this from sibling tools 'add_ingredient_to_list' (singular) and 'add_recipe_ingredients_to_list' (likely single recipe).

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

Usage Guidelines3/5

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

Implies batch usage through 'at once' and 'multiple recipes', but does not explicitly state when to use this versus siblings like 'add_recipe_ingredients_to_list' or 'add_item_to_list'. No explicit exclusions or prerequisites mentioned.

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