Skip to main content
Glama
ECNU3D

Universal Image Generator MCP Server

by ECNU3D

transform_image_from_url

Transform existing images from URLs using AI editing functions like stylization, resolution enhancement, watermark removal, and content modification based on text prompts.

Instructions

Transform an existing image from a URL using the configured image provider.

    Args:
        image_url: Remote or Public URL of the image to be transformed
        prompt: Text prompt describing the desired transformation or modifications
        function: WanX editing function (default: 'description_edit'). Supported functions:
                 'description_edit', 'description_edit_with_mask', 'stylization_all', 
                 'stylization_local', 'remove_watermark', 'expand', 'super_resolution', 
                 'colorization', 'doodle', 'control_cartoon_feature'
        mask_image_url: URL of mask image (required for 'description_edit_with_mask')
        
    Returns:
        Details about the transformed image including local path and remote URL
    

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
image_urlYes
promptYes
functionNodescription_edit
mask_image_urlNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The core handler function for the 'transform_image_from_url' MCP tool. It is decorated with @mcp.tool() for automatic registration and schema inference from signature/docstring. Handles provider-specific logic for downloading images from URL, prompt translation/optimization, and transformation via the image provider.
    @mcp.tool()
    async def transform_image_from_url(image_url: str, prompt: str, function: str = "description_edit", mask_image_url: Optional[str] = None) -> str:
        """Transform an existing image from a URL using the configured image provider.
    
        Args:
            image_url: Remote or Public URL of the image to be transformed
            prompt: Text prompt describing the desired transformation or modifications
            function: WanX editing function (default: 'description_edit'). Supported functions:
                     'description_edit', 'description_edit_with_mask', 'stylization_all', 
                     'stylization_local', 'remove_watermark', 'expand', 'super_resolution', 
                     'colorization', 'doodle', 'control_cartoon_feature'
            mask_image_url: URL of mask image (required for 'description_edit_with_mask')
            
        Returns:
            Details about the transformed image including local path and remote URL
        """
        try:
            provider = get_image_provider()
            logger.info(f"Processing transform_image_from_url request with {provider.get_name()}")
            logger.info(f"Image URL: {image_url}")
            logger.info(f"Transformation prompt: {prompt}")
            logger.info(f"Function: {function}")
    
            # For providers that don't support URL-based transformation, we need to download and convert
            if provider.get_name() == "google":
                # Download image and convert to PIL Image for Google
                import requests
                response = requests.get(image_url)
                if response.status_code != 200:
                    raise ValueError(f"Failed to download image from URL: {image_url}")
                
                source_image = PIL.Image.open(BytesIO(response.content))
                logger.info(f"Downloaded and loaded image from URL for Google")
                
                # Translate the prompt for the provider
                translated_prompt = await translate_prompt_for_provider(prompt, provider)
                
                # Create detailed transformation prompt
                transformation_prompt = get_image_transformation_prompt(translated_prompt)
                
                # Process the transformation using the provider
                _, saved_path, remote_url = await provider.transform_image(source_image, transformation_prompt)
                
            elif provider.get_name() == "bailian":
                # For Bailian, we can use the URL directly
                
                # Translate the prompt for the provider  
                translated_prompt = await translate_prompt_for_provider(prompt, provider)
                
                # Create detailed transformation prompt
                transformation_prompt = get_image_transformation_prompt(translated_prompt)
                
                # Prepare kwargs for Bailian provider
                kwargs = {
                    'function': function,
                    'base_image_url': image_url
                }
                
                # Add mask image URL if provided and function requires it
                if mask_image_url:
                    kwargs['mask_image_url'] = mask_image_url
                elif function == "description_edit_with_mask":
                    raise ValueError("mask_image_url is required for description_edit_with_mask function")
                
                # Use a dummy PIL image since we're passing URL via kwargs
                dummy_image = PIL.Image.new('RGB', (1, 1))
                
                # Process the transformation using the provider
                _, saved_path, remote_url = await provider.transform_image(dummy_image, transformation_prompt, **kwargs)
                
            else:
                # For other providers, download image first
                import requests
                response = requests.get(image_url)
                if response.status_code != 200:
                    raise ValueError(f"Failed to download image from URL: {image_url}")
                
                source_image = PIL.Image.open(BytesIO(response.content))
                logger.info(f"Downloaded and loaded image from URL")
                
                # Translate the prompt for the provider
                translated_prompt = await translate_prompt_for_provider(prompt, provider)
                
                # Create detailed transformation prompt
                transformation_prompt = get_image_transformation_prompt(translated_prompt)
                
                # Process the transformation using the provider
                _, saved_path, remote_url = await provider.transform_image(source_image, transformation_prompt)
            
            logger.info(f"Image transformed and saved to: {saved_path}")
            
            # Prepare response with remote URL if available
            response = f"Image transformed and saved to: {saved_path}"
            if remote_url:
                response += f"\nRemote URL: {remote_url}"
            
            return response
            
        except Exception as e:
            error_msg = f"Error transforming image from URL: {str(e)}"
            logger.error(error_msg)
            return error_msg
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 that the tool uses a 'configured image provider' and lists supported functions, but lacks details on permissions, rate limits, error handling, or what 'transform' entails (e.g., whether it modifies the original or creates a new image). The description adds some context but is insufficient for a mutation tool with zero annotation coverage.

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

Conciseness4/5

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

The description is appropriately sized and front-loaded, starting with the core purpose followed by parameter details in a structured format. Every sentence adds value, such as explaining parameter roles and listing function options. However, the inclusion of 'Args:' and 'Returns:' sections, while helpful, adds some redundancy as this information is partially covered in the schema and output schema.

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 complexity (image transformation with multiple parameters), no annotations, and an output schema (which handles return values), the description is moderately complete. It covers the purpose and parameters well but lacks behavioral context like error cases or provider-specific details. The output schema reduces the need to explain returns, but more guidance on usage and transparency would improve completeness.

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

Parameters4/5

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

The description adds significant meaning beyond the input schema, which has 0% description coverage. It explains each parameter's purpose: 'image_url' as the source image URL, 'prompt' for describing transformations, 'function' with default and supported options, and 'mask_image_url' as required for a specific function. This compensates well for the schema's lack of descriptions, though it doesn't detail format constraints (e.g., URL validity).

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: 'Transform an existing image from a URL using the configured image provider.' It specifies the verb ('transform'), resource ('image from a URL'), and method ('using the configured image provider'), which distinguishes it from sibling tools like 'generate_image_from_text' (creation from text) and 'transform_image_from_file' (transformation from a file). However, it doesn't explicitly differentiate from 'transform_image_from_encoded' (transformation from encoded data), leaving some ambiguity.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It mentions sibling tools in the context signals but offers no explicit comparisons, prerequisites, or scenarios for choosing this tool over others like 'transform_image_from_file' or 'transform_image_from_encoded'. Usage is implied through the description of parameters, but no clear when/when-not instructions are given.

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/ECNU3D/universal-image-generator-mcp'

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