Skip to main content
Glama
kureha4

HowToCook-MCP Server

by kureha4

mcp_howtocook_getRecipeById

Retrieve complete recipe details including ingredients and cooking steps by entering a recipe name or ID. Use this tool to access specific cooking instructions from a Chinese recipe database.

Instructions

根据菜谱名称或ID查询指定菜谱的完整详情,包括食材、步骤等

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes菜谱名称或ID,支持模糊匹配菜谱名称

Implementation Reference

  • Async handler function that implements the core logic: searches recipes by exact ID, exact name, fuzzy name match, or provides up to 5 possible matches based on name/description, returning formatted JSON text content.
    async ({ query }: { query: string }) => {
      // 首先尝试精确匹配ID
      let foundRecipe = recipes.find(recipe => recipe.id === query);
      
      // 如果没有找到,尝试精确匹配名称
      if (!foundRecipe) {
        foundRecipe = recipes.find(recipe => recipe.name === query);
      }
      
      // 如果还没有找到,尝试模糊匹配名称
      if (!foundRecipe) {
        foundRecipe = recipes.find(recipe => 
          recipe.name.toLowerCase().includes(query.toLowerCase())
        );
      }
      
      // 如果仍然没有找到,返回所有可能的匹配项(最多5个)
      if (!foundRecipe) {
        const possibleMatches = recipes.filter(recipe => 
          recipe.name.toLowerCase().includes(query.toLowerCase()) ||
          recipe.description.toLowerCase().includes(query.toLowerCase())
        ).slice(0, 5);
        
        if (possibleMatches.length === 0) {
          return {
            content: [
              {
                type: "text",
                text: JSON.stringify({
                  error: "未找到匹配的菜谱",
                  query: query,
                  suggestion: "请检查菜谱名称是否正确,或尝试使用关键词搜索"
                }, null, 2),
              },
            ],
          };
        }
        
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify({
                message: "未找到精确匹配,以下是可能的匹配项:",
                query: query,
                possibleMatches: possibleMatches.map(recipe => ({
                  id: recipe.id,
                  name: recipe.name,
                  description: recipe.description,
                  category: recipe.category
                }))
              }, null, 2),
            },
          ],
        };
      }
      
      // 返回找到的完整菜谱信息
      return {
        content: [
          {
            type: "text",
            text: JSON.stringify(foundRecipe, null, 2),
          },
        ],
      };
    }
  • Zod input schema defining a single 'query' string parameter with description for recipe name or ID supporting fuzzy matching.
    {
      query: z.string().describe('菜谱名称或ID,支持模糊匹配菜谱名称')
    },
  • registerGetRecipeByIdTool function that registers the tool on the McpServer instance using server.tool() with name, description, schema, and handler, requiring a recipes array.
    export function registerGetRecipeByIdTool(server: McpServer, recipes: Recipe[]) {
      server.tool(
        "mcp_howtocook_getRecipeById",
        "根据菜谱名称或ID查询指定菜谱的完整详情,包括食材、步骤等",
        {
          query: z.string().describe('菜谱名称或ID,支持模糊匹配菜谱名称')
        },
        async ({ query }: { query: string }) => {
          // 首先尝试精确匹配ID
          let foundRecipe = recipes.find(recipe => recipe.id === query);
          
          // 如果没有找到,尝试精确匹配名称
          if (!foundRecipe) {
            foundRecipe = recipes.find(recipe => recipe.name === query);
          }
          
          // 如果还没有找到,尝试模糊匹配名称
          if (!foundRecipe) {
            foundRecipe = recipes.find(recipe => 
              recipe.name.toLowerCase().includes(query.toLowerCase())
            );
          }
          
          // 如果仍然没有找到,返回所有可能的匹配项(最多5个)
          if (!foundRecipe) {
            const possibleMatches = recipes.filter(recipe => 
              recipe.name.toLowerCase().includes(query.toLowerCase()) ||
              recipe.description.toLowerCase().includes(query.toLowerCase())
            ).slice(0, 5);
            
            if (possibleMatches.length === 0) {
              return {
                content: [
                  {
                    type: "text",
                    text: JSON.stringify({
                      error: "未找到匹配的菜谱",
                      query: query,
                      suggestion: "请检查菜谱名称是否正确,或尝试使用关键词搜索"
                    }, null, 2),
                  },
                ],
              };
            }
            
            return {
              content: [
                {
                  type: "text",
                  text: JSON.stringify({
                    message: "未找到精确匹配,以下是可能的匹配项:",
                    query: query,
                    possibleMatches: possibleMatches.map(recipe => ({
                      id: recipe.id,
                      name: recipe.name,
                      description: recipe.description,
                      category: recipe.category
                    }))
                  }, null, 2),
                },
              ],
            };
          }
          
          // 返回找到的完整菜谱信息
          return {
            content: [
              {
                type: "text",
                text: JSON.stringify(foundRecipe, null, 2),
              },
            ],
          };
        }
      );
    }
  • src/index.ts:60-60 (registration)
    Invocation of registerGetRecipeByIdTool(server, recipes) within createServerInstance() to register the tool during server setup.
    registerGetRecipeByIdTool(server, recipes);
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions the tool returns '完整详情' (complete details) including ingredients and steps, which adds value beyond the schema. However, it doesn't describe response format, error handling, rate limits, authentication needs, or whether it's a read-only operation. For a tool with zero annotation coverage, this leaves significant gaps in understanding its behavior.

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 a single, efficient sentence that front-loads the core purpose ('查询指定菜谱的完整详情') and includes essential details (resources covered, parameter behavior). Every word earns its place with no redundancy or wasted space, making it highly concise and well-structured.

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 (single parameter lookup tool), no annotations, and no output schema, the description is minimally adequate. It covers the basic purpose and parameter semantics, but lacks details on return values, error conditions, and behavioral traits. For a tool that presumably returns structured recipe data, more context about output format would be helpful, keeping it at a baseline viable level.

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%, with the parameter 'query' fully documented as supporting recipe names or IDs with fuzzy matching. The description adds marginal value by restating this information in Chinese ('菜谱名称或ID,支持模糊匹配菜谱名称'), but doesn't provide additional syntax examples, format details, or constraints beyond what the schema already covers. Baseline 3 is appropriate when schema does the heavy lifting.

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: '查询指定菜谱的完整详情' (query for complete recipe details) with specific resources mentioned (ingredients, steps). It distinguishes from siblings like getAllRecipes (list all) and getRecipesByCategory (filter by category) by focusing on individual recipe lookup. However, it doesn't explicitly name the verb 'get' or 'retrieve' in the description, keeping it at 4 rather than 5.

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?

The description implies usage context: when you need full details of a specific recipe by name or ID. It mentions '支持模糊匹配菜谱名称' (supports fuzzy matching of recipe names), which provides some guidance on query format. However, it doesn't explicitly state when to use this tool versus alternatives like getAllRecipes (for browsing) or recommendMeals (for suggestions), nor does it mention 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