mcpField
C
codetoimage-mcp-server

codetoimage-mcp-server

Local
codetoimage.appMedia & Design0Updated 16w ago

About codetoimage-mcp-server

codetoimage-mcp-server renders HTML and CSS as PNG, JPEG, or WebP for MCP-compatible clients. It can return the image inline or provide a temporary hosted URL that expires after 24 hours.

Key features

  1. 01Render HTML and CSS to images
  2. 02Return images inline in chat
  3. 03Create hosted image URLs valid for 24 hours
  4. 04Use saved templates and variables
  5. 05Set dimensions, formats, and presets

Use cases

  1. 01Preview a social card or chart in chat
  2. 02Create an Open Graph image and URL
  3. 03Render a transparent image for a dark background

MCP support

The MCP server exposes two rendering tools: one returns image content inline, and the other returns a temporary hosted URL. An API key is required.

Configuration

Local server config is the same for every client. Copy it into your client’s MCP config file.

mcp.json · Universal config
{
"mcpServers": {
"beznazwiska-codetoimage": {
"command": "npx",
"args": [
"-y",
"@codetoimage/mcp-server"
],
"env": {
"CODETOIMAGE_API_KEY": "<CODETOIMAGE_API_KEY>",
"CODETOIMAGE_API_URL": "<CODETOIMAGE_API_URL>"
}
}
}
}
Run commandnpx -y @codetoimage/mcp-server
Environment variables to set
CODETOIMAGE_API_KEYSecretAPI key from https://codetoimage.app/dashboard/keys (starts with cti_live_…). Sandbox tier is free.
CODETOIMAGE_API_URLOverride the API base URL. Defaults to https://api.codetoimage.app.

Local servers need a runtime on your machine (e.g. Node.js 18+). Config file locations differ by client; see your client’s docs.

Packages
npm@codetoimage/mcp-server0.2.0

Tools

2

Saved tool list · updated 2w ago

ParameterTypeRequiredDescription
cssstringNoOptional CSS injected as a <style> block.
htmlstringNoFull HTML (typically including <body>…</body>). Inline styles work; for larger CSS use the `css` field. Required unless `template_id` is provided.
widthintegerNoViewport width in pixels (default 800).
formatenumNoOutput format. Default: png.png | jpeg | webp
heightintegerNoViewport height in pixels (default 600).
presetenumNoNamed viewport size: og 1200×630, twitter-card 1200×628, facebook-post 1200×630, linkedin-post 1200×627, instagram-square 1080×1080, instagram-portrait 1080×1350, instagram-story 1080×1920, youtube-thumbnail 1280×720, pinterest-pin 1000×1500. One template, many sizes. Explicit width/height override the preset.og | twitter-card | facebook-post | linkedin-post | instagram-square | instagram-portrait | instagram-story | youtube-thumbnail | pinterest-pin
qualityintegerNoEncoder quality (JPEG/WebP only, 1-100).
variablesobjectNoValues for {{placeholders}} in the template (or in `html` if provided). Values are HTML-escaped server-side. Missing placeholders render as empty.
backgroundstringNoBackground color, e.g. '#ffffff' or 'rgb(10,10,10)'.
template_idstringNoID of a template saved in the codetoimage dashboard (Templates page). Use INSTEAD of `html` – the saved HTML/CSS renders with {{placeholders}} filled from `variables`.
transparentbooleanNoTransparent background (PNG/WebP only; paid plans).

Details

From the project README

@codetoimage/mcp-server

Official Model Context Protocol server for codetoimage.app – render HTML/CSS to PNG/JPG/WebP directly from Claude Desktop, Claude Code, Cursor, or any MCP-compatible client.

What you get

Two tools, no setup beyond an API key:

  • render_html_to_image – returns the image inline so your agent (or you, in chat) can see it immediately. Best for "show me the rendered card", OG preview iteration, chart generation, badge mockups.
  • render_html_to_url – returns a temporary hosted URL (24h TTL). Best when the image needs to live somewhere external – Instagram Graph API, OpenGraph meta tags, Slack unfurls, docs/posts embeds.

Install

You don't need to install anything globally – MCP clients can run it via npx. Get an API key at codetoimage.app/dashboard/keys, then add the config below.

Claude Desktop

Edit ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows):

{
  "mcpServers": {
    "codetoimage": {
      "command": "npx",
      "args": ["-y", "@codetoimage/mcp-server"],
      "env": {
        "CODETOIMAGE_API_KEY": "cti_live_..."
      }
    }
  }
}

Restart Claude Desktop. The two tools appear in the tool picker.

Claude Code
claude mcp add codetoimage -s user -- npx -y @codetoimage/mcp-server

Then set the env var in your shell profile (or pass -e CODETOIMAGE_API_KEY=cti_live_… in the claude mcp add call).

Cursor

Edit ~/.cursor/mcp.json:

{
  "mcpServers": {
    "codetoimage": {
      "command": "npx",
      "args": ["-y", "@codetoimage/mcp-server"],
      "env": {
        "CODETOIMAGE_API_KEY": "cti_live_..."
      }
    }
  }
}

Usage from an agent

The tools are self-documenting – your agent will pick the right one based on intent. Example prompts that just work:

"Render this card as a PNG: <div style='padding:40px;background:#6366f1;color:white;border-radius:16px'>Hello</div> at 800×400."

"Generate an Open Graph image for the blog post 'Why agents need pixel-perfect rendering' and give me a URL I can paste into the og:image meta tag."

"Take this CSS card and render it as a transparent PNG so I can use it on a dark background."

"Render my saved template 3f2a91d0-... with title 'Launch day' as an Instagram story."

Tool schemas

render_html_to_image
FieldTypeRequiredNotes
htmlstring✓*Full HTML (typically with <body>). *Not needed with template_id
cssstring–Optional CSS injected as <style>
template_iduuid✓*Saved template from the dashboard (Templates page); alternative to html
variablesobject–Values for {{placeholders}} in the template (HTML-escaped)
presetenum–Named size: og, twitter-card, facebook-post, linkedin-post, instagram-square, instagram-portrait, instagram-story, youtube-thumbnail, pinterest-pin
widthinteger 1-2048–Default 800; overrides preset
heightinteger 1-2048–Default 600; overrides preset
formatpng | jpeg | webp–Default png
qualityinteger 1-100–JPEG/WebP only
transparentboolean–PNG/WebP, paid plans
backgroundstring–e.g. #ffffff or rgb(…)

Returns: image content (base64 inline), rendered in the chat.

render_html_to_url

Same input schema as render_html_to_image. Returns a text block with:

  • url – temporary hosted image URL
  • format – final output format
  • expires_at – ISO timestamp (24h from render)
  • credits_remaining – your plan's quota state

Configuration

VariableDefaultPurpose
CODETOIMAGE_API_KEY–Required. Get one at codetoimage.app/dashboard/keys
CODETOIMAGE_API_URLhttps://api.codetoimage.appAPI base URL (override for dev/proxy)

Plans + limits

  • Free – 50 renders/month, no watermark, full features (up to 2048×2048, all formats).
  • Paid (Starter / Hobby / Pro / Scale) – from $9/mo for 1,000 renders up to 50,000/month, higher rate limits.
  • Pay as you go – prepaid credit packs from $5, valid 12 months, no subscription.

Pricing: codetoimage.app/#pricing

Related

License

MIT

Comments

Markdown supported

New to MCP?

From what the protocol is to installing your first server, these answers cover most first questions.

An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.