Image Generation in Claude Code via MCP Tools
Claude Code works with text and code. It can’t produce images on its own. If you need a placeholder graphic, a diagram, or a social card while building a project, you’d normally open a browser, navigate to an image tool, generate the asset, download it, and move it into your project. MCP tools collapse that into a single prompt.
When You’d Want This
Image generation from a terminal agent sounds niche until you list the situations where it comes up:
Building a site or app. You need hero images, placeholder photos, or illustration assets. Switching context to a separate tool breaks your flow. If your agent can generate the image and save it to public/images/, you stay in one place.
Creating documentation. READMEs and docs benefit from diagrams: architecture overviews, sequence flows, component relationships. Generating these inline means they get created alongside the text that references them, not as an afterthought.
Producing social cards and thumbnails. Open Graph images, blog post covers, YouTube thumbnails. These are formulaic enough that a text prompt handles them well.
Rapid prototyping. You’re sketching out a concept and want visual assets that are “good enough” to show the idea. Stock photos rarely fit. A generated image matched to your description is closer to what you need.
None of these require photorealistic quality. They require something reasonable, produced fast, without leaving the terminal.
How MCP Image Generation Works
An MCP image generation server wraps an image model (like Recraft, DALL-E, or Stable Diffusion) behind the standard MCP tool interface. The server exposes a tool with parameters for the prompt, style, dimensions, and other options. Claude Code discovers this tool at startup and can call it during any session.
The flow looks like this:
- You ask Claude Code to generate an image, either as a standalone request or as part of a larger task.
- Claude Code constructs the tool call with your description as the prompt.
- The MCP server sends the prompt to the image model and returns the result.
- Claude Code receives the image (as a URL or file path) and can save it, reference it in code, or describe what was generated.
The agent handles prompt construction. You describe what you want in natural language, and Claude Code translates that into the parameters the tool expects. You can also iterate: “make it wider,” “change the background to dark blue,” “add a third column.”
Style Options Matter
Different image models produce different output. Some are strong at photorealism, others at illustration or vector graphics. The model behind the MCP server determines what styles are available.
Recraft, for example, supports realistic photos, digital illustrations, and vector-style graphics. That range covers most development use cases. If you need a specific aesthetic (pixel art, watercolor, technical diagrams), check what styles your image generation tool supports before committing to a workflow.
AgentPatch + Recraft
AgentPatch exposes Recraft-based image generation through its MCP server. When you connect AgentPatch to Claude Code, the image generation tool appears alongside web search, email, and everything else in the marketplace.
The AgentPatch CLI is designed for AI agents to use via shell access. Install it, and your agent can discover and invoke any tool on the marketplace.
Install (zero dependencies, Python 3.10+):
pip install agentpatch
Set your API key:
export AGENTPATCH_API_KEY=your_api_key
Example commands your agent will use:
ap search "web search"
ap run google-search --input '{"query": "test"}'
Get your API key from the AgentPatch dashboard.
Skill (Recommended)
Install the AgentPatch skill — it teaches Claude Code when to use AgentPatch and how to use the CLI:
/plugin marketplace add fullthom/agentpatch-claude-skill
/plugin install agentpatch@agentpatch
MCP Server (Alternative)
If you prefer raw MCP tool access instead of the skill:
claude mcp add -s user --transport http agentpatch https://agentpatch.ai/mcp \
--header "Authorization: Bearer YOUR_API_KEY"
Replace YOUR_API_KEY with your actual key from the AgentPatch dashboard.
Example
You’re building a landing page and need a hero image:
“Generate an illustration of a developer’s terminal with colorful tool icons floating around it. Use a dark background with bright accent colors. Save it to public/images/hero.png.”
Claude Code calls the Recraft tool through AgentPatch, generates the image, and saves it to your project. You can then reference it in your HTML without ever leaving the session.
Later, you need an Open Graph image:
“Create a 1200x630 social card with the text ‘Ship Faster with AI Tools’ on a gradient background. Clean, modern style.”
Same tool, same session. No context switching.
Wrapping Up
Image generation through MCP gives Claude Code a capability it doesn’t have natively. For development workflows where visual assets are part of the job, it removes the need to switch tools. AgentPatch bundles Recraft image generation with web search, email, and more through one MCP config. See all available tools at agentpatch.ai.