Skip to main content
Glama
iijimam

RAGandLLM-MCP

by iijimam

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
NameRequiredDescriptionDefault
filenameYesアップロードする魚画像ファイル名フルパス(例: c: emp ish.jpg)で指定します。応答はJSONで返送され、FishID、FishName、が返ります。

Implementation Reference

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