# send_message

Source: https://modulify.ai/docs/mcp/chat/send-message

Sends a prompt to the agent that builds a site, starting a generation at once or adding it to the queue when the chat is busy.

- Title: Send a message to a site
- Scope: `chat:write`
- Access: Makes changes

Every message spends AI credits from the workspace that owns the site, so batch your instructions into one clear prompt rather than many small corrections. Use it for every instruction to the site agent, including answering a question the agent asked and approving or changing a plan. A `402` means the workspace has no AI credits left.

When the chat is free, the generation starts at once and the response carries `queued:false` and a `jobId`. Poll `get_job` with that `jobId` until its `state` is no longer `running`.

Every site comes with one chat, whose `chatKey` is `main`, and the message goes there unless you pass `chatId`. When that chat was closed, a message to it opens it again, empty and called `New chat` until a message names it. The checks on the message, your access, the site and the credits come first, and a message one of them refuses leaves the chat closed, but a message the queue caps refuse afterwards with a `429` has still opened it. A site can have more chats, found with `list_chats` and started with `create_chat`, each with its own conversation and queue. One generation runs per chat, and a site runs several chats at once. See [Multiple chats](https://modulify.ai/docs/build/multiple-chats).

This tool never fails because a generation is already running. When one is already running in that chat, the last run in it was stopped, failed (other than with `SC-6002`) or ended part way through, or the site cannot start another chat right now, for example because it already runs as many chats as its plan allows, the message is queued in that chat instead. A run from before the chat was last cleared, or closed and opened again, no longer counts, and neither does one the queue was already resumed past. The response then carries `queued:true`, the entry's `queueItemId`, the reason it was held in `queueReason`, whether that hold is resumable in `queueResumable` and its place in line in `queuePosition`. That is a success, so the tool tells the client not to resend it or retry in a loop.

With `queueResumable:false` the queue runs in order on its own as soon as the chat is free. With `queueResumable:true` the last run in that chat was stopped or ended in an error and its queue stays parked on purpose, and nothing runs until somebody has looked at what went wrong: read the failure with `get_job`, then call `resume_queue`. An answer to the agent's question and a reply to a plan never queue, whatever is already waiting, because the agent is blocked until you reply. Send them to the same chat the question came from.

## When it is refused

A full queue is refused. A site holds at most 20 waiting messages across all its chats and at most 8 from any one person, and going over either comes back as a `429` saying which cap was hit. The tool tells the client to remove an entry with `remove_queued_message` rather than retrying.

Any other chat that was closed comes back as a `404` reading `That chat is not available!` While somebody is closing the `main` chat at that very moment, a message to it is refused with a `409` reading `Wait for this chat to finish first!`, which is safe to send again in a moment.

The message is also refused rather than queued while the site is locked because the workspace holds more sites than its plan allows. The same goes while the GitHub repository behind the site blocks editing: while its code is being moved into GitHub or back to Modulify, when Modulify has lost access to the repository or it was archived or deleted, and when the code lives in the workspace's own GitHub but the workspace is on the Free plan. See [Site chat](https://modulify.ai/docs/build/site-chat) and [Message queue](https://modulify.ai/docs/build/message-queue).

## Inputs

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `projectId` | string | Yes | The site id, from `list_sites` or `get_site`. |
| `prompt` | string | Yes | What the site agent should do, as specific as an instruction to a developer. It must not be empty and is refused over 500,000 characters. |
| `mode` | string | No | `build`, where the agent makes the change, or `plan`, where it proposes a plan for you to approve first. Defaults to `build`, and any other value is refused. |
| `chatId` | string | No | The chat to send to: `main` for the chat every site comes with, or the `chatKey` of another chat from `list_chats`. Defaults to `main`. |