Skip to main content
Glama
utils.ts1.65 kB
import { uploadImage, getOutputImages } from '../utils/filesystem.js'; import { ComfyUIErrorBuilder } from '../utils/errors.js'; import { UploadImageInput, GetOutputImagesInput } from '../types/tools.js'; 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 }; } } 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 }; } }

Implementation Reference

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