How to Generate Images with Claude Code Using MCP Tools

Claude Code is primarily a coding tool, but there are plenty of situations where generating an image is part of the job: placeholder assets, README diagrams, UI mockup references, social card illustrations. Normally you’d switch to a separate tool or service. With AgentPatch connected, Claude Code can handle it in-session.

Why This Matters

AgentPatch exposes a Recraft-based image generation tool through MCP. Recraft supports realistic photographic output, digital illustrations, and vector-style graphics — a broad enough range to cover most practical use cases.

When Claude Code has access to this tool, you can request an image as part of any task without breaking your workflow. The agent generates the image directly; you don’t navigate to another service or manage a Recraft API key.

Setup

Install the AgentPatch CLI (zero dependencies, Python 3.10+):

pip install agentpatch

Set your API key:

export AGENTPATCH_API_KEY=your_api_key

Then use it:

ap search "web search"
ap run agentpatch google-search --input '{"query": "test"}'

Get your API key from the AgentPatch dashboard.

Run this command to add AgentPatch as an MCP server:

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. Claude Code discovers all AgentPatch tools automatically.

Example

You’re building a marketing site and you ask Claude Code:

“Generate a hero image for the landing page — an abstract illustration of connected nodes in a network, using a dark blue and white color scheme.”

Claude Code calls the Recraft tool through AgentPatch and produces the image. You can then ask it to save the file to your project’s assets directory and reference it in the HTML.

Another common case: documentation and READMEs.

“Create a simple diagram-style illustration showing the request flow: User -> API Gateway -> Worker -> Database. Keep it clean, minimal, black and white.”

Claude Code generates the image directly. The whole thing stays in your terminal session.

If the first result isn’t quite right, you just follow up:

“Make it wider and add a cache layer between the Worker and the Database.”

Claude Code calls the tool again with the revised prompt.

Wrapping Up

Image generation is one capability in the AgentPatch marketplace. Connecting AgentPatch also gives Claude Code access to web search, Google Maps, email, news, and more — everything discoverable through the same MCP config. Visit agentpatch.ai for your API key.