Mogplex Docs
Platform

Automation

The Mogplex CLI ships a headless subcommand surface alongside the interactive TUI. Use it for CI runs, dashboards, scheduled jobs, or anywhere a real terminal isn't available.

mogplex is two things in one binary:

  • An interactive cockpit (the TUI you get when you run mogplex with no arguments). Covered in CLI → Quickstart.
  • A headless subcommand surface for scripts, CI, dashboards, and scheduled jobs. Covered here.

The dispatch is automatic: if the first argument is a known subcommand (repos, run, runs, sandboxes), the CLI runs headlessly and exits. Any other invocation boots the TUI.

When to use which

You want to…Use
Edit code interactively with the agentmogplex (TUI)
Start a cloud run from a script or CI stepmogplex run
Tail a run's events from a CI logmogplex runs events <id> --follow
Power a status dashboard with read-only accessmogplex repos list + mogplex sandboxes list --json
Cancel a runaway run from a Slack bot or webhookmogplex runs cancel <id>

The headless surface talks to the same /api/v1/mogplex/* endpoints documented under API Reference. The CLI just bundles the typed client, output formatting, exit codes, and credential resolution.

Quick start

# Set up a personal access token at https://www.mogplex.com/settings/api-keys
export MOGPLEX_API_KEY="mog_..."

# List your repos to find an ID
mogplex repos list

# Start a run
mogplex run --repo <repo-id> --harness codex "Refactor auth to use bearer tokens"

# Tail it
mogplex runs events <run-id> --follow

Commands

CommandScopePurpose
mogplex repos listreadList your cloud-linked repos
mogplex runwriteStart an agent run
mogplex runs get <id>readGet a run's current state
mogplex runs events <id>readList or tail a run's event stream
mogplex runs cancel <id>writeRequest cancellation
mogplex sandboxes listreadList cloud sandboxes
mogplex sandboxes stop <id>writeStop a sandbox (placeholder, see below)

mogplex sandboxes stop is a placeholder until the v1 sandbox lifecycle routes ship. Today it prints a message pointing you at the web UI. The CLI will switch to the v1 endpoint automatically once it lands.

Output formats

Every command supports --json for machine-readable output (NDJSON for lists, single object for get / start / cancel). Without --json you get a human-friendly table or summary.

mogplex repos list                # table
mogplex repos list --json         # one JSON repo per line

Auth precedence

1. MOGPLEX_API_KEY env var       (highest priority)
2. ~/.mogplex/auth.json          (from `mogplex` → /login)

Set MOGPLEX_API_KEY for CI and one-shots (MOGPLEX_API_KEY=mog_... mogplex repos list). The auth.json fallback works without any env setup once you've signed in via the TUI.

See Authentication for PAT issuance, scope model (read / write), revocation, expiry, and rate limits.

Base URL

The CLI hits https://www.mogplex.com by default. Override with:

export MOGPLEX_URL="https://staging.mogplex.com"

For local development, set MOGPLEX_DEV=1 and NODE_ENV to something other than production to allow http://localhost:*.

Exit codes

The CLI follows clig.dev / sysexits conventions:

CodeMeaning
0Success
1Generic failure
2Usage error (bad args, unknown subcommand)
64Unauthorized (no token / 401)
65Forbidden (PAT lacks required scope / 403)
69Service unavailable (503)
75Temporary failure / rate limited (429) — caller can retry

Branch on exit codes in shell scripts:

mogplex runs events "$RUN_ID" --follow
case $? in
  0)  echo "run completed cleanly" ;;
  64) echo "auth failed — refresh MOGPLEX_API_KEY"; exit 1 ;;
  65) echo "PAT lacks write scope" ; exit 1 ;;
  75) echo "rate limited — backing off" ; sleep 60 ; exec "$0" "$@" ;;
  *)  echo "unexpected failure (exit $?)" ; exit 1 ;;
esac
Edit on GitHub

On this page