Skip to main content
Glama

get_job_status

Check execution status and retrieve generated images from ComfyUI workflows using prompt IDs to monitor job progress and access outputs.

Instructions

Get status and results of a ComfyUI job.

Checks execution status and optionally downloads generated images.

Args: prompt_id: The prompt ID returned by execute_workflow server_address: ComfyUI server address download_images: Whether to download generated images image_save_path: Directory to save images (relative to workflows/)

Returns: Job status with completion info and image paths if downloaded

Examples: get_job_status("12345-abcde-67890") get_job_status("12345-abcde-67890", download_images=True)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
prompt_idYes
server_addressNo127.0.0.1:8188
download_imagesNo
image_save_pathNooutputs

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The core handler function for the 'get_job_status' tool. Decorated with @mcp.tool for registration. It fetches job status from ComfyUI server using ComfyUIClient, handles queued/running/completed/failed states, extracts image outputs, and optionally downloads images to the specified path.
    @mcp.tool
    async def get_job_status(
        ctx: Context,
        prompt_id: str,
        server_address: str = DEFAULT_COMFYUI_SERVER,
        download_images: bool = False,
        image_save_path: str = "outputs"
    ) -> Dict[str, Any]:
        """Get status and results of a ComfyUI job.
        
        Checks execution status and optionally downloads generated images.
        
        Args:
            prompt_id: The prompt ID returned by execute_workflow
            server_address: ComfyUI server address
            download_images: Whether to download generated images
            image_save_path: Directory to save images (relative to workflows/)
        
        Returns:
            Job status with completion info and image paths if downloaded
        
        Examples:
            get_job_status("12345-abcde-67890")
            get_job_status("12345-abcde-67890", download_images=True)
        """
        await ctx.info(f"Checking job status for {prompt_id}")
        
        try:
            client = ComfyUIClient(server_address)
            
            # Get execution history
            history = await client.get_history(prompt_id)
            
            if prompt_id not in history:
                # Check queue
                queue = await client.get_queue_status()
                
                # Check if still in queue
                for item in queue.get("queue_running", []) + queue.get("queue_pending", []):
                    if item[1] == prompt_id:
                        return {
                            "prompt_id": prompt_id,
                            "status": "running" if item in queue.get("queue_running", []) else "queued",
                            "position": queue.get("queue_pending", []).index(item) + 1 if item in queue.get("queue_pending", []) else 0
                        }
                
                return {
                    "prompt_id": prompt_id,
                    "status": "not_found",
                    "message": "Job not found in history or queue"
                }
            
            # Parse execution results
            execution = history[prompt_id]
            status = execution.get("status", {})
            
            result = {
                "prompt_id": prompt_id,
                "status": "completed" if status.get("completed", False) and status.get("status_str") == "success" else "failed" if status.get("completed", False) else "running",
                "messages": status.get("messages", [])
            }
            
            # Extract outputs if completed
            if status.get("completed", False):
                outputs = execution.get("outputs", {})
                result["outputs"] = {}
                
                for node_id, output in outputs.items():
                    if "images" in output:
                        result["outputs"][node_id] = {
                            "type": "images",
                            "count": len(output["images"]),
                            "images": output["images"]
                        }
                
                if download_images and result["outputs"]:
                    await ctx.info("Downloading generated images...")
                    
                    # Create save directory
                    save_dir = Path(image_save_path)
                    save_dir.mkdir(parents=True, exist_ok=True)
                    
                    downloaded_files = []
                    
                    for node_id, output in result["outputs"].items():
                        if output["type"] == "images":
                            for i, image_info in enumerate(output["images"]):
                                # Download image
                                image_data = await client.download_image(
                                    image_info["filename"],
                                    image_info["subfolder"],
                                    image_info["type"]
                                )
                                
                                # Save with descriptive name
                                filename = f"{prompt_id}_{node_id}_{i:03d}_{image_info['filename']}"
                                file_path = save_dir / filename
                                
                                file_path.write_bytes(image_data)
                                downloaded_files.append(str(file_path))
                    
                    result["downloaded_files"] = downloaded_files
                    await ctx.info(f"✓ Downloaded {len(downloaded_files)} image(s) to {save_dir}")
            
            return result
            
        except Exception as e:
            raise ToolError(f"Failed to get job status: {e}")
  • ComfyUIClient helper class providing the API client methods used by get_job_status: get_history for execution results, get_queue_status for queue position, and download_image for fetching generated images.
    class ComfyUIClient:
        """Client for ComfyUI API operations"""
        
        def __init__(self, server_address: str = DEFAULT_COMFYUI_SERVER):
            self.server_address = server_address
            self.base_url = f"http://{server_address}"
            self.ws_url = f"ws://{server_address}/ws"
            self.client_id = str(uuid.uuid4())
        
        async def queue_prompt(self, workflow: Dict[str, Any]) -> str:
            """Submit workflow for execution"""
            data = {
                "prompt": workflow,
                "client_id": self.client_id
            }
            
            async with httpx.AsyncClient() as client:
                response = await client.post(
                    f"{self.base_url}/prompt",
                    json=data,
                    headers={'Content-Type': 'application/json'}
                )
                response.raise_for_status()
                result = response.json()
                
                if "error" in result:
                    raise ToolError(f"ComfyUI error: {result['error']}")
                
                return result.get("prompt_id")
        
        async def get_history(self, prompt_id: str) -> Dict[str, Any]:
            """Get execution history and results"""
            async with httpx.AsyncClient() as client:
                response = await client.get(f"{self.base_url}/history/{prompt_id}")
                response.raise_for_status()
                return response.json()
        
        async def get_queue_status(self) -> Dict[str, Any]:
            """Get current queue status"""
            async with httpx.AsyncClient() as client:
                response = await client.get(f"{self.base_url}/queue")
                response.raise_for_status()
                return response.json()
        
        async def download_image(self, filename: str, subfolder: str = "", folder_type: str = "output") -> bytes:
            """Download generated image"""
            params = {
                "filename": filename,
                "subfolder": subfolder,
                "type": folder_type
            }
            
            async with httpx.AsyncClient() as client:
                response = await client.get(f"{self.base_url}/view", params=params)
                response.raise_for_status()
                return response.content
