Skip to Content
Welcome to RitoSwap's documentation!
AI SystemsMCP Stackgenerate_image_with_alt

generate_image_with_alt

Defined in dapp/app/lib/mcp/tools/image-generate-workflow.ts, this tool centralizes OpenAI image creation and the client-side delivery contract.

Pipeline Highlights

  • Input schema — accepts a prompt plus an optional name. Sizes/quality are fixed by aiServerConfig.image.defaults to keep runtime predictable.
  • GenerationcallOpenAIImage is the sole generator path today; it enforces the OpenAI provider and falls back to fetching the signed URL when b64_json is absent.
  • Alt TextgenerateAltText uses the configured vision provider (openai or lmstudio) so every image ships with accessible copy even though the pixels never touch disk.
  • Streaming — the handler pushes JSON first ({ kind: 'store-image', name, width, height, dataBase64 }) and then the <img src="store://..."> text segment so hydrators can populate caches before the transcript renders.

Image Delivery

Images generated by tools are never stored server-side. The workflow (image-generate-workflow.ts) streams a base64 payload through SSE, marks it with kind: 'store-image', and inserts a placeholder <img src="store://image/..."> tag in the text portion. The client’s hydration hook writes the data into memory so parseContentWithMedia.ts can render it inline.

// dapp/app/lib/mcp/tools/image-generate-workflow.ts const imageGenerateWorkflow: Tool<Params> = { name: 'generate_image_with_alt', description: 'Generate an image and emit a store:// payload + alt text.', async handler({ prompt, name }) { const { pngBase64, w, h } = await callOpenAIImage(prompt); const alt = await generateAltText(`data:image/png;base64,${pngBase64}`); const fileName = uniqueName(name); const json = jsonResult({ kind: 'store-image', name: fileName, mime: 'image/png', width: w, height: h, alt, dataBase64: pngBase64, }); const text = textResult( `<img src="store://image/${fileName}" alt="${alt.replace(/"/g, '&quot;')}" width="${w}" height="${h}" />`, ); return { content: [...json.content, ...text.content] }; }, };

Presenter Behavior

dapp/components/chatBot/ToolActivity/catalog/presenters/generate_image_with_alt.presenter.ts keeps the UI minimal:

StatusLabelDetails
pendingGenerating image…No body text; indicates the tool is still queueing.
successImage readyShows name (width×height) when available so the user knows what asset arrived.
errorImage failedSurfaces the raw error text (e.g., provider outage) for quick troubleshooting.

Ties to the Frontend

useHydrateToolImages.ts listens for the { kind: 'store-image' } JSON emitted by this tool. That hook writes the base64 bytes into the useLocalImageStore, so the <img src="store://image/..."> tag rendered in the chat stream resolves instantly without another network hop.

RitoSwap Docs does not store, collect or access any of your conversations. All saved prompts are stored locally in your browser only.