Skip to main content
Glama
supercurses

Powerpoint MCP Server

by supercurses

generate-and-save-image

Generate custom images using FLUX AI and save them as PNG files for use in PowerPoint presentations. Provide a text prompt and filename to create visual content.

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
promptYesDescription of the image to generate in the form of a prompt.
file_nameYesFilename of the image. Include the extension of .png

Implementation Reference

  • Registration of the 'generate-and-save-image' tool in the @server.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"],
        },
    ),
  • Dispatch handler logic within @server.call_tool(): validates arguments, sanitizes file path, invokes VisionManager, and returns success/error text content.
    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)}"
                )
            ]
  • Primary tool execution logic in VisionManager class: generates image using FLUX model via Together AI, downloads with requests, opens with PIL, and saves to disk.
    async def generate_and_save_image(self, prompt: str, output_path: str) -> str:
        """Generate an image using Together AI/Flux Model and save it to the specified path."""
    
        api_key = os.environ.get('TOGETHER_API_KEY')
        if not api_key:
            raise ValueError("TOGETHER_API_KEY environment variable not set.")
    
        client = Together(api_key=api_key)
    
        try:
            # Generate the image
            response = client.images.generate(
                prompt=prompt,
                width=1024,
                height=1024,
                steps=4,
                model="black-forest-labs/FLUX.1-schnell-Free",
                n=1,
            )
        except Exception as e:
            raise ValueError(f"Failed to generate image: {str(e)}")
    
        image_url = response.data[0].url
    
        # Download the image
        try:
            response = requests.get(image_url)
            if response.status_code != 200:
                raise ValueError(f"Failed to download generated image: HTTP {response.status_code}")
        except requests.RequestException as e:
            raise ValueError(f"Network error downloading image: {str(e)}")
    
        # Save the image
        try:
            image = Image.open(BytesIO(response.content))
            # 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 a directory for image: str({e})")
            # Save the image
            image.save(output_path)
        except (IOError, OSError) as e:
            raise ValueError(f"Failed to save image to {output_path}: {str(e)}")
    
        return output_path

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

B3.4/5.0
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.