Skip to main content
Glama

get_result_image

Retrieve generated images from completed ComfyUI workflows by specifying prompt and node IDs.

Instructions

Get the result image from a completed prompt.

    Args:
        prompt_id: The prompt ID from submit_workflow()
        output_node_id: Node ID that produced the image

    Returns the image if available, or error message.
    

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
prompt_idYesPrompt ID
output_node_idYesOutput node ID

Implementation Reference

  • The handler function for the 'get_result_image' tool. It retrieves the prompt history from ComfyUI, verifies completion, extracts the image filename from the output node, downloads the image data, and returns it as an MCP Image object.
    @mcp.tool()
    def get_result_image(
        prompt_id: str = Field(description="Prompt ID"),
        output_node_id: str = Field(description="Output node ID"),
        ctx: Context = None,
    ):
        """Get the result image from a completed prompt.
    
        Args:
            prompt_id: The prompt ID from submit_workflow()
            output_node_id: Node ID that produced the image
    
        Returns the image if available, or error message.
        """
        if ctx:
            ctx.info(f"Getting result: {prompt_id}")
    
        try:
            history = comfy_get(f"/history/{prompt_id}")
            if prompt_id not in history:
                return "Prompt not found in history"
    
            entry = history[prompt_id]
            status = entry.get("status", {})
    
            if not status.get("completed"):
                return "Prompt not yet completed"
    
            outputs = entry.get("outputs", {})
            if output_node_id not in outputs:
                return f"No output from node {output_node_id}"
    
            images = outputs[output_node_id].get("images", [])
            if not images:
                return "No images in output"
    
            # Download image
            url = get_file_url(settings.comfy_url, images[0])
            from ..api import download_file
    
            image_data = download_file(url)
            if image_data:
                return Image(data=image_data, format="png")
            return "Failed to download image"
    
        except Exception as e:
            return f"Error: {e}"
  • Registration call for execution tools, including 'get_result_image', within the register_all_tools function.
    register_execution_tools(mcp)
  • Top-level registration of all tools by calling register_all_tools(mcp), which indirectly registers 'get_result_image'.
    register_all_tools(mcp)
  • Input schema defined via Pydantic Field descriptions for prompt_id and output_node_id parameters.
    def get_result_image(
        prompt_id: str = Field(description="Prompt ID"),
        output_node_id: str = Field(description="Output node ID"),
        ctx: Context = None,
    ):
Behavior3/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. It discloses that it returns 'the image if available, or error message,' which adds useful behavioral context about potential outcomes. However, it doesn't cover other traits like error conditions (e.g., invalid IDs), performance aspects, or authentication needs, leaving gaps for a tool with no annotation support.

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 front-loaded with the core purpose in the first sentence, followed by concise parameter explanations and return behavior. Every sentence earns its place without waste, and the structure is clear and efficient for a tool with two parameters.

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 100% schema coverage, the description is moderately complete. It covers the basic purpose and parameters but lacks details on error handling, image format, or dependencies (e.g., requiring a completed prompt). For a retrieval tool with no structured output info, it should do more to compensate.

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%, so the schema already documents both parameters ('prompt_id' and 'output_node_id'). The description adds minimal value by linking 'prompt_id' to 'submit_workflow()' and clarifying 'output_node_id' as the 'Node ID that produced the image,' but this is redundant with the schema. Baseline 3 is 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: 'Get the result image from a completed prompt.' It specifies the verb ('Get') and resource ('result image'), and distinguishes it from siblings like 'generate_image' (which creates images) or 'get_prompt_status' (which checks status). However, it doesn't explicitly contrast with all siblings, such as 'get_history' which might also retrieve results.

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 implies usage by referencing 'a completed prompt' and 'prompt ID from submit_workflow()', suggesting it should be used after workflow submission. However, it lacks explicit guidance on when not to use it (e.g., for non-image outputs) or clear alternatives among siblings like 'get_prompt_status' for checking completion first.

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/IO-AtelierTech/comfyui-mcp'

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