Skip to main content
Glama

upload_file

Upload local files to Fal.ai storage to generate URLs for use with AI models like image-to-video conversion and audio transformation tools.

Instructions

Upload a local file to Fal.ai storage and get a URL. Use this to upload images, videos, or audio files that can then be used with other Fal.ai tools (e.g., image-to-video, audio transform).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_pathYesAbsolute path to the local file to upload (e.g., '/path/to/image.png')

Implementation Reference

  • The core handler function that implements the upload_file tool. It takes a file_path argument, checks if the file exists, uploads it using fal_client.upload_file wrapped in asyncio.to_thread, and returns the resulting URL or error messages.
    async def handle_upload_file(
        arguments: Dict[str, Any],
        registry: ModelRegistry,  # Not used but kept for consistency
    ) -> List[TextContent]:
        """Handle the upload_file tool."""
        file_path = arguments.get("file_path")
        if not file_path:
            return [
                TextContent(
                    type="text",
                    text="❌ No file path specified. Provide the absolute path to the file.",
                )
            ]
    
        try:
            # Use the synchronous upload wrapped in asyncio
            import asyncio
            import os
    
            if not os.path.exists(file_path):
                return [
                    TextContent(
                        type="text",
                        text=f"❌ File not found: {file_path}",
                    )
                ]
    
            # Upload using fal_client
            url = await asyncio.to_thread(fal_client.upload_file, file_path)
    
            return [
                TextContent(
                    type="text",
                    text=f"✅ File uploaded successfully!\n\n**URL**: {url}\n\nYou can use this URL with image-to-video, image-to-image, or other tools.",
                )
            ]
        except Exception as e:
            logger.error("File upload failed: %s", e)
            return [
                TextContent(
                    type="text",
                    text=f"❌ Upload failed: {e}",
                )
            ]
  • The MCP Tool schema definition for the upload_file tool, specifying the inputSchema with required file_path parameter.
        Tool(
            name="upload_file",
            description="Upload a local file to Fal.ai storage and get a URL. Use this to upload images, videos, or audio files that can then be used with other Fal.ai tools (e.g., image-to-video, audio transform).",
            inputSchema={
                "type": "object",
                "properties": {
                    "file_path": {
                        "type": "string",
                        "description": "Absolute path to the local file to upload (e.g., '/path/to/image.png')",
                    },
                },
                "required": ["file_path"],
            },
        ),
    ]
  • Registration of the upload_file handler in the TOOL_HANDLERS dictionary used by the stdio MCP server.
    TOOL_HANDLERS = {
        # Utility tools (no queue needed)
        "list_models": handle_list_models,
        "recommend_model": handle_recommend_model,
        "get_pricing": handle_get_pricing,
        "get_usage": handle_get_usage,
        "upload_file": handle_upload_file,
        # Image generation tools
        "generate_image": handle_generate_image,
        "generate_image_structured": handle_generate_image_structured,
        "generate_image_from_image": handle_generate_image_from_image,
        # Image editing tools
        "remove_background": handle_remove_background,
        "upscale_image": handle_upscale_image,
        "edit_image": handle_edit_image,
        "inpaint_image": handle_inpaint_image,
        "resize_image": handle_resize_image,
        "compose_images": handle_compose_images,
        # Video tools
        "generate_video": handle_generate_video,
        "generate_video_from_image": handle_generate_video_from_image,
        "generate_video_from_video": handle_generate_video_from_video,
        # Audio tools
        "generate_music": handle_generate_music,
    }
  • Registration of the upload_file handler in the TOOL_HANDLERS dictionary used by the HTTP/SSE MCP server.
    TOOL_HANDLERS = {
        # Utility tools (no queue needed)
        "list_models": handle_list_models,
        "recommend_model": handle_recommend_model,
        "get_pricing": handle_get_pricing,
        "get_usage": handle_get_usage,
        "upload_file": handle_upload_file,
        # Image tools
        "generate_image": handle_generate_image,
        "generate_image_structured": handle_generate_image_structured,
        "generate_image_from_image": handle_generate_image_from_image,
        # Video tools
        "generate_video": handle_generate_video,
        "generate_video_from_image": handle_generate_video_from_image,
        "generate_video_from_video": handle_generate_video_from_video,
        # Audio tools
        "generate_music": handle_generate_music,
    }
    
    # Tools that don't require a queue strategy
    NO_QUEUE_TOOLS = {
        "list_models",
        "recommend_model",
        "get_pricing",
        "get_usage",
        "upload_file",
    }
  • Re-export of the handle_upload_file function in handlers/__init__.py for easy import in server files.
    from fal_mcp_server.handlers.utility_handlers import (
        handle_get_pricing,
        handle_get_usage,
        handle_list_models,
        handle_recommend_model,
        handle_upload_file,
    )
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It discloses that the tool uploads files and returns a URL, but lacks details on authentication requirements, rate limits, file size constraints, or error handling. The description adds basic context but misses key behavioral traits for a mutation tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is two sentences with zero waste: the first states the purpose and outcome, and the second provides usage context. It is appropriately sized and front-loaded with essential information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a mutation tool with no annotations and no output schema, the description adequately covers purpose and usage but lacks details on return values (e.g., URL format), error cases, or operational constraints. It is minimally viable but has clear gaps in completeness.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents the single parameter 'file_path' with its type and example. The description does not add any parameter-specific information beyond what the schema provides, meeting the baseline for high schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Upload a local file') and resource ('to Fal.ai storage'), and distinguishes this tool from its siblings by specifying its role in the workflow (uploading files for use with other tools like image-to-video or audio transform).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explicitly states when to use this tool ('to upload images, videos, or audio files that can then be used with other Fal.ai tools') and provides examples of alternative tools (e.g., 'image-to-video, audio transform'), giving clear context for its application.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

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/raveenb/fal-mcp-server'

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