Get Recipe Details
get_recipe_detailsRetrieve complete recipe information including ingredients and preparation steps by searching with a recipe name or identifier.
Instructions
Get full details of a specific recipe including ingredients and preparation steps. Look up by name or ID.
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "get_recipe_details"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| recipe_name | No | Recipe name to look up (case-insensitive partial match) | |
| recipe_id | No | Recipe identifier for exact lookup |
Implementation Reference
- src/tools/recipes.ts:48-58 (registration)Registration of the 'get_recipe_details' tool.
server.registerTool( 'get_recipe_details', { title: 'Get Recipe Details', description: 'Get full details of a specific recipe including ingredients and preparation steps. Look up by name or ID.', inputSchema: z.object({ recipe_name: z.string().optional().describe('Recipe name to look up (case-insensitive partial match)'), recipe_id: z.string().optional().describe('Recipe identifier for exact lookup'), }), }, - src/tools/recipes.ts:59-117 (handler)The handler function implementing the logic for 'get_recipe_details'.
async ({ recipe_name, recipe_id }) => { try { if (!recipe_name && !recipe_id) { return { content: [{ type: 'text', text: 'Error: provide either recipe_name or recipe_id' }], isError: true, }; } const client = AnyListClient.getInstance(); const recipes = await client.getRecipes(); let recipe; if (recipe_id) { recipe = recipes.find((r) => r.identifier === recipe_id); } else if (recipe_name) { const term = recipe_name.toLowerCase(); recipe = recipes.find((r) => r.name?.toLowerCase() === term) ?? recipes.find((r) => r.name?.toLowerCase().includes(term)); } if (!recipe) { return { content: [{ type: 'text', text: `Recipe not found: ${recipe_name ?? recipe_id}` }], isError: true, }; } const details = { id: recipe.identifier, name: recipe.name, rating: recipe.rating ?? null, cookTime: recipe.cookTime ?? null, prepTime: recipe.prepTime ?? null, servings: recipe.servings ?? null, note: recipe.note ?? null, sourceName: recipe.sourceName ?? null, sourceUrl: recipe.sourceUrl ?? null, nutritionalInfo: recipe.nutritionalInfo ?? null, ingredients: recipe.ingredients.map((i) => ({ rawIngredient: i.rawIngredient, name: i.name, quantity: i.quantity, note: i.note, })), preparationSteps: recipe.preparationSteps, }; return { content: [{ type: 'text', text: JSON.stringify(details, null, 2) }], }; } catch (error) { return { content: [{ type: 'text', text: `Error fetching recipe details: ${error instanceof Error ? error.message : String(error)}` }], isError: true, }; } }, );