Behavior3/5

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

With no annotations provided, the description carries the full burden. It discloses key behavioral traits: it's a read operation (no mutation implied), it can download images to a specific directory, and it returns status with image paths. However, it lacks details on error handling (e.g., invalid prompt_id), rate limits, authentication needs, or whether it modifies server state (e.g., by downloading).

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 well-structured and front-loaded: the first sentence states the core purpose, followed by specific functionality. The Args/Returns/Examples sections are organized efficiently with no wasted sentences. Each part adds value, such as clarifying parameter relationships and providing usage examples.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given 4 parameters with 0% schema coverage and an output schema (implied by 'Returns'), the description is mostly complete. It explains all parameters and the return value ('Job status with completion info and image paths'). However, for a job status tool with no annotations, it could better cover edge cases (e.g., job failures, timeouts) or server interaction details.

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?

Schema description coverage is 0%, so the description must compensate. It adds meaningful semantics for all 4 parameters: 'prompt_id' is linked to 'execute_workflow', 'server_address' is implied as ComfyUI server, 'download_images' controls image retrieval, and 'image_save_path' specifies directory relative to 'workflows/'. This goes beyond schema types, though it doesn't detail formats (e.g., prompt_id structure).

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 verbs ('Get status and results', 'Checks execution status', 'download generated images') and identifies the resource ('ComfyUI job'). It distinguishes from siblings like 'execute_workflow' (which creates jobs) and 'list_comfyui_queue' (which lists queued jobs) by focusing on status retrieval for specific jobs.

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 context for when to use this tool: after 'execute_workflow' returns a prompt_id, to check job completion and optionally download results. It mentions the sibling 'execute_workflow' as the source of prompt_id. However, it doesn't explicitly state when NOT to use it or compare with alternatives like 'list_comfyui_queue' for broader status checks.

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/christian-byrne/comfy-mcp'

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