Build an app over MCP
The loop an MCP client follows to start an app, wait for the agent, answer its questions, read the code and publish the site.
Tools that start work answer right away. The agent inside App Builder keeps
working, and your client checks on it with get_app. An app's status is one
of three:
status | Meaning | What to do next |
|---|---|---|
running | The agent is replying. | Wait, then call get_app again, or cancel with stop_run. |
waiting | The agent paused on a question for you. | Read pendingToolCalls and answer with resolve_tool_call. |
idle | The reply is finished. | Read it with list_messages, then send_message or publish. |
An app takes one turn at a time, whether it comes from your client or from someone typing in App Builder. While a turn runs, a new prompt from either side is refused until it finishes.
The loop
-
Start an app. Call
create_appwith what to build, in plain language:{ "prompt": "A one-page tip calculator with a dark theme" }It returns the new
appId, therunIdof the agent's reply, and aurlthat opens the app in App Builder, where you can watch the agent work. -
Poll until the agent stops. Call
get_appevery few seconds untilstatusis no longerrunning. A first version often takes a minute or more. Keep the interval at two seconds or longer: each key allows 120 requests a minute, shared by everything that uses it. -
Answer any questions. When
statusiswaiting,pendingToolCallslists what the agent is waiting on. Answer each withresolve_tool_call, which resumes the reply, then go back to polling. See Answering questions. -
Read the reply and the code. Once
statusisidle,list_messagesreturns the conversation: each message's text and the names of the tools the agent called.list_filesandread_fileread the project itself. The first call after the app has sat idle can take a while, because it starts the app's sandbox again. -
Ask for changes. Call
send_messagewith a follow-up prompt and poll again. It is refused while the app isrunningorwaiting. -
Publish. Call
publish. The first publish needs aname, which becomes the app's title and its site's address (My Appbecomesmy-app, ormy-app-2when that is taken; a name with no Latin letters or digits gets a short random address):{ "appId": "…", "name": "Tip calculator" }It returns the
deploymentIdand the site'surl, but the build runs afterwards. Pollget_appuntildeployment.statusispublished. Publish again after later changes to update the same site;nameis ignored from then on, so the address does not change. -
Share it, if you like. A published site that everyone in the workspace (or anyone with the link) can open can be listed in the workspace's Marketplace with
set_marketplace_listing. Who can open a site is set in App Builder, under Share. Wait for the first publish to reachpublishedbefore listing: while it isqueuedorbuilding, the listing is refused with "Wait for the app to finish publishing, then share it."
Answering questions
The agent asks with its ask_user tool, often before it starts a new app or a
large feature, so a new app often stops at waiting before any code is
written. Each entry in pendingToolCalls has the runId and toolCallId to
send back, a toolName, a kind of answers, and the questionnaire in
input, whose questions each have an id, a type and the options to
choose from. Answer with an answers object keyed by question ID:
Question type | Answer value |
|---|---|
single_select | One option's label, as a string |
multi_select | An array of option labels |
text | The text of the answer |
| An optional question | null to skip it |
{
"appId": "…",
"runId": "…",
"toolCallId": "…",
"answers": { "palette": "Dark", "features": ["Split the bill", "Round up"] }
}resolve_tool_call answers questionnaires only. A call with kind: "approval"
cannot be approved or declined over MCP: open the app in App Builder and answer
it there.
Publishing states
get_app includes deployment once the app has been published. Its status
moves through these values:
status | Meaning |
|---|---|
extracting | Unpacking the project. |
uploading | Storing the source for the build. |
queued | Waiting for a build worker. |
building | Building the site and applying its database migrations. |
published | Live at deployment.url. |
failed | Stopped. deployment.reason says why; fix it and publish again. |
deployment.live is true while an earlier publish is still serving the site,
even when the latest one failed. Do not call publish again while a publish is
in progress.
If a workspace manager or a platform admin takes the site down, deployment
and marketplace become null and siteTakenDown is true. The app, its
chat and its files stay. Call publish to put it online again at a new
address; siteTakenDown turns false as soon as that publish starts.
Stopping a reply
stop_run cancels the reply in progress and returns stopped: false when
nothing was running. A question the agent is waiting on stays pending, so a
waiting app still needs resolve_tool_call before it takes a new prompt.
What a client cannot do
The MCP server cannot rename an app, delete it, change who can open its site, take the site down, or upload files with a prompt. Do those in App Builder.