Skip to main content
Glama
kureha4

HowToCook-MCP Server

by kureha4

mcp_howtocook_getRecipesByCategory

Find recipes by category to solve meal planning challenges. Filter Chinese recipes by food type like seafood, breakfast, meat dishes, or staples to get cooking inspiration.

Instructions

根据分类查询菜谱,可选分类有:

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
categoryYes菜谱分类名称,如水产、早餐、荤菜、主食等

Implementation Reference

  • Handler function that filters the recipes list by the input category, maps each to a simplified version using simplifyRecipe helper, and returns the JSON stringified list in the 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), }, ], }; }
  • Zod schema defining the single input parameter 'category' as an enum of available categories.
    { category: z.enum(categories as [string, ...string[]]) .describe('菜谱分类名称,如水产、早餐、荤菜、主食等') },
  • The server.tool() call within registerGetRecipesByCategoryTool that registers the tool name, dynamic description with categories, input schema, and inline handler on the MCP server.
    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/index.ts:57-57 (registration)
    Invocation of the registration function during server instance creation, passing the MCP server, loaded recipes data, and derived categories list.
    registerGetRecipesByCategoryTool(server, recipes, categories);
  • Helper function simplifyRecipe transforms a full Recipe into SimpleRecipe, selecting id, name, description, and ingredients (name, text_quantity only). Used in the tool handler.
    export function simplifyRecipe(recipe: Recipe): SimpleRecipe { return { id: recipe.id, name: recipe.name, description: recipe.description, ingredients: recipe.ingredients.map((ingredient: Ingredient) => ({ name: ingredient.name, text_quantity: ingredient.text_quantity })) }; }

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