Skip to main content
Glama
iijimam
by iijimam

upload_file

Upload a local fish image to identify the fish species and receive interesting facts in return. Works with RAGandLLM-MCP for knowledge retrieval.

Instructions

ローカルの魚の画像をアップロードすると魚名と豆知識を返します

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filenameYesアップロードする魚画像ファイル名フルパス(例: c: emp ish.jpg)

Implementation Reference

  • The core handler function that performs the file upload to the API endpoint, reads the file, sends it via POST request, and returns the JSON response with fish identification data.
    async def upload_file(filename: str): file = {'fish': open(filename, 'rb')} async with httpx.AsyncClient(timeout=60.0,verify=False) as client: response = await client.post( f"{API_BASE_URL}/upload",files=file ) response.raise_for_status() data = response.json() return data
  • The JSON schema definition for the 'upload_file' tool input, specifying the required 'filename' parameter as a string with description.
    types.Tool( name="upload_file", description="魚の画像を渡すと魚名が返ります。補足情報として魚IDも返ります。", inputSchema={ "type": "object", "properties": { "filename": { "type": "string", "description": "アップロードする魚画像ファイル名フルパス(例: c:\temp\fish.jpg)で指定します。応答はJSONで返送され、FishID、FishName、が返ります。" } }, "required": ["filename"] } ),
  • The @server.list_tools() handler that registers and lists all available tools, including 'upload_file' with its schema.
    @server.list_tools() async def handle_list_tools() -> list[types.Tool]: """ List available tools. Each tool specifies its arguments using JSON Schema validation. """ return [ types.Tool( name="upload_file", description="魚の画像を渡すと魚名が返ります。補足情報として魚IDも返ります。", inputSchema={ "type": "object", "properties": { "filename": { "type": "string", "description": "アップロードする魚画像ファイル名フルパス(例: c:\temp\fish.jpg)で指定します。応答はJSONで返送され、FishID、FishName、が返ります。" } }, "required": ["filename"] } ), 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"] } ), types.Tool( name="register_choka", description="釣果登録が行えます", inputSchema={ "type": "object", "properties": { "FishID": { "type": "string", "description": "upload_fileの応答JSONにあるFishIDを使用する。upload_fileを事前に実行していいない場合はユーザによる指定が必要" }, "FishName": { "type": "string", "description": "upload_fileの応答JSONにあるFishNameを使用する。upload_fileを事前に実行していいない場合はユーザによる指定が必要" }, "FishSize": { "type": "string", "description": "釣果登録時、魚の体長をセンチメートルで指定する" }, "FishCount": { "type": "integer", "description": "釣果登録時、釣った魚の数を指定する。" } }, "required": ["FishID","FishName","FishSize","FishCount"] } ) ]
  • The dispatch logic in the main @server.call_tool() handler that invokes the upload_file function when the tool 'upload_file' is called, handles arguments, executes it, and formats the response.
    if name == "upload_file": if not isinstance(arguments, dict): raise ValueError("Invalid forecast arguments") file=arguments["filename"] try: answer= await upload_file(file) print(answer) logger.info(f"answer is : {answer}") return [ types.TextContent( type="text", text=json.dumps(answer,ensure_ascii=False, indent=2) ) ] except Exception as e: error_details = { "error_type": type(e).__name__, "error_message": str(e), } return [ types.TextContent( type="text", text=f"エラーが発生しました(upload): {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"エラーが発生しました(upload): {str(e)}" ) ]

Other Tools

Related 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