cancel_current
Stop long-running image generations in ComfyUI workflows by interrupting current processes or canceling specific prompt IDs.
Instructions
Interrupt current generation.
Args:
prompt_id: Optional specific prompt ID to cancel.
If not provided, cancels all running jobs.
Use this to stop a long-running generation.
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "cancel_current"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| prompt_id | No | Specific prompt ID to cancel |
Implementation Reference
- The handler function implementing the 'cancel_current' tool logic. It optionally takes a prompt_id and sends a POST request to ComfyUI's /interrupt endpoint to cancel running jobs. Includes inline schema via Pydantic Field and is registered via @mcp.tool() decorator.
@mcp.tool() def cancel_current( prompt_id: str = Field(default=None, description="Specific prompt ID to cancel"), ctx: Context = None, ) -> str: """Interrupt current generation. Args: prompt_id: Optional specific prompt ID to cancel. If not provided, cancels all running jobs. Use this to stop a long-running generation. """ if ctx: msg = f"Cancelling prompt {prompt_id}" if prompt_id else "Cancelling all" ctx.info(msg) data = {"prompt_id": prompt_id} if prompt_id else {} status, _ = comfy_post("/interrupt", data) return "Interrupted successfully" if status == 200 else "Interrupt failed"