> ## Documentation Index
> Fetch the complete documentation index at: https://docs.agentfront.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Build Exec Executor

> Build a distributable bundle using frontmcp build --target node

Builds a distributable executable bundle using esbuild. Produces a single-file output ideal for containerized deployments.

## Usage

```bash theme={"theme":{"light":"snazzy-light","dark":"dark-plus"}}
nx build-exec my-app
```

## Configuration

```json project.json theme={"theme":{"light":"snazzy-light","dark":"dark-plus"}}
{
  "targets": {
    "build-exec": {
      "executor": "@frontmcp/nx:build-exec",
      "outputs": ["{projectRoot}/dist"],
      "options": {
        "entry": "{projectRoot}/src/main.ts",
        "outputPath": "{projectRoot}/dist"
      }
    }
  }
}
```

## Options

| Option       | Type      | Description                                       |
| ------------ | --------- | ------------------------------------------------- |
| `entry`      | `string`  | Entry file path                                   |
| `outputPath` | `string`  | Output directory path                             |
| `cli`        | `boolean` | Generate CLI with subcommands per tool (optional) |

## CLI Mode

Pass `cli: true` (or use `frontmcp build --target cli`) to generate a standalone CLI executable with auto-generated subcommands for every tool, resource, prompt, and template in your MCP server.

```json project.json theme={"theme":{"light":"snazzy-light","dark":"dark-plus"}}
{
  "targets": {
    "build-exec": {
      "executor": "@frontmcp/nx:build-exec",
      "outputs": ["{projectRoot}/dist"],
      "options": {
        "entry": "{projectRoot}/src/main.ts",
        "outputPath": "{projectRoot}/dist",
        "cli": true
      }
    }
  }
}
```

### Output Files

| Mode        | Output                     | Description                      |
| ----------- | -------------------------- | -------------------------------- |
| Server only | `dist/{name}-server.cjs`   | Single-file MCP server bundle    |
| Server only | `dist/{name}-runner.sh`    | Shell runner with env/port setup |
| CLI mode    | `dist/{name}-server.cjs`   | Single-file MCP server bundle    |
| CLI mode    | `dist/{name}-cli.cjs`      | Generated Commander CLI entry    |
| CLI mode    | `dist/{name}-runner.sh`    | Shell runner for the CLI         |
| CLI mode    | `dist/{name}-installer.sh` | Install script (optional)        |

### `frontmcp.config.js` — CLI Options

The `cli` block controls what the generated CLI includes:

```js theme={"theme":{"light":"snazzy-light","dark":"dark-plus"}}
// frontmcp.config.js
module.exports = {
  name: 'myapp',
  version: '1.0.0',
  cli: {
    enabled: true,
    outputDefault: 'text',       // 'text' | 'json'
    authRequired: false,         // inject OAuth token into calls
    description: 'My MCP CLI',
    excludeTools: [],            // tool names to omit from CLI
    nativeDeps: {                // checked by generated `doctor` command
      brew: [],
      apt: [],
      npm: [],
    },
    oauth: {
      serverUrl: 'https://auth.example.com',
      clientId: 'my-app',
      defaultScope: 'read write',
      portRange: [17830, 17850], // local callback port range for PKCE
      timeout: 120000,           // login flow timeout (ms)
    },
  },
};
```

| CLI Config Key       | Type               | Description                                  | Default          |
| -------------------- | ------------------ | -------------------------------------------- | ---------------- |
| `enabled`            | `boolean`          | Enable CLI generation                        | `false`          |
| `outputDefault`      | `string`           | Default output format (`text` or `json`)     | `'text'`         |
| `authRequired`       | `boolean`          | Auto-inject OAuth token into all calls       | `false`          |
| `description`        | `string`           | CLI description shown in `--help`            | app name         |
| `excludeTools`       | `string[]`         | Tool names to exclude from the generated CLI | `[]`             |
| `nativeDeps`         | `object`           | System dependencies for `doctor` command     | `{}`             |
| `oauth.serverUrl`    | `string`           | OAuth authorization server URL               | —                |
| `oauth.clientId`     | `string`           | OAuth client ID                              | —                |
| `oauth.defaultScope` | `string`           | Default OAuth scopes                         | —                |
| `oauth.portRange`    | `[number, number]` | Port range for local PKCE callback           | `[17830, 17850]` |
| `oauth.timeout`      | `number`           | Login flow timeout in ms                     | `120000`         |

## Caching

This executor is **cacheable**. The bundled output is deterministic given the same inputs.
