Home / Docs / MCP Server / MCP Tools Reference | HTML to Image Docs

MCP Tools Reference

The MCP server exposes two tools. Both render in real Chrome, both cost 1 credit per successful image, and both return a full-resolution CDN URL plus a downscaled preview image so the model can review the result.

The parameters mirror the REST API parameters, with two differences: there is no webhook_url (MCP calls are synchronous), and an extra format argument lets the model choose png or pdf.

generate-image-from-html

Renders HTML and CSS to a PNG or PDF. Best for content the model designs itself: social cards, OG images, invoices, certificates, receipts, charts and more.

ParameterTypeRequiredDescription
htmlstringYesComplete, self-contained HTML to render. Put CSS in an inline <style> block.
cssstringNoExtra CSS injected into the page.
widthintegerNoViewport width in pixels (1-5000).
heightintegerNoViewport height in pixels (1-5000).
fullpagebooleanNoCapture the full scrollable height instead of the viewport.
dpiintegerNoDevice pixel ratio (1-4) for higher-resolution output.
ms_delayintegerNoMilliseconds to wait before capture (e.g. to let fonts or animation settle).
wait_for_selectorstringNoWait until this CSS selector appears before capturing.
formatstringNopng (default) or pdf.

screenshot-url

Captures a screenshot of a live, publicly accessible web page.

ParameterTypeRequiredDescription
urlstringYesThe fully-qualified URL to capture (https://...).
cssstringNoCSS injected into the page before capture (e.g. to hide cookie banners).
widthintegerNoViewport width in pixels (1-5000).
heightintegerNoViewport height in pixels (1-5000).
fullpagebooleanNoCapture the full scrollable height instead of the viewport.
selectorstringNoCapture only the element matching this CSS selector.
dpiintegerNoDevice pixel ratio (1-4).
ms_delayintegerNoMilliseconds to wait before capture.
wait_for_selectorstringNoWait until this CSS selector appears before capturing.

Output

On success, a tool returns two things to the model:

  1. A text part with the full-resolution image URL on the i.html2img.com CDN and your remaining credit balance.
  2. An image part - a downscaled preview of the render, so the model can see what it produced and iterate. PDFs return the URL only.

The full-resolution file always lives at the returned URL. The inline preview is intentionally small so it fits inside the message-size limits of MCP clients.

The image URL is permanent for the lifetime of a paid account, so the model can hand it straight back to you, drop it into a document, or post it onward.

Credits and errors

  • Each successful image costs 1 credit, exactly like the REST API.
  • If you are out of credits, the tool returns a clear message instead of an image, and no credit is spent. Top up on the pricing page.
  • Render failures (timeouts, unreachable pages, invalid input) come back as readable tool errors so the assistant can adjust and try again.

Reminder: inline your images

The renderer does not fetch remote images. Replace any <img src="https://..."> with a base64 data URI (data:image/png;base64,...). Self-contained HTML with an inline <style> block renders most reliably.

See also