Claude Code · about five minutes

How to generate images in Claude Code

Claude Code can’t generate images on its own: the Claude models behind it read images but don’t make them. To add image generation, connect an image MCP server with one claude mcp add command, install an agent skill, or have it call an image API from a script. For icons and simple marks, it can also write SVG by hand.

By the Image MCP Server teamPublished Updated Claude Code docs verified November 2026
~/projects/site
$ claude mcp add --transport http imagemcp \
    https://mcp.imagemcpserver.com/mcp \
    --header "x-api-key: sk-img-gen-your_key_here"

Added MCP server "imagemcp"

$ claude
> /mcp
  imagemcp   connected

> add a hero image to the pricing page

  ⏺ generate_image(aspectRatio: "21:9") …
  ⏺ compress_image(quality: 80) …
  ⏺ Write(public/hero-pricing.webp)

Four ways to get images out of Claude Code

Three of them hand the work to an image model: they differ in how Claude Code reaches it. The fourth keeps everything inside Claude Code and is limited to what can be written as markup.

Four ways to generate images in Claude Code: setup, what each can make, cost and trade-off
RouteSetupWhat it can makeCostTrade-off
Image MCP serverthis guideclaude mcp add --transport http imagemcp …Photos and illustrations, edits, cut-outs, transparent PNGs, upscales, SVG, compression and format conversion: the 8 image tools.Credits per call: 15 on the default model, 8–30 across models.The tools appear natively, with their schemas, in every session the server is scoped to. In exchange, their definitions load into each session’s context, and you need an account with credits.
Agent skill + CLInpx skills add imagemcp/skillThe same operations, run as a command that prints JSON.The same credits as the MCP server.Nothing stays connected, and it works anywhere the agent can run a shell command, CI included. The agent learns the commands from SKILL.md rather than from tool schemas.
A script calling the REST APIPOST /v1/generateThe same operations, from any language, wherever you call it.The same credits as the MCP server.Full control, and it fits a build step that should not depend on an agent. You write and maintain the script, and the agent can only do what the script exposes.
SVG written by hand, or text_to_svgAsk Claude Code for SVG, or call text_to_svgIcons, logos, badges, diagrams and simple illustrations. Not photos or photographic scenes.Hand-written SVG uses no image credits. text_to_svg is a flat 5 credits.Vector output scales cleanly and recolours with CSS. Hand-written SVG is limited to what Claude Code can draw in markup; complex or photographic images need a raster model.

Which one to pick

Use the MCP server if you generate images in interactive sessions and want the tools there every time. Use the agent skill if you would rather not keep a server connected, or need the same thing in CI. Write a script against the REST API when the images belong to a build step. Ask for SVG when the asset is an icon or a diagram.

What the first three cost

They bill the same credits, because they call the same server. The default model, google/gemini-2.5-flash-image (“Nano Banana”), is 15 credits an image, so the $5 Testing plan’s 100 credits cover about 6 of them. Every plan is on the pricing page. If you would rather run an image server yourself, see hosted vs open-source image MCP servers.

Watch an agent generate a page’s images over MCP

72 seconds, unedited: a coding agent replaces every grey placeholder on a landing page with images it generates, cuts out and upscales through Image MCP Server. Connected to Claude Code, the server exposes the same tools.

generate_image · remove_background · edit_image · upscale_image — every call lands in the request log

Set up the MCP server, or the skill

Both expose the same operations and bill the same credits. The difference is whether the tools arrive over the Model Context Protocol or as a command the agent runs.

MCP server

recommended

Tools appear natively in the agent’s tool list with their full schemas, so it knows the parameters without being told. Add once, available in every session.

claude mcp add --transport http imagemcp \
  https://mcp.imagemcpserver.com/mcp \
  --header "x-api-key: $IMAGEMCP_API_KEY"

Run it in your terminal rather than inside a claude session — you are configuring the server before starting a conversation. It lands at local scope unless you say otherwise; see below.

Skill & CLI

A skill directory plus a zero-dependency Node CLI that prints structured JSON. Nothing to keep running, and it works anywhere the agent can execute a shell command — including CI.

npx skills add imagemcp/skill

export IMAGEMCP_API_KEY=sk-img-gen-…
node imagemcp.js generate \
  --prompt "isometric server rack" \
  --aspect 4:3
Command reference →

Writing your own script instead? Every tool is also a plain HTTP endpoint under https://api.imagemcpserver.com that takes the same key in an x-api-key header. MCP vs REST API covers when each one is the simpler choice.

Scopes: where it actually gets written

This is the part that trips people up. The default is local scope — private to you and only active in the directory you ran the command from. A server you added last week appearing to have vanished in a different repository is almost always this, not a broken config.

Claude Code MCP configuration scopes, the file each writes to, and who can use it
ScopeFlagWritten toAvailable to
localdefault~/.claude.json, under this projectOnly you, only this project
project--scope project.mcp.json in the project rootEveryone who clones it — after each approves it
user--scope user~/.claude.json, top-level mcpServersOnly you, every project

Project scope needs approving

Committing .mcp.json shares the server, but Claude Code will not trust a checked-in server definition on its own. Each teammate sees it as pending until they approve it once. That is a feature — a repository should not be able to add tools to your agent silently.

