How to generate images from an AI agent with 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, maintainer of Snapsbrew. Published . Last updated .
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,subheadandphoto. - An MCP client: Claude Code, Claude Desktop, Cursor, Codex CLI or another client with the Streamable HTTP transport.
Step 1: Create an API token
- Open Account > Developers on your instance.
- Click New token. Give it a name, for example
claude-code. - 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
claude mcp add --transport http snapsbrew https://snapsbrew.example/mcp \
--header "Authorization: Bearer <your-token>"
Cursor (~/.cursor/mcp.json)
{
"mcpServers": {
"snapsbrew": {
"url": "https://snapsbrew.example/mcp",
"headers": { "Authorization": "Bearer <your-token>" }
}
}
}
Codex CLI (~/.codex/config.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.
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:
list-templatesto find the webinar template and its ID.get-template-detailsto read the layer keys and the current values.preview-snapwith the variants. The preview is watermarked HTML. It stores no snap.- The agent shows you the preview. You ask for changes, and it previews again.
create-snapwith 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-templateand 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, amessage, afixthat names the next call, andretryable. 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-templatewrites the draft of a template, andpublish-templatemakes 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-remotebridge. - 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.