Skip to main content

April 2026

How to generate images from Claude Code via MCP

You are five minutes from shipping a README and you still need a hero image. Instead of context-switching to a UI, you tell Claude Code to generate one, verify it, and commit the URL. Here is the exact setup, the exact prompt, and the exact JSON Claude sends.

The 90-second setup

Claude Code speaks MCP. AgentFramer ships an MCP server that exposes generate_image, generate_video, generate_audio, get_generation, list_recent_generations, get_credits, and a handful of workspace tools. Register it once and every Claude Code session in that project can call them.

Sign up at agentframer.com. New accounts get a small free balance, enough to run roughly 30 FLUX schnell generations or 5 FLUX 1.1 pro generations end-to-end. The dashboard prints your MCP URL on first load and shows live status for every connected agent.

Register the server

From the project root, run the CLI command. Claude Code handles the OAuth handshake in your browser, so you never paste an API key into a config file.

# add AgentFramer at the project scope
claude mcp add --scope project agentframer https://mcp.agentframer.com/mcp

# verify it landed
claude mcp list

Prefer JSON? Drop the same entry into ~/.claude/mcp.json for a global install or .claude/mcp.json next to the repo for project scope.

{
  "mcpServers": {
    "agentframer": {
      "type": "http",
      "url": "https://mcp.agentframer.com/mcp"
    }
  }
}

Open Claude Code and type /mcp. The slash menu lists every connected server with a status dot, the tool count, and an "authenticate" action if OAuth has not completed. Pick agentframer, complete the browser flow, and the dot turns green. The full reference is in the MCP setup guide.

A real prompt, end to end

Type this into Claude Code:

"Generate a 1280x800 dark hero image for the README that reads 'Self-host or hosted, your call' over a subtle dot grid. Use FLUX 1.1 pro. Save the URL to docs/hero.url and download the PNG to docs/hero.png."

Claude expands that into four steps without further prompting:

  1. Calls generate_image with the prompt, model, and dimensions.
  2. Polls get_generation every few seconds until status is completed (FLUX 1.1 pro typically returns in 6–12s).
  3. Writes the signed URL to docs/hero.url with its Write tool.
  4. Shells out to curl to fetch the PNG and saves it to docs/hero.png.

The tool call Claude actually sends

If you expand the tool call in Claude Code's transcript, the payload looks roughly like this:

{
  "tool": "generate_image",
  "arguments": {
    "model": "flux-1.1-pro",
    "prompt": "Dark themed README hero, the words 'Self-host or hosted, your call' set in a clean sans-serif, subtle dot grid background, deep charcoal #0a0a0a, soft cyan accent, no logo",
    "width": 1280,
    "height": 800,
    "guidance_scale": 3.5,
    "seed": 42
  }
}

AgentFramer returns a generation ID immediately. Claude pings get_generation with that ID until the response carries a url field. At FLUX 1.1 pro list price (around $0.04 per image at 1MP), this round trip costs less than five cents. Switching the model to flux-schnell drops it to roughly $0.003 per image and finishes in 1–2 seconds, which is what you want for iteration. Per-call billing means a stalled session never ticks over a meter; you pay for the generations you actually run.

Two details worth knowing. First, the URL Claude writes to docs/hero.url is signed and time-limited; AgentFramer stores the underlying asset for you, so a permanent link is one get_generation call away. Second, the seed in the payload is yours to set. Pin it to a number when you find a composition you like, and small prompt edits will produce variations instead of completely different images. That is how you go from "close" to "ship" without burning credits.

Let Claude grade its own homework

Once the PNG is on disk, Claude can read it back. Claude Code's image support means you can say "open docs/hero.png and tell me whether the headline is legible and centered." It will inspect the file, describe what it sees, and propose a revised prompt if the rendering is off. That feedback loop, generation followed by visual verification, is the part most non-MCP workflows skip.

A typical revision sequence: first call uses flux-schnell to scout composition, Claude looks at the result, then it escalates to flux-1.1-pro with a tightened prompt and a fixed seed for the keeper. Two calls, under a dime. If the text rendering matters (badges, labels, README banners), Claude will often pick Ideogram v2 or SD3.5 Large on its own; both handle in-image typography better than the FLUX family. Tell Claude which model it picked is fine, because the next iteration will follow your steer.

This is also where list_recent_generations earns its keep. If you walk away mid-session, Claude can rehydrate state by listing your last few generations, reading their URLs, and picking up where the previous turn left off — no scrolling through old terminal output, no re-prompting from scratch.

A cost ceiling pattern for CLAUDE.md

Image calls are billed per generation, so put the budget rules in context where Claude will read them. Drop this into your project's CLAUDE.md:

## Image generation policy

- Default model: flux-schnell. It is cheap (~$0.003) and fast.
- Escalate to flux-1.1-pro only when I ask for "final" or "ship".
- Never use sora-2 or veo-3 without explicit approval.
- Before any batch >= 5 calls, run get_credits and report the balance.
- Always save the generation URL alongside the file, not just the file.

Claude reads CLAUDE.md on session start and respects it. If you ever want a one-off override, just say so in the message; the policy is a default, not a lock. Pair it with a get_credits call at the top of any heavy session and you have a soft budget alarm that costs nothing to enforce. Teams running shared workspaces should also pin a target workspace with switch_workspace in the same file so generations land in the right billing bucket.

When MCP image generation in Claude Code is the wrong tool

Claude Code is a great hands on agent for code-adjacent assets: hero images, OG cards, empty-state placeholders, doc diagrams, favicons. It is the wrong tool for several other jobs.

  • Heavy art direction. If you need to iterate on lighting, lens, and pose for an editorial shot, the AgentFramer web UI gives you a side-by-side gallery and parameter sliders that beat a chat transcript.
  • Brand-locked aesthetics. Cursor's inline preview and reference-image pinning make style-locked work easier than terminal output.
  • Batch ecommerce. Generating 400 product variants belongs in a script that calls the HTTP API directly, not in an agent loop where each call costs you a tool turn.
  • Long video. Sora 2, Veo 3, and Runway Gen-4 are happy to run from MCP, but Claude Code's terminal is a poor place to review minutes of footage. Use the dashboard.

The decision is rarely "MCP or nothing." It is more often: which interface is closest to the work I am already doing? If the asset is a byproduct of code I am writing right now, Claude Code wins because the agent already has the file context. If the asset is the work — a campaign hero, a product photo, a music track — a purpose-built UI almost always beats a chat box. Compare on the models page if you want to know which model fits which scenario; the same MCP server powers all of them, so you can move freely between Claude Code, Cursor, and the dashboard without re-authenticating.

Going further

The same connection covers video and audio. Ask Claude to draft a 15-second product clip with Veo 3 and an Eleven Labs voiceover and you get a single tool-call sequence that lands a finished MP4 in your repo. The patterns are the same: prompt, poll, write the URL, optionally download. The tool-call patterns guide walks through the multi-modal sequences worth memorizing.

One last note on reliability. MCP servers are HTTP under the hood, and AgentFramer's endpoint runs in our own infrastructure with retry-aware tool semantics: if Claude's first generate_image call times out at the network layer, the same call will not double charge you. get_generation is the source of truth for whether anything actually started. That detail matters when an agent loop is making its own decisions about retries — you want idempotence, not surprise invoices.

Two minutes of setup, one CLAUDE.md block, and your terminal agent ships production assets without ever leaving the editor. Stop tabbing into a UI to fetch a hero image. Tell Claude what you want, let it call the tool, and ship the README.