get_recipe
Generate recipes using user preferences and identified fish data to create customized cooking instructions.
Instructions
ユーザプロンプトと前回取得した魚名、魚IDを元にレシピ生成
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| UserInput | Yes | ユーザのレシピに対する希望。例:夏バテ防止レシピ | |
| FishID | Yes | 魚の画像アップロード後に得られた魚ID | |
| FishName | Yes | 魚の画像アップロード後に得られた魚の名称 |
Implementation Reference
- src/ragandllm_mcp/server.py:58-76 (handler)Core handler function implementing the 'get_recipe' tool logic: constructs a JSON payload with user input, fish ID, and name, then POSTs to the /recipe2 API endpoint and returns the response.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:102-119 (schema)JSON Schema defining the input parameters for the 'get_recipe' tool: UserInput, FishID, and FishName as required strings.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:99-120 (registration)Registration of the 'get_recipe' tool in the list_tools() handler, including name, description, and input schema.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)Dispatch handler in @server.call_tool() for 'get_recipe': extracts arguments, calls the get_recipe function, formats response 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)}" ) ]