Scope is fixed at add time

There is no command to move a server between scopes. Remove it and add it again with the scope you wanted. claude mcp get imagemcp tells you which scope currently holds it.

Reading the connection status

claude mcp list is the fastest diagnostic, and its statuses are more specific than they look — each one points at a different fix. Inside a session, /mcp does the same job.

✔ Connected

Ready. Tools are listed and callable.

! Connected · tools fetch failed

The server answered but could not list tools. Run claude mcp get imagemcp for the detail.

! Needs authentication

Reachable but unauthenticated — usually a missing or malformed --header.

✘ Failed to connect

No response. Check the URL first, then the network.

✘ Connection error

The connection attempt threw an error. Run claude mcp get imagemcp for the detail.

⏸ Pending approval

A project-scoped server you have not approved yet. Run claude and approve it.

⊘ Disabled for this project

Turned off in the project’s disabledMcpServers list. Re-enable with /mcp.

Two things worth knowing that are easy to miss. A connected tick proves the config, not the key: this server lists its tools before it checks the key, so ask for your credit balance once. And every connected server costs context, because its tool names and instructions load into each session. Removing servers you have stopped using is free performance.

What changes in day-to-day work

Claude Code can already write the component, the styles and the tests. With the server connected, generating the image stops being a context switch — the asset appears in the same turn as the code that uses it.

“Build the marketing page from this brief.”

Without image tools

Ships with grey placeholder boxes and a TODO for design.

With them connected

Generates the hero, the three feature illustrations and the OG image, compresses them to WebP and references them from the JSX.

“Our icons are inconsistent — fix them.”

Without image tools

Suggests an icon library and leaves the migration to you.

With them connected

Generates a matching SVG set with one style prompt, writes each as a component, and deletes the mismatched PNGs.

“Every product image in /public is a 4MB PNG.”

Without image tools

Explains what a WebP is.

With them connected

Runs a batch compression over the folder, rewrites the references, and reports the before-and-after page weight.

Keeping an autonomous agent honest

An agent with a spending tool needs the same treatment as an agent with a deploy tool. These are the three habits worth putting in your project instructions.

  1. 1

    Check the balance first

    get_user_info is free. Telling the agent to call it before a batch means it can stop rather than fail halfway through forty images.

  2. 2

    Draft cheap, finish expensive

    Iterate on a fast model, then re-run the approved prompt on a premium one. Upscaling and compression happen once, at the end.

  3. 3

    Read the log afterwards

    Every call is recorded with its cost in the dashboard. A run that cost more than expected is a question you can answer with data.

drop this in CLAUDE.md

## Images

Image assets come from the imagemcp MCP
server. Before generating a batch, call
get_user_info and stop if credits are low.

- Draft on a fast model, finalise on a
  premium one only after I approve.
- Always compress to WebP before writing
  an image into /public.
- Never commit a PNG over 500 KB.

Once Claude Code is connected

Claude Code gets the server’s 8 image tools, plus 3 utility tools for the credit balance, the model list and batching: 11 MCP tools in all. The ones most setups reach for first are the AI image generation API, Background removal API and Transparent PNG generator API; each page covers what the tool does and what a call costs. If the protocol itself is new to you, what is MCP explains how a client like Claude Code finds these tools and calls them.

Setting up another client too? The Cursor MCP setup, Claude Desktop MCP setup and ChatGPT MCP connector setup guides use the same endpoint and key in a different config shape.

Claude Code questions

Can Claude Code generate images on its own?

No. Anthropic documents the Claude models as image understanding models only: they can read and analyse images but cannot generate or edit them. On its own, Claude Code can only make an image by writing code, such as SVG markup or a script that draws one. For photos, illustrations or anything raster it needs a tool: an image MCP server, an agent skill, or a script that calls an image API.

How do I add an MCP server to Claude Code?

Run claude mcp add --transport http <name> <url> in your terminal, outside a claude session, adding --header for any auth the server needs. Then run claude mcp list and check the server shows a connected tick before you start a session.

What scope does claude mcp add use by default?

Local scope, which is private to you and active only in the project you ran the command in. That is why a server added in one repository appears to vanish in another. Use --scope user to register it once for every project, or --scope project to share it with the team.

MCP server or the skill — which should I use?

The MCP server if you want the tools available in every session automatically. The skill and CLI if you prefer the agent to shell out to a command, which is also what you want on machines where you would rather not run a bridge process.

Can I scope the server to one project?

Yes. Adding it with project scope writes a .mcp.json in the repository so everyone who clones it gets the same server — though each teammate has to approve it once before it connects, since Claude Code does not trust a checked-in server definition automatically.

Should the API key go in the repo?

No. Keep the key in your environment and reference it, or add the server at user scope so the credential never enters a file that gets committed. A committed key should be revoked from the dashboard immediately.

Will the agent burn credits without asking?

It calls tools the same way it calls any other. get_user_info and list_models are free, so a well-prompted agent can check the balance before it starts. Every call also lands in the request log with its exact cost, so nothing is invisible after the fact.

Does it work in a headless or CI run?

Yes — the CLI is a plain Node script that prints JSON and reads the key from IMAGEMCP_API_KEY, so a non-interactive run can generate assets exactly like an interactive one.