Skip to main content
Glama

comfy_cancel_generation

Cancel an active AI image generation or remove pending tasks from the ComfyUI queue to manage workflow execution.

Instructions

Cancel a specific generation or interrupt the currently executing generation. Can optionally remove from queue.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
prompt_idNo
delete_from_queueNo

Implementation Reference

  • The main handler function that implements the tool logic: interrupts the ComfyUI generation using the client, optionally deletes a specific queue item by prompt_id, and returns success/error responses.
    export async function handleCancelGeneration(input: CancelGenerationInput) {
      try {
        const client = getComfyUIClient();
    
        if (input.prompt_id) {
          // Cancel specific prompt
          if (input.delete_from_queue) {
            await client.deleteQueueItem(input.prompt_id);
          }
          await client.interrupt();
    
          return {
            content: [{
              type: "text",
              text: JSON.stringify({
                cancelled: true,
                prompt_id: input.prompt_id,
                message: `Generation ${input.prompt_id} cancelled`
              }, null, 2)
            }]
          };
        } else {
          // Interrupt current
          await client.interrupt();
    
          return {
            content: [{
              type: "text",
              text: JSON.stringify({
                cancelled: true,
                message: "Current generation interrupted"
              }, null, 2)
            }]
          };
        }
      } catch (error: any) {
        if (error.error) {
          return {
            content: [{
              type: "text",
              text: JSON.stringify(error, null, 2)
            }],
            isError: true
          };
        }
    
        return {
          content: [{
            type: "text",
            text: JSON.stringify(ComfyUIErrorBuilder.executionError(error.message), null, 2)
          }],
          isError: true
        };
      }
    }
  • Zod schema for input validation: optional prompt_id (to target specific generation) and delete_from_queue (default true).
    export const CancelGenerationSchema = z.object({
      prompt_id: z.string().optional(),
      delete_from_queue: z.boolean().optional().default(true)
    });
  • src/server.ts:120-124 (registration)
    Tool registration in the ListTools response: defines name, description, and references the input schema.
    {
      name: 'comfy_cancel_generation',
      description: 'Cancel a specific generation or interrupt the currently executing generation. Can optionally remove from queue.',
      inputSchema: zodToJsonSchema(CancelGenerationSchema) as any,
    },
  • src/server.ts:179-180 (registration)
    Switch case in CallToolRequestHandler that dispatches the tool call to the handler function.
    case 'comfy_cancel_generation':
      return await handleCancelGeneration(args as any);
Behavior2/5

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

With no annotations provided, the description carries full burden but lacks critical behavioral details. It mentions cancellation and optional deletion but doesn't disclose whether this requires specific permissions, if it's reversible, what happens to partial results, or error conditions (e.g., invalid prompt_id). For a mutation tool with zero annotation coverage, this is a significant gap.

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 a single, efficient sentence with zero waste. It's front-loaded with the core action ('cancel'/'interrupt') and includes the optional feature concisely. Every word earns its place without redundancy.

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

Completeness2/5

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

Given a mutation tool with 2 parameters, 0% schema coverage, no annotations, and no output schema, the description is incomplete. It lacks details on permissions, side effects, return values, error handling, and parameter specifics. While concise, it doesn't provide enough context for safe and effective use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/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 but adds minimal parameter context. It mentions 'specific generation' (hinting at prompt_id) and 'remove from queue' (hinting at delete_from_queue), but doesn't explain parameter meanings, formats, or interactions (e.g., if prompt_id is omitted, it cancels the current execution). With 2 undocumented parameters, this is inadequate.

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 ('cancel', 'interrupt') and resources ('a specific generation', 'the currently executing generation'), plus an optional action ('remove from queue'). It distinguishes itself from sibling tools like comfy_clear_queue (which clears the entire queue) and comfy_get_status (which only checks status).

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 context by mentioning 'currently executing generation' and 'queue', suggesting it's for active or queued tasks. However, it doesn't explicitly state when to use this versus alternatives like comfy_clear_queue for bulk operations or comfy_delete_workflow for workflow management, nor does it specify prerequisites or exclusions.

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/Nikolaibibo/claude-comfyui-mcp'

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