Skip to Content
DocsAINOX PLATFORM

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:

statusMeaningWhat to do next
runningThe agent is replying.Wait, then call get_app again, or cancel with stop_run.
waitingThe agent paused on a question for you.Read pendingToolCalls and answer with resolve_tool_call.
idleThe 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

  1. Start an app. Call create_app with what to build, in plain language:

    { "prompt": "A one-page tip calculator with a dark theme" }

    It returns the new appId, the runId of the agent's reply, and a url that opens the app in App Builder, where you can watch the agent work.

  2. Poll until the agent stops. Call get_app every few seconds until status is no longer running. 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.

  3. Answer any questions. When status is waiting, pendingToolCalls lists what the agent is waiting on. Answer each with resolve_tool_call, which resumes the reply, then go back to polling. See Answering questions.

  4. Read the reply and the code. Once status is idle, list_messages returns the conversation: each message's text and the names of the tools the agent called. list_files and read_file read the project itself. The first call after the app has sat idle can take a while, because it starts the app's sandbox again.

  5. Ask for changes. Call send_message with a follow-up prompt and poll again. It is refused while the app is running or waiting.

  6. Publish. Call publish. The first publish needs a name, which becomes the app's title and its site's address (My App becomes my-app, or my-app-2 when that is taken; a name with no Latin letters or digits gets a short random address):

    { "appId": "…", "name": "Tip calculator" }

    It returns the deploymentId and the site's url, but the build runs afterwards. Poll get_app until deployment.status is published. Publish again after later changes to update the same site; name is ignored from then on, so the address does not change.

  7. 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 reach published before listing: while it is queued or building, 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 typeAnswer value
single_selectOne option's label, as a string
multi_selectAn array of option labels
textThe text of the answer
An optional questionnull 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:

statusMeaning
extractingUnpacking the project.
uploadingStoring the source for the build.
queuedWaiting for a build worker.
buildingBuilding the site and applying its database migrations.
publishedLive at deployment.url.
failedStopped. 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.

On this page