# How to generate images from an AI agent with MCP

Source: https://snapsbrew.com/guides/generate-images-with-ai-agent-mcp

Connect your agent to the MCP server of a Snapsbrew instance at /mcp with an API token. The agent lists your templates, reads the layer keys, and shows a watermarked preview. After you approve the preview, it renders the final PNG, JPEG, WebP or PDF from the same template. The images stay on your server.

By [Alejandro Medina](https://amedina.me), maintainer of Snapsbrew. Published 27 November 2026. Last updated 27 November 2026.

On this page

- [What you need](#what-you-need)
- [Step 1: Create an API token](#step-1-create-an-api-token)
- [Step 2: Connect the client](#step-2-connect-the-client)
- [Step 3: Ask for an image](#step-3-ask-for-an-image)
- [Step 4: Render many images in one call](#step-4-render-many-images-in-one-call)
- [Step 5: Design with the agent](#step-5-design-with-the-agent)
- [Keep it safe](#keep-it-safe)
- [When an AI image model is the better tool](#when-an-ai-image-model-is-the-better-tool)

An AI agent is good at words and bad at brand rules. Ask a chat model for a launch image and you get a new style each time, often with broken text. Ask it to fill a template and you get your design with the words that it wrote.

Snapsbrew has an MCP server for this job. The agent never draws. It picks a template, writes the values of the layers, shows you a preview, and renders the final file after you say yes.

## What you need

- A Snapsbrew instance with `MCP_ENABLED=true`. That is the default value.
- One or more published templates with clear layer keys, for example `headline`, `subhead` and `photo`.
- An MCP client: Claude Code, Claude Desktop, Cursor, Codex CLI or another client with the Streamable HTTP transport.

## Step 1: Create an API token

1. Open **Account > Developers** on your instance.
2. Click **New token**. Give it a name, for example `claude-code`.
3. Copy the token. The page shows it one time.

The REST API and the MCP server accept the same token. Make one token for each client, so that you can revoke one client and keep the others.

## Step 2: Connect the client

The endpoint is the `APP_URL` of your instance followed by `/mcp`.

**Claude Code**

```bash
claude mcp add --transport http snapsbrew https://snapsbrew.example/mcp \
  --header "Authorization: Bearer <your-token>"

```

**Cursor** (`~/.cursor/mcp.json`)

```json
{
  "mcpServers": {
    "snapsbrew": {
      "url": "https://snapsbrew.example/mcp",
      "headers": { "Authorization": "Bearer <your-token>" }
    }
  }
}

```

**Codex CLI** (`~/.codex/config.toml`)

```toml
[mcp_servers.snapsbrew]
url = "https://snapsbrew.example/mcp"

[mcp_servers.snapsbrew.http_headers]
Authorization = "Bearer <your-token>"

```

The Claude custom connector uses OAuth 2.0 instead of a token. The instance must be on the public internet with a trusted certificate. Read [Connect Claude](https://snapsbrew.com/docs/mcp/connect-claude.md).

To test the connection, ask the agent to call `whoami`. It returns your account and your company.

## Step 3: Ask for an image

Ask for the result, not for the tool calls. For example:

> Make an Instagram story for our Friday webinar "Ship faster with feature flags", 3 PM CET. Use the webinar template. Show me a preview first.

The server sends a workflow to the agent as its instructions, so a good agent follows these steps:

1. `list-templates` to find the webinar template and its ID.
2. `get-template-details` to read the layer keys and the current values.
3. `preview-snap` with the variants. The preview is watermarked HTML. It stores no snap.
4. The agent shows you the preview. You ask for changes, and it previews again.
5. `create-snap` with the same variants, after you approve. The result is the URL of the final image.

The preview step matters. A preview stores nothing and leaves no snap in your account, so the agent can try ten headlines before it renders one.

## Step 4: Render many images in one call

`create-snaps-batch` renders up to 100 snaps from one template. It returns a batch ID at once and renders the items in the background. The agent reads the progress with `get-snaps-batch`.

> Here are the 24 speakers of our conference, with name, talk title and photo URL. Make a speaker card for each one with the speaker template.

For a set of files to hand to a person, `export-creative-package` renders up to 10 final images from published templates into one package. The agent polls `get-creative-package` until the package is ready, then gives you the file URLs.

## Step 5: Design with the agent

The agent can also build a template. Three guide tools give it the rules:

| Tool                | The question it answers                                                                                                                       |
| ------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
| platform-guide      | Where does the image go? It returns the size preset, the crop rules and the safe zones of Instagram, LinkedIn, X, TikTok, YouTube and others. |
| image-purpose-guide | What is the image for? For example an og:image, a carousel, an ad or an email header. It returns the rules, a layer recipe and a checklist.   |
| design-guide        | How do I compose it? Layer order, type, color and composition recipes.                                                                        |

Then `create-template` saves the design, and `publish-template` makes it live. `preview-design` and `create-snap-from-design` render a one-off design with no saved template.

## Keep it safe

- **A token acts as its account.** The agent can do what the owner of the token can do in the company, for example edit and publish templates. Revoke the token in **Account > Developers** when you stop using the client.
- **Destructive tools are marked.** `create-snap`, `edit-template`, `publish-template` and the batch tools carry the destructive hint. Clients that ask before such calls show you each one.
- **The rate limit is 30 requests a minute for each user.** A loop in the agent stops there.
- **Errors tell the agent what to do.** Each error has a `code`, a `message`, a `fix` that names the next call, and `retryable`. The agent can read the next step from the error.
- **The images stay on your server.** A snap that an agent renders goes to the usage log of the account, like a snap from the REST API.

## When an AI image model is the better tool

A template fills known slots. It cannot invent a photo, a scene or an illustration. If you need new artwork, use an image model, then put its output into an image layer with `image_url`. The template keeps the logo, the type and the layout the same.

## Questions

Does the agent draw the image with an AI image model?

No. The agent fills the layers of a template that a person designed. The instance renders the template with headless Chrome. So the logo, the fonts and the colors are always the ones of your brand, and the text is exactly the text that the agent wrote.

Can the agent change my templates?

Yes, if the token allows it. `edit-template` writes the draft of a template, and `publish-template` makes the draft live. Both are marked destructive, so a client that asks before such calls asks you first. Snaps render the published version, so a draft edit changes nothing until a publish.

Which clients work?

Any MCP client with the Streamable HTTP transport. The docs have steps for Claude Code, Claude Desktop, the Claude custom connector, Cursor and Codex CLI. A client with only the stdio transport can connect through the `mcp-remote` bridge.

How many calls can an agent make?

The server allows 30 requests each minute for each user. A batch tool renders up to 100 images in one call.

## Related pages

- [Docs: MCP server](https://snapsbrew.com/docs/mcp/overview.md)
- [Docs: MCP tools reference](https://snapsbrew.com/docs/mcp/tools-reference.md)
- [How to generate images from a Google Sheet or an Airtable table](https://snapsbrew.com/guides/generate-images-from-spreadsheet.md)
- [The best open-source image generation APIs and tools in 2026](https://snapsbrew.com/blog/best-open-source-image-generation-api.md)

## Run it on your own server

Docker Compose starts the app, the queue, MySQL, Redis and the renderer together.

[Self-host it](https://snapsbrew.com/docs/getting-started/installation-docker.md) [View on GitHub](https://github.com/amedina068/snapsbrew)

```bash
git clone https://github.com/amedina068/snapsbrew.git
cd snapsbrew
cp .env.docker.example .env   # then fill in .env
docker compose up -d --build
```
