Skip to main content
Glama
Ichigo3766

PowerPoint MCP Server

by Ichigo3766

generate-and-save-image

Create and save custom PNG images using FLUX model prompts on the PowerPoint MCP Server. Specify a description and filename to generate and store images for presentations.

Instructions

Generates an image using a FLUX model and save the image to the specified path. The tool will return a PNG file path. It should be used when the user asks to generate or create an image or a picture.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_nameYesFilename of the image. Include the extension of .png
promptYesDescription of the image to generate in the form of a prompt.

Implementation Reference

  • Dispatch handler in the main tool caller that validates arguments, sanitizes the output path, and delegates image generation to VisionManager.
    elif name == "generate-and-save-image":
        prompt = arguments.get("prompt")
        file_name = arguments.get("file_name")
        try:
            safe_file_path = sanitize_path(folder_path, file_name)
        except ValueError as e:
            raise ValueError(f"Invalid file path: {str(e)}")
    
        if not all([prompt, file_name]):
            raise ValueError("Missing required arguments")
    
        try:
            saved_path = await vision_manager.generate_and_save_image(prompt, str(safe_file_path))
            return [
                types.TextContent(
                    type="text",
                    text=f"Successfully generated and saved image to: {saved_path}"
                )
            ]
        except Exception as e:
            return [
                types.TextContent(
                    type="text",
                    text=f"Failed to generate image: {str(e)}"
                )
            ]
  • Core implementation that generates image using Stable Diffusion WebUI API (FLUX model via SD), decodes base64 response, and saves as PNG to the specified path.
    async def generate_and_save_image(self, prompt: str, output_path: str) -> str:
        """Generate an image using Stable Diffusion API and save it to the specified path."""
        headers = {'Content-Type': 'application/json'}
        auth = None
        if self.auth_user and self.auth_pass:
            auth = (self.auth_user, self.auth_pass)
    
        payload = {
            "prompt": prompt,
            "negative_prompt": "",
            "steps": 4,
            "width": 1024,
            "height": 1024,
            "cfg_scale": 1,
            "sampler_name": "Euler",
            "seed": -1,
            "n_iter": 1,
            "scheduler": "Simple"
        }
    
        try:
            # Generate the image
            response = requests.post(
                f"{self.sd_url}/sdapi/v1/txt2img",
                headers=headers,
                auth=auth,
                json=payload,
                timeout=3600
            )
            response.raise_for_status()
            
            if not response.json().get('images'):
                raise ValueError("No images generated")
            
            # Get the first image
            image_data = response.json()['images'][0]
            if ',' in image_data:
                image_data = image_data.split(',')[1]
            
            # Convert base64 to image
            image_bytes = base64.b64decode(image_data)
            image = Image.open(BytesIO(image_bytes))
    
            # Ensure the save directory exists
            try:
                os.makedirs(os.path.dirname(output_path), exist_ok=True)
            except OSError as e:
                raise ValueError(f"Failed to create directory for image: {str(e)}")
    
            # Save the image
            image.save(output_path)
            
        except requests.RequestException as e:
            raise ValueError(f"Failed to generate image: {str(e)}")
        except (IOError, OSError) as e:
            raise ValueError(f"Failed to save image to {output_path}: {str(e)}")
    
        return output_path
  • Tool registration in list_tools() handler, including name, description, and input schema definition.
    types.Tool(
        name="generate-and-save-image",
        description="Generates an image using a FLUX model and save the image to the specified path. The tool "
                    "will return a PNG file path. It should be used when the user asks to generate or create an "
                    "image or a picture.",
        inputSchema={
            "type": "object",
            "properties": {
                "prompt": {
                    "type": "string",
                    "description": "Description of the image to generate in the form of a prompt.",
                },
                "file_name": {
                    "type": "string",
                    "description": "Filename of the image. Include the extension of .png",
                },
            },
            "required": ["prompt", "file_name"],
        },
    ),
  • Utility function to sanitize the output file path to prevent directory traversal.
    def sanitize_path(base_path: str, file_name: str) -> str:
        """
        Ensure that the resulting path doesn't escape outside the base directory
        Returns a safe, normalized path
        """
    
        joined_path = os.path.join(base_path, file_name)
        normalized_path = os.path.normpath(joined_path)
    
        if not normalized_path.startswith(base_path):
            raise ValueError(f"Invalid path. Attempted to access location outside allowed directory.")
    
        return normalized_path
Behavior2/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 of behavioral disclosure. While it mentions the tool 'will return a PNG file path,' it doesn't cover important behavioral aspects like error handling, file overwriting behavior, performance characteristics, or any limitations of the FLUX model. For a tool that generates and saves files with no annotation coverage, this leaves significant gaps in understanding its behavior.

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 with two sentences that each serve distinct purposes: the first states what the tool does, and the second provides usage guidance. There's no wasted text, though it could be slightly more structured by separating behavioral information from usage guidance.

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 that there's no output schema and no annotations, the description provides basic purpose and usage information but lacks important contextual details. It doesn't explain what happens if the file already exists, what quality/size limitations the FLUX model might have, or error scenarios. For a tool that creates files with no structured output documentation, this leaves the agent with incomplete understanding of what to expect.

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%, with both parameters well-documented in the schema. The description doesn't add any additional parameter semantics beyond what's already in the schema. According to the scoring rules, when schema_description_coverage is high (>80%), the baseline is 3 even with no param info in the description, which applies here.

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: 'Generates an image using a FLUX model and save the image to the specified path.' This specifies the verb (generate and save), resource (image), and method (FLUX model). However, it doesn't explicitly differentiate from sibling tools, which are all presentation-related, making this distinction implicit rather than explicit.

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 provides clear usage context: 'It should be used when the user asks to generate or create an image or a picture.' This gives explicit when-to-use guidance. However, it doesn't mention when NOT to use it or name specific alternatives among the sibling tools, which are presentation-focused and not direct image generation alternatives.

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

Related 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/Ichigo3766/powerpoint-mcp'

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