# merge_chat_changes

Source: https://modulify.ai/docs/mcp/chat/merge-chat-changes

Tries again to merge the unmerged changes of a chat into the site.

- Title: Merge the unmerged changes of a chat
- Scope: `chat:write`
- Access: Makes changes

Multiple chats are a paid plan feature, and each chat works in its own copy of the site. When the end of a turn cannot merge its changes automatically, for example because another chat changed the same lines, they are kept as unmerged changes, which `list_chats` shows as `pending`. This tries the merge again. See [Changes not merged](https://modulify.ai/docs/build/multiple-chats#changes-not-merged).

The response carries the outcome in `integration`, where `state` reads:

| `state` | What it means |
| --- | --- |
| `landed` | The changes are on the site now |
| `no-changes` | Nothing was left to merge |
| `conflicted`, `pending` or `rejected` | They still could not be merged and stay unmerged. Send a message to that chat asking the agent to resolve the conflicts |

`integration` also lists the files that conflict in `conflicts`, each with its `path` and `kind`.

It is refused with a `409` while a generation runs in that chat or its changes are already being merged or discarded (`Wait for this chat to finish first!`), while the site finishes a restore or move or its preview moves to a new [environment](https://modulify.ai/docs/editor/environment) (`Changes cannot be saved to this site while it finishes a restore or move. Try again in a moment!`) and when the chat has no unmerged changes (`This chat has no unmerged changes!`). It is also refused while the site is locked or while its GitHub repository blocks editing, with the same message `send_message` gives.

Two refusals are safe to try again in a moment:

| Status | When | The message |
| --- | --- | --- |
| `409` | Another chat's changes are being merged into the site right now | `Another chat is merging changes right now. Try again in a moment!` |
| `503` | The site or its repository could not be reached to finish the merge | `The site could not be reached to finish this. Try again in a moment!` |

## Inputs

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `projectId` | string | Yes | The site id, from `list_sites` or `get_site`. |
| `chatId` | string | No | The chat to merge: `main` for the chat every site comes with, or the `chatKey` of another chat from `list_chats`. Defaults to `main`. |