Skip to main content
Glama
iijimam

RAGandLLM-MCP

by iijimam

get_recipe

Generate recipes using user preferences and identified fish data to create customized cooking instructions.

Instructions

ユーザプロンプトと前回取得した魚名、魚IDを元にレシピ生成

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
UserInputYesユーザのレシピに対する希望。例:夏バテ防止レシピ
FishIDYes魚の画像アップロード後に得られた魚ID
FishNameYes魚の画像アップロード後に得られた魚の名称

Implementation Reference

  • 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
  • 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"]
    }
  • 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"]
        }
    ),
  • 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)}"
                )
            ]
Install Server

Other Tools

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/iijimam/RAGandLLM-MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server