Skip to main content
Glama
worryzyy

HowToCook-MCP Server

by worryzyy

mcp_howtocook_whatToEat

Find personalized meal ideas based on the number of people. Input the group size, and get tailored dish recommendations for your next meal.

Instructions

不知道吃什么?根据人数直接推荐适合的菜品组合

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
peopleCountYes用餐人数,1-10之间的整数,会根据人数推荐合适数量的菜品

Implementation Reference

  • Implements the core logic of the 'mcp_howtocook_whatToEat' tool. Takes peopleCount input, calculates appropriate numbers of meat and vegetable dishes based on group size, filters recipes by category, applies randomization with meat type preferences for variety, constructs and returns a structured DishRecommendation in JSON format.
    async ({ peopleCount }: { peopleCount: number }) => {
      // 根据人数计算荤素菜数量
      const vegetableCount = Math.floor((peopleCount + 1) / 2);
      const meatCount = Math.ceil((peopleCount + 1) / 2);
      
      // 获取所有荤菜
      let meatDishes = recipes.filter((recipe) => 
        recipe.category === '荤菜' || recipe.category === '水产'
      );
      
      // 获取其他可能的菜品(当做素菜)
      let vegetableDishes = recipes.filter((recipe) => 
        recipe.category !== '荤菜' && recipe.category !== '水产' && 
        recipe.category !== '早餐' && recipe.category !== '主食'
      );
      
      // 特别处理:如果人数超过8人,增加鱼类荤菜
      let recommendedDishes: Recipe[] = [];
      let fishDish: Recipe | null = null;
      
      if (peopleCount > 8) {
        const fishDishes = recipes.filter((recipe) => recipe.category === '水产');
        if (fishDishes.length > 0) {
          fishDish = fishDishes[Math.floor(Math.random() * fishDishes.length)];
          recommendedDishes.push(fishDish);
        }
      }
      
      // 打乱肉类优先级顺序,增加随机性
      const meatTypes = ['猪肉', '鸡肉', '牛肉', '羊肉', '鸭肉', '鱼肉'];
      // 使用 Fisher-Yates 洗牌算法打乱数组
      for (let i = meatTypes.length - 1; i > 0; i--) {
        const j = Math.floor(Math.random() * (i + 1));
        [meatTypes[i], meatTypes[j]] = [meatTypes[j], meatTypes[i]];
      }
      
      const selectedMeatDishes: Recipe[] = [];
      
      // 需要选择的荤菜数量
      const remainingMeatCount = fishDish ? meatCount - 1 : meatCount;
      
      // 尝试按照随机化的肉类优先级选择荤菜
      for (const meatType of meatTypes) {
        if (selectedMeatDishes.length >= remainingMeatCount) break;
        
        const meatTypeOptions = meatDishes.filter((dish) => {
          // 检查菜品的材料是否包含这种肉类
          return dish.ingredients?.some((ingredient) => {
            const name = ingredient.name?.toLowerCase() || '';
            return name.includes(meatType.toLowerCase());
          });
        });
        
        if (meatTypeOptions.length > 0) {
          // 随机选择一道这种肉类的菜
          const selected = meatTypeOptions[Math.floor(Math.random() * meatTypeOptions.length)];
          selectedMeatDishes.push(selected);
          // 从可选列表中移除,避免重复选择
          meatDishes = meatDishes.filter((dish) => dish.id !== selected.id);
        }
      }
      
      // 如果通过肉类筛选的荤菜不够,随机选择剩余的
      while (selectedMeatDishes.length < remainingMeatCount && meatDishes.length > 0) {
        const randomIndex = Math.floor(Math.random() * meatDishes.length);
        selectedMeatDishes.push(meatDishes[randomIndex]);
        meatDishes.splice(randomIndex, 1);
      }
      
      // 随机选择素菜
      const selectedVegetableDishes: Recipe[] = [];
      while (selectedVegetableDishes.length < vegetableCount && vegetableDishes.length > 0) {
        const randomIndex = Math.floor(Math.random() * vegetableDishes.length);
        selectedVegetableDishes.push(vegetableDishes[randomIndex]);
        vegetableDishes.splice(randomIndex, 1);
      }
      
      // 合并推荐菜单
      recommendedDishes = recommendedDishes.concat(selectedMeatDishes, selectedVegetableDishes);
      
      // 构建推荐结果
      const recommendationDetails: DishRecommendation = {
        peopleCount,
        meatDishCount: selectedMeatDishes.length + (fishDish ? 1 : 0),
        vegetableDishCount: selectedVegetableDishes.length,
        dishes: recommendedDishes.map(simplifyRecipe),
        message: `为${peopleCount}人推荐的菜品,包含${selectedMeatDishes.length + (fishDish ? 1 : 0)}个荤菜和${selectedVegetableDishes.length}个素菜。`
      };
      
      return {
        content: [
          {
            type: "text",
            text: JSON.stringify(recommendationDetails, null, 2),
          },
        ],
      };
  • Defines the input schema using Zod: an object with 'peopleCount' property (integer, min 1, max 10).
    {
      peopleCount: z.number().int().min(1).max(10)
                   .describe('用餐人数,1-10之间的整数,会根据人数推荐合适数量的菜品')
    },
  • Registers the tool 'mcp_howtocook_whatToEat' on the McpServer instance via server.tool(), providing name, Chinese description, input schema, and async handler function.
    server.tool(
      "mcp_howtocook_whatToEat",
      "不知道吃什么?根据人数直接推荐适合的菜品组合",
      {
        peopleCount: z.number().int().min(1).max(10)
                     .describe('用餐人数,1-10之间的整数,会根据人数推荐合适数量的菜品')
      },
      async ({ peopleCount }: { peopleCount: number }) => {
        // 根据人数计算荤素菜数量
        const vegetableCount = Math.floor((peopleCount + 1) / 2);
        const meatCount = Math.ceil((peopleCount + 1) / 2);
        
        // 获取所有荤菜
        let meatDishes = recipes.filter((recipe) => 
          recipe.category === '荤菜' || recipe.category === '水产'
        );
        
        // 获取其他可能的菜品(当做素菜)
        let vegetableDishes = recipes.filter((recipe) => 
          recipe.category !== '荤菜' && recipe.category !== '水产' && 
          recipe.category !== '早餐' && recipe.category !== '主食'
        );
        
        // 特别处理:如果人数超过8人,增加鱼类荤菜
        let recommendedDishes: Recipe[] = [];
        let fishDish: Recipe | null = null;
        
        if (peopleCount > 8) {
          const fishDishes = recipes.filter((recipe) => recipe.category === '水产');
          if (fishDishes.length > 0) {
            fishDish = fishDishes[Math.floor(Math.random() * fishDishes.length)];
            recommendedDishes.push(fishDish);
          }
        }
        
        // 打乱肉类优先级顺序,增加随机性
        const meatTypes = ['猪肉', '鸡肉', '牛肉', '羊肉', '鸭肉', '鱼肉'];
        // 使用 Fisher-Yates 洗牌算法打乱数组
        for (let i = meatTypes.length - 1; i > 0; i--) {
          const j = Math.floor(Math.random() * (i + 1));
          [meatTypes[i], meatTypes[j]] = [meatTypes[j], meatTypes[i]];
        }
        
        const selectedMeatDishes: Recipe[] = [];
        
        // 需要选择的荤菜数量
        const remainingMeatCount = fishDish ? meatCount - 1 : meatCount;
        
        // 尝试按照随机化的肉类优先级选择荤菜
        for (const meatType of meatTypes) {
          if (selectedMeatDishes.length >= remainingMeatCount) break;
          
          const meatTypeOptions = meatDishes.filter((dish) => {
            // 检查菜品的材料是否包含这种肉类
            return dish.ingredients?.some((ingredient) => {
              const name = ingredient.name?.toLowerCase() || '';
              return name.includes(meatType.toLowerCase());
            });
          });
          
          if (meatTypeOptions.length > 0) {
            // 随机选择一道这种肉类的菜
            const selected = meatTypeOptions[Math.floor(Math.random() * meatTypeOptions.length)];
            selectedMeatDishes.push(selected);
            // 从可选列表中移除,避免重复选择
            meatDishes = meatDishes.filter((dish) => dish.id !== selected.id);
          }
        }
        
        // 如果通过肉类筛选的荤菜不够,随机选择剩余的
        while (selectedMeatDishes.length < remainingMeatCount && meatDishes.length > 0) {
          const randomIndex = Math.floor(Math.random() * meatDishes.length);
          selectedMeatDishes.push(meatDishes[randomIndex]);
          meatDishes.splice(randomIndex, 1);
        }
        
        // 随机选择素菜
        const selectedVegetableDishes: Recipe[] = [];
        while (selectedVegetableDishes.length < vegetableCount && vegetableDishes.length > 0) {
          const randomIndex = Math.floor(Math.random() * vegetableDishes.length);
          selectedVegetableDishes.push(vegetableDishes[randomIndex]);
          vegetableDishes.splice(randomIndex, 1);
        }
        
        // 合并推荐菜单
        recommendedDishes = recommendedDishes.concat(selectedMeatDishes, selectedVegetableDishes);
        
        // 构建推荐结果
        const recommendationDetails: DishRecommendation = {
          peopleCount,
          meatDishCount: selectedMeatDishes.length + (fishDish ? 1 : 0),
          vegetableDishCount: selectedVegetableDishes.length,
          dishes: recommendedDishes.map(simplifyRecipe),
          message: `为${peopleCount}人推荐的菜品,包含${selectedMeatDishes.length + (fishDish ? 1 : 0)}个荤菜和${selectedVegetableDishes.length}个素菜。`
        };
        
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(recommendationDetails, null, 2),
            },
          ],
        };
      }
    );
  • src/index.ts:59-59 (registration)
    Invokes registerWhatToEatTool(server, recipes) within createServerInstance() to perform the tool registration during MCP server initialization.
    registerWhatToEatTool(server, recipes);
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool recommends dish combinations based on people count, but doesn't describe how recommendations are generated (e.g., random, curated, based on preferences), what the output format is, or any constraints like rate limits or authentication needs. For a tool with no annotations, this is a significant gap in transparency.

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?

