comfyui-mcp
Version:
Local-first, agent-native control plane for ComfyUI — MCP server + autonomous sidebar agent that drives your live graph in natural language on ANY LLM: Claude/ChatGPT/Gemini on your subscription (no API key), free local models via Ollama (fully offline),
36 lines • 1.45 kB
JavaScript
import { AssetRegistry } from "./asset-registry.js";
import { getOutputImage } from "./image-management.js";
const SUPPORTED_IMAGE_MIME_PREFIX = "image/";
/**
* Fetch a registered asset's bytes and return them as an MCP image content
* block so the agent can see the actual image. Throws on missing/expired
* assets and on non-image mime types (audio/video are not viewable inline).
*/
export async function viewAssetImage(assetId) {
const record = AssetRegistry.get(assetId);
if (!record) {
throw new Error(`No asset found for id "${assetId}". It may have expired or never been registered.`);
}
const validType = record.type === "output" || record.type === "input" || record.type === "temp";
const fetchType = validType
? record.type
: "output";
const { base64, mimeType } = await getOutputImage(record.filename, fetchType, record.subfolder);
if (!mimeType.startsWith(SUPPORTED_IMAGE_MIME_PREFIX)) {
throw new Error(`Asset "${assetId}" is not an image (mime: ${mimeType}). get_image (action:"view") only supports PNG/JPEG/WebP.`);
}
return {
content: [
{
type: "text",
text: `Asset ${assetId} — ${record.filename} (${mimeType})`,
},
{
type: "image",
data: base64,
mimeType,
},
],
};
}
//# sourceMappingURL=view-image.js.map