Skip to main content
Glama
qhdrl12

Gemini Image Generator MCP Server

transform_image_from_file

Modify existing images using text prompts with Google's Gemini model. Provide an image file path and descriptive prompt to transform images.

Instructions

Transform an existing image file based on the given text prompt using Google's Gemini model.

Args:
    image_file_path: Path to the image file to be transformed
    prompt: Text prompt describing the desired transformation or modifications
    
Returns:
    Path to the transformed image file saved on the server

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
image_file_pathYes
promptYes

Implementation Reference

  • The handler function for the 'transform_image_from_file' tool. It is registered via the @mcp.tool() decorator. Loads the image from file path, translates the prompt, and delegates to process_image_transform for Gemini API interaction.
    @mcp.tool()
    async def transform_image_from_file(image_file_path: str, prompt: str) -> Tuple[bytes, str]:
        """Transform an existing image file based on the given text prompt using Google's Gemini model.
    
        Args:
            image_file_path: Path to the image file to be transformed
            prompt: Text prompt describing the desired transformation or modifications
            
        Returns:
            Path to the transformed image file saved on the server
        """
        try:
            logger.info(f"Processing transform_image_from_file request with prompt: {prompt}")
            logger.info(f"Image file path: {image_file_path}")
    
            # Validate file path
            if not os.path.exists(image_file_path):
                raise ValueError(f"Image file not found: {image_file_path}")
    
            # Translate the prompt to English
            translated_prompt = await translate_prompt(prompt)
                
            # Load the source image directly using PIL
            try:
                source_image = PIL.Image.open(image_file_path)
                logger.info(f"Successfully loaded image from file: {image_file_path}")
            except PIL.UnidentifiedImageError:
                logger.error("Error: Could not identify image format")
                raise ValueError("Could not identify image format. Supported formats include PNG, JPEG, GIF, WebP.")
            except Exception as e:
                logger.error(f"Error: Could not load image: {str(e)}")
                raise 
            
            # Process the transformation
            return await process_image_transform(source_image, translated_prompt, prompt)
            
        except Exception as e:
            error_msg = f"Error transforming image: {str(e)}"
            logger.error(error_msg)
            return error_msg
Behavior2/5

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

No annotations are provided, so the description carries full burden. It mentions the tool saves the transformed file on the server, which is useful behavioral context. However, it lacks critical details like required permissions, file format limitations, transformation scope, error handling, or whether the operation is reversible/destructive.

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 efficiently structured with a clear purpose statement followed by labeled sections for Args and Returns. Every sentence adds value without redundancy, and information is front-loaded appropriately.

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 no annotations, no output schema, and 2 parameters, the description covers purpose and parameters adequately. However, for a transformation tool with potential complexity (image processing via Gemini), it lacks details about output format, file location specifics, or error cases, leaving gaps in 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?

With 0% schema description coverage, the description fully compensates by explaining both parameters: 'image_file_path' as 'Path to the image file to be transformed' and 'prompt' as 'Text prompt describing the desired transformation or modifications'. This adds essential meaning beyond the bare schema.

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 tool's purpose with specific verb ('Transform') and resource ('existing image file'), and distinguishes it from siblings by specifying it works from a file path rather than text or encoded input. The mention of using Google's Gemini model adds technical specificity.

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

Usage Guidelines4/5

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

The description implies usage context by specifying it transforms 'an existing image file' and uses a 'text prompt', which differentiates it from 'generate_image_from_text' (creates new images) and 'transform_image_from_encoded' (uses encoded input). However, it doesn't explicitly state when to choose this tool over alternatives or any prerequisites.

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/qhdrl12/mcp-server-gemini-image-generator'

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