Skip to main content
Glama
kureha4

HowToCook-MCP Server

by kureha4

mcp_howtocook_whatToEat

Solve the "what to eat" problem by recommending personalized meal combinations based on the number of people dining. Input the number of diners to receive suitable dish suggestions.

Instructions

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

Input Schema

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

Implementation Reference

  • The main handler function for the tool. It calculates the number of meat and vegetable dishes needed based on peopleCount, filters recipes by category, adds randomization for meat types, selects dishes, simplifies them, and returns a JSON string of the DishRecommendation.
    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),
          },
        ],
      };
    }
  • Zod schema defining the input parameter 'peopleCount' as an integer between 1 and 10.
    {
      peopleCount: z.number().int().min(1).max(10)
                   .describe('用餐人数,1-10之间的整数,会根据人数推荐合适数量的菜品')
    },
  • TypeScript interface defining the structure of the tool's output recommendation object.
    export interface DishRecommendation {
      peopleCount: number;
      meatDishCount: number;
      vegetableDishCount: number;
      dishes: SimpleRecipe[];
      message: string;
    } 
  • Function that registers the 'mcp_howtocook_whatToEat' tool on the MCP server, providing name, description, input schema, and handler.
    export function registerWhatToEatTool(server: McpServer, recipes: Recipe[]) {
      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)
    Invocation of the registration function inside createServerInstance() to register the tool with the server instance and loaded recipes.
    registerWhatToEatTool(server, recipes);
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. While it mentions the tool '推荐适合的菜品组合' (recommends suitable dish combinations), it doesn't describe what 'suitable' means, how recommendations are generated, whether they're personalized, what format the output takes, or any limitations. For a recommendation tool with zero annotation coverage, this is insufficient.

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 extremely concise - a single sentence that directly states the tool's purpose. It's front-loaded with the core functionality and wastes no words. Every part of the sentence contributes to understanding what the tool does.

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

Completeness2/5

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

For a recommendation tool with no annotations and no output schema, the description is incomplete. It doesn't explain what constitutes a '菜品组合' (dish combination), how recommendations are determined, what the output format will be, or any constraints beyond the people count parameter. Given the complexity of recommendation logic and lack of structured output documentation, more context is needed.

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?

The schema has 100% description coverage, with the single parameter 'peopleCount' well-documented in the schema. The description adds minimal value beyond the schema, only reinforcing that recommendations are based on '人数' (number of people). This meets the baseline of 3 when schema coverage is high.

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 resource '菜品组合' (dish combinations), but doesn't explicitly distinguish it from sibling tools like 'mcp_howtocook_recommendMeals' which appears to have a similar recommendation function.

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 usage guidance - it only implies to use this tool when you '不知道吃什么' (don't know what to eat) and need recommendations based on people count. There's no explicit guidance on when to use this tool versus alternatives like 'mcp_howtocook_recommendMeals', nor any mention of prerequisites or exclusions.

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/kureha4/mcptest1'

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