mcp_howtocook_getRecipesByCategory
Retrieve recipes by category such as seafood, breakfast, desserts, or soups to simplify meal planning using the HowToCook repository.
Instructions
根据分类查询菜谱,可选分类有: 水产, 早餐, 调料, 甜品, 饮品, 荤菜, 半成品加工, 汤, 主食, 素菜
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| category | Yes | 菜谱分类名称,如水产、早餐、荤菜、主食等 |
Implementation Reference
- src/tools/getRecipesByCategory.ts:6-28 (registration)Registers the 'mcp_howtocook_getRecipesByCategory' tool with MCP server, defining schema and handler inline.export function registerGetRecipesByCategoryTool(server: McpServer, recipes: Recipe[], categories: string[]) { server.tool( "mcp_howtocook_getRecipesByCategory", `根据分类查询菜谱,可选分类有: ${categories.join(', ')}`, { category: z.enum(categories as [string, ...string[]]) .describe('菜谱分类名称,如水产、早餐、荤菜、主食等') }, async ({ category }: { category: string }) => { const filteredRecipes = recipes.filter((recipe) => recipe.category === category); // 返回简化版的菜谱数据 const simplifiedRecipes = filteredRecipes.map(simplifyRecipe); return { content: [ { type: "text", text: JSON.stringify(simplifiedRecipes, null, 2), }, ], }; } ); }
- src/tools/getRecipesByCategory.ts:14-26 (handler)Handler function that filters recipes by given category, simplifies them using simplifyRecipe, and returns JSON-formatted list in MCP text content format.async ({ category }: { category: string }) => { const filteredRecipes = recipes.filter((recipe) => recipe.category === category); // 返回简化版的菜谱数据 const simplifiedRecipes = filteredRecipes.map(simplifyRecipe); return { content: [ { type: "text", text: JSON.stringify(simplifiedRecipes, null, 2), }, ], }; }
- Input schema using Zod: 'category' parameter as enum of provided categories with description.{ category: z.enum(categories as [string, ...string[]]) .describe('菜谱分类名称,如水产、早餐、荤菜、主食等') },