Skip to main content
Glama

comfy_save_workflow

Store workflow JSON in the MCP library with metadata for organization and future reuse.

Instructions

Save a workflow JSON to the MCP library for later reuse. Includes metadata like description and tags for organization.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYes
workflowYes
descriptionNo
tagsNo
overwriteNo

Implementation Reference

  • The main handler function for the 'comfy_save_workflow' tool. Validates input, processes the workflow JSON, checks for overwrites, creates metadata, and saves it to the workflow library using saveWorkflowToLibrary.
    export async function handleSaveWorkflow(input: SaveWorkflowInput) {
      try {
        // Validate workflow name
        if (!validateWorkflowName(input.name)) {
          throw ComfyUIErrorBuilder.validationError(
            'Invalid workflow name. Use only alphanumeric characters, hyphens, and underscores.'
          );
        }
    
        // Parse and validate workflow
        const processor = new WorkflowProcessor();
        const workflow = processor.parseWorkflow(input.workflow);
    
        if (!validateWorkflowJSON(workflow)) {
          throw ComfyUIErrorBuilder.invalidWorkflow('Invalid workflow structure');
        }
    
        // Check if exists and overwrite is false
        const config = getConfig();
        const libraryPath = getFullPath(config.paths.workflow_library);
        const filePath = join(libraryPath, `${input.name}.json`);
    
        if (existsSync(filePath) && !input.overwrite) {
          throw ComfyUIErrorBuilder.validationError(
            `Workflow "${input.name}" already exists. Set overwrite=true to replace it.`
          );
        }
    
        // Create metadata
        const now = new Date().toISOString();
        const metadata = {
          name: input.name,
          description: input.description,
          tags: input.tags || [],
          created_at: existsSync(filePath) ? JSON.parse(require('fs').readFileSync(filePath, 'utf-8')).created_at : now,
          updated_at: now,
          workflow
        };
    
        // Save to library
        const savedPath = saveWorkflowToLibrary(input.name, metadata);
    
        return {
          content: [{
            type: "text",
            text: JSON.stringify({
              name: input.name,
              path: savedPath,
              message: `Workflow "${input.name}" saved successfully`
            }, 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
        };
      }
    }
  • src/server.ts:93-96 (registration)
    Registration of the 'comfy_save_workflow' tool in the MCP server, including name, description, and input schema reference.
      name: 'comfy_save_workflow',
      description: 'Save a workflow JSON to the MCP library for later reuse. Includes metadata like description and tags for organization.',
      inputSchema: zodToJsonSchema(SaveWorkflowSchema) as any,
    },
  • Zod schema defining the input structure for the 'comfy_save_workflow' tool, including validation for name, workflow, description, tags, and overwrite flag.
    export const SaveWorkflowSchema = z.object({
      name: z.string().regex(/^[a-zA-Z0-9_-]+$/),
      workflow: z.union([z.string(), z.record(z.any())]),
      description: z.string().optional(),
      tags: z.array(z.string()).optional(),
      overwrite: z.boolean().optional().default(false)
    });
  • src/server.ts:164-165 (registration)
    Switch case in the tool call handler that routes 'comfy_save_workflow' calls to the handleSaveWorkflow function.
    case 'comfy_save_workflow':
      return await handleSaveWorkflow(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 offers minimal behavioral insight. It mentions metadata inclusion (description, tags) but omits critical details: whether saving requires authentication, if it's idempotent (hinted by 'overwrite' parameter but not explained), potential rate limits, error conditions (e.g., duplicate names), or what happens on success (e.g., confirmation message). For a write operation with zero annotation coverage, this is inadequate.

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 concise with two sentences that efficiently convey the core purpose and metadata aspects. It's front-loaded with the main action and avoids unnecessary details. However, the second sentence could be integrated more smoothly, and there's room to add brief usage context without bloating.

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 the complexity (a write operation with 5 parameters), lack of annotations, and no output schema, the description is incomplete. It doesn't address behavioral aspects like permissions, idempotency, or error handling, and parameter coverage is partial. For a tool that saves data to a library, more context on success/failure outcomes and operational constraints is needed.

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 0%, so the description must compensate but only partially does. It mentions 'metadata like description and tags' which maps to two parameters (description, tags), but doesn't explain 'name' (required, with pattern), 'workflow' (required, JSON or object), or 'overwrite' (default false). Since it covers 2 of 5 parameters (40%), it adds some value but falls short of fully compensating for the schema gap.

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 action ('Save a workflow JSON') and resource ('to the MCP library for later reuse'), which distinguishes it from sibling tools like comfy_delete_workflow or comfy_load_workflow. However, it doesn't explicitly differentiate from comfy_submit_workflow (which might execute workflows) or comfy_list_workflows (which lists them), leaving some ambiguity about exact sibling distinctions.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing an existing workflow), exclusions (e.g., not for executing workflows), or direct comparisons to siblings like comfy_load_workflow (for retrieval) or comfy_delete_workflow (for removal), leaving usage context unclear.

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