get_recipe
Generate personalized recipes based on user input, fish name, and fish info. Perfect for creating customized meal plans using specific ingredients and preferences.
Instructions
ユーザプロンプトと前回取得した情報を元にレシピ生成
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| FishInfo | Yes | 魚の画像ファイルアップロード後に得られた魚情報 | |
| FishName | Yes | 魚の画像ファイルから得られた魚の名称 | |
| UserInput | Yes | ユーザのレシピに対する希望。例:夏バテ防止レシピ |
Implementation Reference
- src/ragandllm_mcp/server.py:58-76 (handler)Core handler function that implements the get_recipe tool logic by making a POST request to the /recipe2 API endpoint with user input, fish ID, and fish name.async def get_recipe(user_input: str, fish_id:str, fish_name: str) -> str: headers={ "Content-Type":"application/json;charset=utf-8" } # 送信するJSONボディを組み立て body = { "UserInput": user_input, "FishID": fish_id, "FishName": fish_name } async with httpx.AsyncClient(timeout=80.0,verify=False) as client: response = await client.post( f"{API_BASE_URL}/recipe2", headers=headers, json=body ) response.raise_for_status() data = response.json() return data
- src/ragandllm_mcp/server.py:99-120 (registration)Registers the get_recipe tool with the MCP server via list_tools(), including name, description, and input schema definition.types.Tool( name="get_recipe", description="ユーザプロンプトと前回取得した魚名、魚IDを元にレシピ生成", inputSchema={ "type": "object", "properties": { "UserInput": { "type": "string", "description": "ユーザのレシピに対する希望。例:夏バテ防止レシピ" }, "FishID": { "type": "string", "description": "魚の画像アップロード後に得られた魚ID" }, "FishName": { "type": "string", "description": "魚の画像アップロード後に得られた魚の名称" } }, "required": ["UserInput","FishID","FishName"] } ),
- src/ragandllm_mcp/server.py:195-231 (handler)MCP tool call handler that parses arguments, invokes the get_recipe function, and returns the result or error as TextContent.elif name == "get_recipe": if not isinstance(arguments, dict): raise ValueError("Invalid forecast arguments") userinput=arguments["UserInput"] fish_id=arguments["FishID"] fish_name=arguments["FishName"] try: answer= await get_recipe(userinput,fish_id,fish_name) return [ types.TextContent( type="text", text=json.dumps(answer,ensure_ascii=False, indent=2) #text=f"🎉 IRIS接続成功!\n📥 応答::{msg}" ) ] except Exception as e: error_details = { "error_type": type(e).__name__, "error_message": str(e), } return [ types.TextContent( type="text", text=f"エラーが発生しました(recipe): {json.dumps(error_details, ensure_ascii=False, indent=2)}" ) ] except httpx.HTTPError as e: logger.error(f"IRIS API error: {str(e)}") return [ types.TextContent( type="text", text=f"エラーが発生しました(recipe): {str(e)}" ) ]
- src/ragandllm_mcp/server.py:102-119 (schema)JSON schema defining the input parameters for the get_recipe tool: UserInput (string), FishID (string), FishName (string).inputSchema={ "type": "object", "properties": { "UserInput": { "type": "string", "description": "ユーザのレシピに対する希望。例:夏バテ防止レシピ" }, "FishID": { "type": "string", "description": "魚の画像アップロード後に得られた魚ID" }, "FishName": { "type": "string", "description": "魚の画像アップロード後に得られた魚の名称" } }, "required": ["UserInput","FishID","FishName"] }