Skip to main content
Glama

upscale_image

Enhance low-resolution images by increasing their resolution while maintaining quality. Supports 2x or 4x upscaling with different model options for quality or speed.

Instructions

Upscale an image to higher resolution while preserving quality. Use for enhancing low-resolution images.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
image_urlYesURL of the image to upscale (use upload_file for local images)
scaleNoUpscale factor (2x or 4x)
modelNoUpscaling model. Options: fal-ai/clarity-upscaler (high quality), fal-ai/aura-sr (fast)fal-ai/clarity-upscaler

Implementation Reference

  • The primary handler function for the upscale_image tool. It resolves the model, prepares fal_args with image_url and scale, executes the model via queue_strategy, handles timeouts and errors, extracts the output image URL, and returns a formatted response with the result.
    async def handle_upscale_image(
        arguments: Dict[str, Any],
        registry: ModelRegistry,
        queue_strategy: QueueStrategy,
    ) -> List[TextContent]:
        """Handle the upscale_image tool."""
        model_input = arguments.get("model", "fal-ai/clarity-upscaler")
        try:
            model_id = await registry.resolve_model_id(model_input)
        except ValueError as e:
            return [
                TextContent(
                    type="text",
                    text=f"❌ {e}. Use list_models to see available options.",
                )
            ]
    
        scale = arguments.get("scale", 2)
        fal_args: Dict[str, Any] = {
            "image_url": arguments["image_url"],
            "scale": scale,
        }
    
        logger.info("Starting %dx upscale with %s", scale, model_id)
    
        try:
            result = await asyncio.wait_for(
                queue_strategy.execute_fast(model_id, fal_args),
                timeout=120,  # Upscaling can take longer
            )
        except asyncio.TimeoutError:
            logger.error("Upscaling timed out for %s", model_id)
            return [
                TextContent(
                    type="text",
                    text="❌ Upscaling timed out after 120 seconds. Please try again.",
                )
            ]
        except Exception as e:
            logger.exception("Upscaling failed: %s", e)
            return [
                TextContent(
                    type="text",
                    text=f"❌ Upscaling failed: {e}",
                )
            ]
    
        # Check for error in response
        if "error" in result:
            error_msg = result.get("error", "Unknown error")
            logger.error("Upscaling failed for %s: %s", model_id, error_msg)
            return [
                TextContent(
                    type="text",
                    text=f"❌ Upscaling failed: {error_msg}",
                )
            ]
    
        # Extract the result image URL
        # Clarity upscaler returns {"image": {"url": "..."}}
        image_data = result.get("image", {})
        if isinstance(image_data, dict):
            output_url = image_data.get("url")
        else:
            output_url = result.get("image_url")
    
        if not output_url:
            logger.warning("Upscaling returned no image. Result: %s", result)
            return [
                TextContent(
                    type="text",
                    text="❌ Upscaling completed but no image was returned.",
                )
            ]
    
        response = f"🔍 Image upscaled {scale}x successfully!\n\n"
        response += f"**Result**: {output_url}\n\n"
        response += f"The image resolution has been increased by {scale}x."
        return [TextContent(type="text", text=response)]
  • The tool schema definition specifying the input parameters, descriptions, defaults, and requirements for the upscale_image tool.
    Tool(
        name="upscale_image",
        description="Upscale an image to higher resolution while preserving quality. Use for enhancing low-resolution images.",
        inputSchema={
            "type": "object",
            "properties": {
                "image_url": {
                    "type": "string",
                    "description": "URL of the image to upscale (use upload_file for local images)",
                },
                "scale": {
                    "type": "integer",
                    "default": 2,
                    "enum": [2, 4],
                    "description": "Upscale factor (2x or 4x)",
                },
                "model": {
                    "type": "string",
                    "default": "fal-ai/clarity-upscaler",
                    "description": "Upscaling model. Options: fal-ai/clarity-upscaler (high quality), fal-ai/aura-sr (fast)",
                },
            },
            "required": ["image_url"],
        },
    ),
  • Registration of all tool handlers in the TOOL_HANDLERS dictionary, including the mapping of 'upscale_image' to handle_upscale_image. This dictionary is used in the call_tool method to route tool calls to their handlers.
    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,
    }
  • Import of the handle_upscale_image function from handlers, making it available for registration in TOOL_HANDLERS.
    from fal_mcp_server.handlers import (
        handle_compose_images,
        handle_edit_image,
        handle_generate_image,
        handle_generate_image_from_image,
        handle_generate_image_structured,
        handle_generate_music,
        handle_generate_video,
        handle_generate_video_from_image,
        handle_generate_video_from_video,
        handle_get_pricing,
        handle_get_usage,
        handle_inpaint_image,
        handle_list_models,
        handle_recommend_model,
        handle_remove_background,
        handle_resize_image,
        handle_upload_file,
        handle_upscale_image,
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions quality preservation, which is useful, but fails to disclose critical traits like whether this is a read-only or mutating operation, potential costs, rate limits, authentication needs, or output format (e.g., URL, file). For a tool with no annotation coverage, this is a significant gap.

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 appropriately sized with two concise sentences that are front-loaded with the core purpose. Every sentence earns its place by stating the action and providing usage context without any redundant or verbose language.

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?

Given the tool's moderate complexity (3 parameters, no output schema, no annotations), the description is minimally adequate. It covers the basic purpose and usage but lacks completeness in behavioral traits (e.g., mutation effects, costs) and output details, which are crucial for an agent to use it correctly without structured output guidance.

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?

The schema description coverage is 100%, so the schema already documents all three parameters thoroughly (e.g., 'image_url' with upload guidance, 'scale' with enum values, 'model' with options). The description adds no additional parameter semantics beyond what's in the schema, making the baseline score of 3 appropriate as the schema does the heavy lifting.

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

Purpose4/5

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

The description clearly states the tool's purpose with specific verbs ('upscale', 'enhancing') and resources ('image', 'resolution'), and distinguishes it from some siblings like 'resize_image' by emphasizing quality preservation. However, it doesn't explicitly differentiate from all potential alternatives like 'edit_image' or 'generate_image_from_image' for enhancement tasks.

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

Usage Guidelines3/5

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

The description provides implied usage guidance ('Use for enhancing low-resolution images'), which gives a general context. However, it lacks explicit when-not-to-use scenarios, prerequisites (e.g., file size limits), or named alternatives among siblings (e.g., when to choose 'resize_image' vs. this tool), leaving some ambiguity for the agent.

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