The description is concise and front-loaded: a single sentence in Chinese that directly states the tool's function and key parameter. There is no wasted text, and it efficiently communicates the core idea without unnecessary elaboration.

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

Completeness3/5

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

Given the tool's moderate complexity (recommendation based on a single parameter), no annotations, and no output schema, the description is minimally adequate. It covers the purpose and parameter intent but lacks details on behavior, output, or differentiation from siblings. This meets the minimum viable threshold but has clear gaps in completeness.

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

Parameters4/5

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

The description adds meaningful context beyond the input schema. The schema describes 'peopleCount' as an integer 1-10 for meal count, but the description clarifies it's for '用餐人数' (dining people) and that it '会根据人数推荐合适数量的菜品' (will recommend suitable number of dishes based on people count), explaining the parameter's purpose in the recommendation logic. With 100% schema coverage and 1 parameter, this exceeds the baseline of 3.

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

Purpose4/5

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

The description clearly states the tool's purpose: '根据人数直接推荐适合的菜品组合' (recommend suitable dish combinations based on number of people). It specifies the verb '推荐' (recommend) and the resource '菜品组合' (dish combinations), making the purpose understandable. However, it doesn't explicitly differentiate from sibling tools like 'mcp_howtocook_recommendMeals', which appears similar.

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

Usage Guidelines2/5

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

The description provides minimal guidance: it implies usage when '不知道吃什么' (don't know what to eat) and based on '人数' (number of people). However, it offers no explicit when-to-use vs. when-not-to-use instructions, no prerequisites, and no alternatives compared to sibling tools like 'mcp_howtocook_recommendMeals'. This leaves the agent with unclear decision criteria.

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

Related 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/worryzyy/HowToCook-mcp'

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