---
title: Build an app
description: "Write a TypeScript Executor app with index.ts and package.json, create it with executor apps create, and deploy it with executor apps deploy."
slug: "/build"
---

An Executor app is a TypeScript package with `index.ts` and `package.json` declaring `dependencies.apps`. Create apps with `executor apps create`, activate them with `executor apps deploy`, and update them with `executor apps source`, `executor apps commit`, or Git on **Local**, **Self-host**, and **Cloud**.

**The command that matters most:** run `executor apps framework`, save `hello/package.json` and `hello/index.ts`, then run `executor apps create --name "Hello" --files ./hello` and `executor apps deploy --app "$APP_ID" --files ./hello`.

**Prerequisites and permissions:** Bash, Node.js, and `npm i -g executor@2.0.0-beta.79`. **Local** needs no sign-in without a hosted override. On **Cloud** and **Self-host**, creating requires org membership with write access (**All apps** on scoped connections); editing requires creator, **admin**, or **owner** under a matching grant.

**You'll know it worked when…** deploy returns `app` and `version`, and `executor execute --code 'return await tools.hello.greet({ name: "Ada" })'` returns `Hello, Ada!`.

## How to use it

App commands choose their target in this order: `--host`, then `EXECUTOR_HOST`, then the last host remembered by either sign-in command (`executor apps login` or `executor login`), then the **Local** background server.

Every app starts with two files:

- `package.json` declaring `dependencies.apps` pinned to the exact version returned by `executor apps framework` so rebuilds stay on that release.
- `index.ts` exporting `defineApp(requirements, definition)` as the default export.

### Local

The commands below use Bash and Node.js and assume no saved hosted sign-in or `EXECUTOR_HOST` override. If you run a manual Local server instead of the background service, pass its loopback origin (`--host http://127.0.0.1:4312`), set `EXECUTOR_API_KEY` in the process environment, omit `--organization`, and ensure no higher-priority access-token override is set.

1. **Check the host's apps version**

    In a new empty directory, run:

    ```bash
    executor apps framework
    ```

    Note the returned `version` (for example `0.0.1-beta.148`).

2. **Create the two starter files**

    Save these two files in `./hello`, replacing `0.0.1-beta.148` with the `version` printed above if your host reports a different release:

    <CodeGroup>

    ```json hello/package.json
    {
      "name": "hello-app",
      "private": true,
      "dependencies": {
        "apps": "0.0.1-beta.148"
      }
    }
    ```

    ```ts hello/index.ts
    import { defineApp, object, query, router, string } from "apps";

    const greet = query(
      {
        description: "Greet someone by name",
        input: object({ name: string() }),
        output: object({ message: string() }),
      },
      async (_ctx, { name }) => ({
        message: `Hello, ${name}!`,
      }),
    );

    export default defineApp({}, { tools: router({ greet }) });
    ```

    </CodeGroup>

