upload_file
Upload fish images to identify species and receive fish names with corresponding IDs for documentation and classification purposes.
Instructions
魚の画像を渡すと魚名が返ります。補足情報として魚IDも返ります。
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filename | Yes | アップロードする魚画像ファイル名フルパス(例: c: empish.jpg)で指定します。応答はJSONで返送され、FishID、FishName、が返ります。 |
Implementation Reference
- src/ragandllm_mcp/server.py:25-33 (handler)The core handler function for the 'upload_file' tool. It opens the specified file, sends it via HTTP POST to the API endpoint, and returns the JSON response containing 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
- src/ragandllm_mcp/server.py:88-97 (schema)JSON Schema defining the input parameters for the 'upload_file' tool, specifying that 'filename' is a required string.inputSchema={ "type": "object", "properties": { "filename": { "type": "string", "description": "アップロードする魚画像ファイル名フルパス(例: c:\temp\fish.jpg)で指定します。応答はJSONで返送され、FishID、FishName、が返ります。" } }, "required": ["filename"] }
- src/ragandllm_mcp/server.py:85-98 (registration)Registers the 'upload_file' tool in the MCP server's list_tools handler, providing name, description, and schema.types.Tool( name="upload_file", description="魚の画像を渡すと魚名が返ります。補足情報として魚IDも返ります。", inputSchema={ "type": "object", "properties": { "filename": { "type": "string", "description": "アップロードする魚画像ファイル名フルパス(例: c:\temp\fish.jpg)で指定します。応答はJSONで返送され、FishID、FishName、が返ります。" } }, "required": ["filename"] } ),
- src/ragandllm_mcp/server.py:159-193 (helper)Dispatch logic in the call_tool handler that invokes the upload_file function based on tool name, handles arguments, calls the tool, and formats success/error responses.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)}" ) ]