Skip to main content
Glama

comfy_upload_image

Upload images to ComfyUI's input folder for AI workflow integration. Specify custom filenames and control file overwriting to prepare visual assets for processing.

Instructions

Upload an image to ComfyUI's input folder for use in workflows. Supports custom filenames and overwrite control.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
image_pathYes
filenameNo
overwriteNo

Implementation Reference

  • MCP handler function for comfy_upload_image tool. Calls uploadImage helper, handles errors, and returns formatted response.
    export async function handleUploadImage(input: UploadImageInput) {
      try {
        const result = uploadImage(input.image_path, input.filename, input.overwrite);
    
        return {
          content: [{
            type: "text",
            text: JSON.stringify({
              filename: result.filename,
              path: result.path,
              size: result.size,
              message: `Image uploaded successfully as ${result.filename}`
            }, null, 2)
          }]
        };
      } catch (error: any) {
        if (error.message.includes('not found')) {
          return {
            content: [{
              type: "text",
              text: JSON.stringify(ComfyUIErrorBuilder.fileNotFound(input.image_path), null, 2)
            }],
            isError: true
          };
        }
    
        return {
          content: [{
            type: "text",
            text: JSON.stringify(ComfyUIErrorBuilder.executionError(error.message), null, 2)
          }],
          isError: true
        };
      }
    }
  • Zod input schema for validating parameters of the comfy_upload_image tool.
    export const UploadImageSchema = z.object({
      image_path: z.string(),
      filename: z.string().optional(),
      overwrite: z.boolean().optional().default(false)
    });
  • src/server.ts:130-134 (registration)
    Registration of the comfy_upload_image tool in the MCP server's tool list, providing name, description, and input schema.
    {
      name: 'comfy_upload_image',
      description: 'Upload an image to ComfyUI\'s input folder for use in workflows. Supports custom filenames and overwrite control.',
      inputSchema: zodToJsonSchema(UploadImageSchema) as any,
    },
  • Core utility function that uploads the image by copying it to ComfyUI's input directory, handling directory creation, filename sanitization, conflicts, and validation.
    export function uploadImage(sourcePath: string, filename?: string, overwrite: boolean = false): { filename: string; path: string; size: number } {
      const config = getConfig();
      const inputDir = getFullPath(config.paths.input);
    
      // Ensure input directory exists
      if (!existsSync(inputDir)) {
        mkdirSync(inputDir, { recursive: true });
      }
    
      // Validate source file
      if (!existsSync(sourcePath)) {
        throw new Error(`Source file not found: ${sourcePath}`);
      }
    
      // Determine target filename
      let targetFilename = filename || basename(sourcePath);
      targetFilename = sanitizeFilename(targetFilename);
    
      // Validate image format
      if (!validateImageFormat(targetFilename)) {
        throw new Error(`Invalid image format: ${targetFilename}`);
      }
    
      // Handle existing file
      let targetPath = join(inputDir, targetFilename);
      if (existsSync(targetPath) && !overwrite) {
        const ext = extname(targetFilename);
        const nameWithoutExt = basename(targetFilename, ext);
        let counter = 1;
        do {
          targetFilename = `${nameWithoutExt}_${counter}${ext}`;
          targetPath = join(inputDir, targetFilename);
          counter++;
        } while (existsSync(targetPath));
      }
    
      // Copy file
      copyFileSync(sourcePath, targetPath);
      const stat = statSync(targetPath);
    
      return {
        filename: targetFilename,
        path: targetPath,
        size: stat.size
      };
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions 'overwrite control', which hints at mutation behavior, but does not detail permissions, side effects, error handling, or rate limits. This is inadequate for a tool that modifies system state, leaving significant gaps in understanding its operational traits.

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 and concise, consisting of two sentences that directly state the tool's function and key features without unnecessary elaboration. Every sentence adds value, making it efficient and well-structured for quick comprehension.

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 of an upload operation with no annotations, 0% schema coverage, and no output schema, the description is incomplete. It lacks details on return values, error conditions, and full parameter semantics, which are crucial for an agent to use the tool effectively in workflows.

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?

The description adds some meaning by mentioning 'custom filenames and overwrite control', which relates to the 'filename' and 'overwrite' parameters. However, with 0% schema description coverage and three parameters, it does not fully compensate for the lack of schema details, such as explaining 'image_path' format or constraints, resulting in a baseline score.

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 ('Upload an image') and resource ('to ComfyUI's input folder for use in workflows'), making the purpose evident. However, it does not explicitly differentiate from sibling tools like 'comfy_get_output_images' or 'comfy_submit_workflow', which might involve images but serve different purposes, so it falls short of a perfect score.

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 mentions the tool's function but does not specify scenarios, prerequisites, or exclusions, such as when to prefer this over other image-handling tools in the sibling list, leaving the agent with minimal usage context.

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