3. **Create, deploy, and run the tool**

    Create the app from `./hello`, deploy the returned `id`, and call `greet`:

    ```bash
    APP_ID=$(executor apps create --name "Hello" --files ./hello | node -pe 'JSON.parse(require("fs").readFileSync(0, "utf8")).id')
    executor apps deploy --app "$APP_ID" --files ./hello
    executor execute --code 'return await tools.hello.greet({ name: "Ada" })'
    ```

    Check that the deploy response includes `app` and `version`, and that `execution.value.message` is `"Hello, Ada!"` (or open the app's **Tools** tab in the dashboard and click **Run tool**).

### Cloud

1. **Sign in for app commands**

    ```bash
    executor apps login
    ```

    Open the printed URL in your browser and approve the code. `executor apps login` defaults to `https://api.executor.sh` (unless `EXECUTOR_HOST` overrides it) and remembers both the host and the organization you approved. For scripted hosted app commands, set `EXECUTOR_ACCESS_TOKEN` to an app-management access token and pass `--organization "$ORG_ID"` with `--host https://api.executor.sh`.

2. **Check the framework version, create, and deploy**

    Run `executor apps framework`, put the returned `version` in `hello/package.json`, then create and deploy `./hello`:

    ```bash
    executor apps framework
    APP_ID=$(executor apps create --name "Hello" --files ./hello | node -pe 'JSON.parse(require("fs").readFileSync(0, "utf8")).id')
    executor apps deploy --app "$APP_ID" --files ./hello
    ```

3. **Call the deployed tool**

    Being able to manage an app is separate from being in its tool audience. To run the tool over hosted MCP, use a connection that can call the app. For the tool CLI on `2.0.0-beta.79`, sign in separately with `executor login --host https://api.executor.sh`, then run:

    ```bash
    executor execute --code 'return await tools.hello.greet({ name: "Ada" })'
    ```

### Self-host

Sign in against your self-hosted origin for app commands, pin the returned framework version in `hello/package.json`, create, and deploy:

```bash
executor apps login --host https://executor.example.com
executor apps framework
APP_ID=$(executor apps create --name "Hello" --files ./hello | node -pe 'JSON.parse(require("fs").readFileSync(0, "utf8")).id')
executor apps deploy --app "$APP_ID" --files ./hello
```

You can set `EXECUTOR_HOST=https://executor.example.com` instead of passing `--host` on each command. To call the deployed tool from the tool CLI on `2.0.0-beta.79`, sign in separately with `executor login --host https://executor.example.com` first.

## Deploying

`executor apps create` saves source files without building or running them. `executor apps deploy` compiles the app, runs any SQL migrations, activates the new version if the build succeeds, and returns JSON with `app` and `version`. A failed build keeps the previous active version running and reports the failing stage, with a source file and line when available.

`executor apps deploy --files` first loads the working revision and saves the complete supplied directory as the new working source before building. A failed build can therefore leave the working source updated, and `--files` does not check for someone else's edits since you downloaded the app.

### Updating an existing app

To detect concurrent changes before deploying edits from a shell:

1. Download the working source into an empty directory and record its `revision.commit`:

   ```bash
   BASE_COMMIT=$(executor apps source --app "$APP_ID" --out ./hello | node -pe 'JSON.parse(require("fs").readFileSync(0, "utf8")).revision.commit')
   ```

2. Edit files in `./hello`, commit with `--expected "$BASE_COMMIT"`, and deploy the returned `revision.commit`:

   ```bash
   NEW_COMMIT=$(executor apps commit --app "$APP_ID" --files ./hello --expected "$BASE_COMMIT" --message "Update greeting" | node -pe 'JSON.parse(require("fs").readFileSync(0, "utf8")).revision.commit')
   executor apps deploy --app "$APP_ID" --commit "$NEW_COMMIT"
   ```

3. Inspect previous commits with `executor apps history --app "$APP_ID"`.

`executor apps commit` saves a complete snapshot: any file omitted from `--files` is deleted from the working source, and the command reports `removed.count` and up to 100 removed paths.

The CLI uploads a source directory larger than 16 MiB through Git automatically when only its `ui/public/` assets push it over the inline limit (non-public code must still fit within 4,096 files and 16 MiB). To clone manually on **Cloud** or **Self-host** after `executor apps login`, run:

```bash
CLONE_URL=$(executor apps git --app "$APP_ID")
git clone -c credential.helper= -c credential.helper='!executor apps credential' -c credential.useHttpPath=true "$CLONE_URL"
```

On **Local**, use the snapshot commands (`source`, `commit`, `deploy`), or enter the Local API key as the Git HTTP Basic password when prompted. A Git push saves source; deploy the pushed commit with `executor apps deploy --app "$APP_ID" --commit "$NEW_COMMIT"` to activate it.

### Deploying through an agent over MCP

Use a **Full access** MCP connection (with **All apps** if scoped). On **Cloud** or **Self-host**, read your organization ID from `tools.executor.context.get({})` and include `organization` in every `path` object (`path: { organization }` for `framework.release` and `appManagement.create`, and `path: { organization, app }` for `source`, `commit`, and `deploy`).

On **Local**:

- `tools.executor.framework.release({})` returns the target's `apps` version for `package.json`.
- `tools.executor.appManagement.create({ body: { name, files } })` creates an app from `{ path, content }` pairs.
- `tools.executor.appManagement.source({ path: { app } })` reads the working source and current `revision`.
- `tools.executor.appManagement.commit({ path: { app }, body: { expected, message, files } })` saves a new commit.
- `tools.executor.appManagement.deploy({ path: { app }, body: { commit } })` builds and activates that commit.

Start a new `execute` call after deploying to discover and run the newly deployed tool.

## Limits

- **Host resolution order:** `executor apps` commands resolve their target in this order: `--host`, then `EXECUTOR_HOST`, then the last host remembered by either `executor apps login` or `executor login`, then the Local background server. Pass `--host` or `EXECUTOR_HOST` explicitly when switching between targets.
- **Pinning `dependencies.apps`:** declare the exact version returned by `executor apps framework` in `dependencies.apps` to keep rebuilds on that release. Omitting `dependencies.apps` fails the build; a version range can resolve to a different published framework version.
- **Source size bounds:** code outside `ui/public/` must be UTF-8 text, at most 4,096 files and 16 MiB total, and each of your own JavaScript or TypeScript files is at most 2,000,000 bytes (JSON files and imported npm packages are outside the per-file JS/TS limit). Files under `ui/public/` may be binary: up to 10,000 files, at most 32 MB per file, and 1 GB total.
- **Git push size on hosted servers:** on hosted Executor, a single Git push larger than about 64 MiB of packed data fails; split large `ui/public/` additions across smaller commits.
- **No secrets in source:** never hardcode API keys or tokens in app files. Publishing on **Cloud** requires an organization **owner** or **admin** with app edit access and exposes the selected commit's files, package name, description, commit ID, and publication date. Connected account records, live app data, and private Git history stay behind (and paths such as `.env`, `.env.*`, and `.npmrc` are blocked), but credentials or private data written into included files become public. Use [Accounts and providers](/docs/build/accounts) for credentials.

## Related

- [Tools, routers, and schemas](/docs/build/tools)
- [Accounts and providers](/docs/build/accounts)
- [Framework versions and upgrades](/docs/build/upgrades)
- [Apps and versions](/docs/concepts/apps-and-versions)
