Skip to main content
Glama

comfy_get_output_images

Retrieve recent generated images from ComfyUI's output folder with customizable sorting and filtering options for easy access to AI-generated content.

Instructions

List recent output images from ComfyUI's output folder. Returns full Windows paths that Claude Desktop can read.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNo
sortNonewest
filterNo

Implementation Reference

  • MCP tool handler function that processes input, calls the getOutputImages utility, formats the response as MCP content or error.
    export async function handleGetOutputImages(input: GetOutputImagesInput) {
      try {
        const images = getOutputImages(input.limit, input.sort, input.filter);
    
        return {
          content: [{
            type: "text",
            text: JSON.stringify({
              images,
              total_count: images.length
            }, null, 2)
          }]
        };
      } catch (error: any) {
        return {
          content: [{
            type: "text",
            text: JSON.stringify(ComfyUIErrorBuilder.executionError(error.message), null, 2)
          }],
          isError: true
        };
      }
    }
  • Core utility function implementing the logic to scan ComfyUI output directory, filter/sort image files, and return metadata array.
    export function getOutputImages(limit: number = 20, sort: 'newest' | 'oldest' | 'name' = 'newest', filter?: string): ImageInfo[] {
      const config = getConfig();
      const outputDir = getFullPath(config.paths.output);
    
      if (!existsSync(outputDir)) {
        return [];
      }
    
      const files = readdirSync(outputDir);
      const images: ImageInfo[] = [];
    
      for (const file of files) {
        if (filter && !file.includes(filter)) continue;
        if (!validateImageFormat(file)) continue;
    
        const fullPath = join(outputDir, file);
        const stat = statSync(fullPath);
    
        if (stat.isFile()) {
          images.push({
            filename: file,
            path: fullPath,
            size: stat.size,
            created_at: stat.birthtime.toISOString(),
            modified_at: stat.mtime.toISOString()
          });
        }
      }
    
      // Sort
      if (sort === 'newest') {
        images.sort((a, b) => new Date(b.created_at).getTime() - new Date(a.created_at).getTime());
      } else if (sort === 'oldest') {
        images.sort((a, b) => new Date(a.created_at).getTime() - new Date(b.created_at).getTime());
      } else {
        images.sort((a, b) => a.filename.localeCompare(b.filename));
      }
    
      return images.slice(0, limit);
    }
  • Zod schema and TypeScript type for GetOutputImagesInput defining optional parameters: limit, sort, filter.
    // Get Output Images Tool
    export const GetOutputImagesSchema = z.object({
      limit: z.number().int().optional().default(20),
      sort: z.enum(["newest", "oldest", "name"]).optional().default("newest"),
      filter: z.string().optional()
    });
    
    // Type exports
    export type SubmitWorkflowInput = z.infer<typeof SubmitWorkflowSchema>;
    export type GenerateSimpleInput = z.infer<typeof GenerateSimpleSchema>;
    export type GetStatusInput = z.infer<typeof GetStatusSchema>;
    export type WaitForCompletionInput = z.infer<typeof WaitForCompletionSchema>;
    export type ListModelsInput = z.infer<typeof ListModelsSchema>;
    export type SaveWorkflowInput = z.infer<typeof SaveWorkflowSchema>;
    export type LoadWorkflowInput = z.infer<typeof LoadWorkflowSchema>;
    export type ListWorkflowsInput = z.infer<typeof ListWorkflowsSchema>;
    export type DeleteWorkflowInput = z.infer<typeof DeleteWorkflowSchema>;
    export type CancelGenerationInput = z.infer<typeof CancelGenerationSchema>;
    export type ClearQueueInput = z.infer<typeof ClearQueueSchema>;
    export type UploadImageInput = z.infer<typeof UploadImageSchema>;
    export type GetOutputImagesInput = z.infer<typeof GetOutputImagesSchema>;
  • src/server.ts:136-139 (registration)
    Tool registration entry in the listTools response, providing name, description, and input schema.
      name: 'comfy_get_output_images',
      description: 'List recent output images from ComfyUI\'s output folder. Returns full Windows paths that Claude Desktop can read.',
      inputSchema: zodToJsonSchema(GetOutputImagesSchema) as any,
    },
  • src/server.ts:188-190 (registration)
    Dispatch in the CallToolRequest handler switch statement routing to the tool handler.
    case 'comfy_get_output_images':
      return await handleGetOutputImages(args as any);
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 of behavioral disclosure. It adds useful context about the return format ('full Windows paths that Claude Desktop can read'), which isn't obvious from the schema. However, it lacks details on permissions, rate limits, or error handling, leaving gaps for a tool that accesses file systems.

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 efficiently structured in a single sentence, with zero wasted words. Every part ('List recent output images', 'from ComfyUI's output folder', 'Returns full Windows paths that Claude Desktop can read') adds essential information without redundancy.

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

Completeness3/5

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

Given the tool's moderate complexity (3 parameters, no output schema, no annotations), the description is partially complete. It clarifies the tool's purpose and return format but lacks details on parameter usage, error conditions, or integration with siblings, making it adequate but with clear gaps for effective agent use.

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 for undocumented parameters. It does not explain the meaning or usage of 'limit', 'sort', or 'filter' parameters, failing to add value beyond the schema. The baseline is 3 since the schema provides some structure (e.g., enums for 'sort'), but the description offers no parameter insights.

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 specific action ('List recent output images') and resource ('from ComfyUI's output folder'), distinguishing it from siblings like comfy_get_queue or comfy_get_status that handle different resources. It precisely defines what the tool does without being vague or tautological.

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 does not mention prerequisites, exclusions, or compare it to sibling tools like comfy_list_workflows or comfy_upload_image, leaving the agent to infer usage context without explicit direction.

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