# Create with Agent tools

Two MCP tools let your AI client hand a job to ZenCreator's Create with Agent assistant, the same assistant that works in the web app. You describe what to make, the assistant picks the tool and model and writes the prompt, and you launch the result. This works for 18+ content too, for accounts with Trusted Status.

The assistant works inside the platform: it uses your files, picks the tools and models, writes the prompts, sets the settings and plans multi-step jobs. Use it when you want a result and leave the how to the assistant. When you run the generation yourself and need only the prompt text, the optional [`zencreator_craft_prompt`](./generation.md#zencreator_craft_prompt) helper is the smaller tool: it knows the per-model prompt guides and nothing else about the platform.

- [`zencreator_chat_with_agent`](#zencreator_chat_with_agent) — talk to the assistant, get its reply and its newest card. Costs nothing.
- [`zencreator_start_agent_card`](#zencreator_start_agent_card) — launch a card, like the Generate button. Spends credits.

Both tools take `response_format` (`"markdown"` default, or `"json"`) and always return full `structuredContent`. Both need the `mcp.generate` permission.

## The flow

1. Call `zencreator_chat_with_agent` with a `message` (and `attachments` if needed). Keep the returned `chat_id`.
2. Read the `card`: the tool, the prompt (`card.steps[].inputs`), `next_price` and `max_price`.
3. To change something, write to the assistant in the same chat (`chat_id` + a new `message`) and read the new card.
4. A start charges `next_price`, up to `max_price`: show the user both. When the user agrees to the card and prices, call `zencreator_start_agent_card`.
5. While `status` is `working`, call `zencreator_chat_with_agent` with only `chat_id`. When it is `ready`, read the results from `card.steps[].asset_ids`.

Writing "yes" or "go" in the chat does not launch a card. Only `zencreator_start_agent_card` does.

---

## zencreator_chat_with_agent

Two modes:

- **Send**: pass `message` and/or `attachments`. Without `chat_id` a new chat is opened; with it the chat continues. The call waits for the assistant's answer.
- **Wait**: pass only `chat_id`. Nothing is sent; the call waits for the assistant or a running generation and returns the current state.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `message` | string | no | | What to tell the assistant. |
| `attachments` | string[] | no | | Up to 4 asset ids: images, video or audio. |
| `chat_id` | string | no | | Continue or wait on this chat. |
| `timeout_s` | integer | no | 40 | Total time of the call, 5–50 seconds. |
| `response_format` | string | no | `markdown` | `markdown` or `json`. |

Pass at least one of `message`, `attachments` or `chat_id`.

**Returns**

```json
{
  "chat_id": "uuid",
  "status": "working | ready",
  "reply": { "message_id": "uuid", "status": "streaming | completed | stopped | failed", "text": "..." },
  "card": {
    "card_id": "uuid",
    "label": "C1",
    "status": "proposed | superseded | running | completed | failed | stopped",
    "next_price": 12,
    "max_price": 12,
    "run": { "status": "running | completed | failed | stopped", "failure": { "step": 2, "code": "..." } },
    "steps": [
      { "n": 1, "tool_name": "image_editor", "inputs": [{ "prompt": "..." }], "status": "completed", "asset_ids": ["uuid"] }
    ]
  }
}
```

`reply` and `card` are `null` when the chat has none. The prompt is in `card.steps[].inputs[]`; an input `{"step": k}` stands for the result of step `k`.

**Errors**

| Case | What to do |
| --- | --- |
| Create with Agent is not available for the account | Tell the user; retrying does not help. |
| Message rejected or too long | Rephrase and send again. |
| Chat or file not found | Check `chat_id` and the asset ids. |
| The assistant is still working in the chat | Call again with only `chat_id`. |
| Too many chats working, or messages too frequent | Wait for another chat to finish, or retry after the stated time. |

An error after a chat was opened includes its `chat_id`; reuse it instead of opening another chat. If a read fails after the message was sent, the error says so: do not send again, call with only `chat_id`.

---

## zencreator_start_agent_card

Launches a card, the same as the Generate button. It charges `card.next_price`, up to `card.max_price`; show both to the user before starting. Launch only after the user agreed to the card and these prices.

- A card that is already running or finished is not launched again; the tool returns its state and results.
- A card that failed or stopped continues from its first step without a result, and that step is charged again.
- An outdated card is refused: start the newest `card_id`.
- Images take seconds, video takes minutes. Use `zencreator_chat_with_agent` with only `chat_id` to wait.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `chat_id` | string | yes | | The chat the card is in. |
| `card_id` | string | yes | | `card.card_id` from `zencreator_chat_with_agent`. |
| `timeout_s` | integer | no | 40 | Total time of the call, 5–50 seconds. |
| `response_format` | string | no | `markdown` | `markdown` or `json`. |

**Returns** the same object as `zencreator_chat_with_agent`, with the card as it stands after the start.

**Errors**

| Case | What to do |
| --- | --- |
| Not enough credits | Tell the user to top up; the response carries the link. |
| Price rose above the card's maximum | Nothing was charged and the card holds the new price. Read it with `zencreator_chat_with_agent` (only `chat_id`), show `next_price` and `max_price` to the user, then start again. |
| Card cannot be started, chat busy, or a file of the card was deleted | Nothing was charged. Read the newest card with `zencreator_chat_with_agent`. |
| Too many chats working | Wait until a reply or generation in another chat finishes, then retry. |
| The card's tool or model is not available for the account | 18+ generation needs Trusted Status. Retrying does not help. |
| The card cannot run as it is (400) | Ask the assistant for a changed card. |

If a read fails after the card was started, the error says so: do not start again, call `zencreator_chat_with_agent` with only `chat_id`.
