mola-cloud
v0.9.0
Published
CLI and MCP server for persistent Mola Cloud computers
Readme
Mola Cloud CLI
Manage computers through the Mola control-panel API. Requires Node.js 22 or later.
Use npx --yes mola-cloud without a global install. Its binary is mola-cloud,
separate from the open-source mola binary. Cloud access currently requires
a Mola Cloud account.
Start with:
npx --yes mola-cloud login
npx --yes mola-cloud create atlas --wait
npx --yes mola-cloud exec atlas -- uname -a
npx --yes mola-cloud desktop atlas
npx --yes mola-cloud stop atlas --waitMCP for Claude, Codex, and other agents
The same package includes a stdio MCP server with computer lifecycle, shell, file, screenshot, pointer, keyboard, desktop, Cua Driver, snapshot, operation, and migration tools. The MCP process automatically reuses one persistent low-latency action session per computer while the agent works. Log in once, then add it to any MCP-compatible agent:
npx --yes mola-cloud login
claude mcp add mola-cloud -- npx --yes mola-cloud mcp
codex mcp add mola-cloud -- npx --yes mola-cloud mcpFor unattended agents, provide MOLA_TOKEN from a secret manager in the MCP
server environment. Run npx --yes mola-cloud mcp directly only when an MCP
client is attached; stdout is reserved for the protocol.
Run npx --yes mola-cloud --help for every implemented command. For a source
checkout, replace npx --yes mola-cloud with
node packages/mola-cloud/bin/mola-cloud.js.
Authentication and local development
login uses browser approval. It prints the verification URL and short user code
on stderr; it opens a browser only on an interactive terminal. --no-open works
on remote terminals. No command prompts for passwords or waits for terminal input.
The poll handles pending approval, persistent slow-down, denial and expiry.
A lost token response requires a fresh login; token redemption is not retried.
The default API is https://cloud.mola.sh/api/v1. Override MOLA_API_URL or
--api-url for a different installation. HTTPS verification is always enabled:
export MOLA_API_URL=https://mola-cloud.test/api/v1
# If Node does not trust Herd's local CA, use its actual certificate file:
export NODE_EXTRA_CA_CERTS=/absolute/path/to/local-ca.pem
node packages/mola-cloud/bin/mola-cloud.js login --no-openThe current credential storage fallback is a private JSON file at
~/.config/mola-cloud/credentials.json, with directory mode 0700 and file mode
0600 on Unix. There is no OS keychain integration yet. On Windows, keep the
configuration directory in your private user profile with user-only ACLs; POSIX
mode checks cannot enforce Windows ACLs. MOLA_CONFIG_DIR overrides its directory.
Never put this directory in a shared/project folder or commit it. Credentials
are keyed by the complete normalized API URL; switching APIs never reuses a
saved token from another installation. File writes use atomic replacement.
For CI, provide MOLA_TOKEN from a secret manager. This explicit environment token
applies to the API you configure and takes precedence over saved credentials.
login requires it to be unset. Account login tokens are never printed or passed
as command arguments. Machine-grant creation deliberately returns its secret
once through explicit JSON output. logout revokes only the current CLI token and clears saved state;
if remote revocation fails it reports the failure after clearing local state.
Revoke the session in Settings if connectivity prevented server revocation.
Commands and behavior
mola-cloud whoami
mola-cloud account --json
mola-cloud doctor
mola-cloud profiles
mola-cloud images
mola-cloud list
mola-cloud show atlas
mola-cloud create atlas --profile small --image omarchy --auto-stop 30 --wait
mola-cloud wake atlas --wait
mola-cloud restart atlas --wait
mola-cloud stop atlas --wait
mola-cloud delete atlas --yes --waitCreation uses the selected image's preferred default profile when available to
your account, otherwise the first available profile in the ordered catalog.
It uses the server's default image and reports both selections on stderr. Supply explicit slugs for
reproducible automation; when no default image exists and multiple images are
available, --image is required. Omitted auto-stop uses the account/platform
default; --auto-stop never requests no automatic stop.
Names must match exactly and uniquely within your account. Ambiguous names fail with matching IDs; any command accepts the computer ID. The API currently lists all account computers without pagination. Capacity and entitlement errors come from the server; the CLI does not silently stop another computer to make room.
--wait waits for the returned operation to succeed; lifecycle responses refresh
the computer afterward. --timeout bounds the wait (300 seconds by default,
maximum 24 hours). Ctrl-C stops waiting; it does not cancel the server operation.
operation show|wait <computer> <operation-id> resumes observation independently.
Delete requires --yes and destroys the entire disk. Stop retains it. After a
successful delete --wait, the JSON result is {data:{id,deleted:true},operation,
request_id} rather than the original, now-stale computer resource. Without
--wait, deletion returns the accepted computer state and pending operation.
mola-cloud exec atlas -- printf '%s\n' 'literal $HOME; spaces and quotes'
mola-cloud exec atlas -- sh -lc 'uname -a && pwd'
mola-cloud exec atlas --exec-timeout 120 -- long-running-command
mola-cloud desktop atlas --no-open
mola-cloud ssh atlas
mola-cloud ssh atlas --print
mola-cloud ssh-key add laptop --file ~/.ssh/id_ed25519.pub
mola-cloud ssh-key list
mola-cloud ssh-key remove KEY_ID --yesexec quotes every argument for the guest POSIX shell, streams the returned stdout
and stderr unchanged, and exits with the guest exit code. Output is returned after
the action completes, rather than streamed live. Use explicit sh -lc when you
want shell syntax. --json returns the structured action result while preserving
the exit code. Exec's timeout defaults to 30 seconds (maximum 120). Arbitrary
commands/actions are never automatically retried, even on network failures.
Desktop opens the authenticated control-panel viewer; that browser may require
its own sign-in. It never exposes a desktop-session bearer URL. SSH uses the
server's public structured host/port/username and the system ssh client, with
no shell evaluation. Upload a public key first. Private keys remain local; the
normal SSH client performs host-key verification. The CLI never contacts private
compute-host management endpoints.
mola-cloud snapshot list atlas
mola-cloud snapshot create atlas before-upgrade --wait
mola-cloud snapshot restore atlas SNAPSHOT_ID --yes --wait
mola-cloud snapshot delete atlas SNAPSHOT_ID --yes --wait
mola-cloud snapshots
mola-cloud create copy --from-snapshot SNAPSHOT_ID --acknowledge-sensitive-state --wait
mola-cloud snapshots delete SNAPSHOT_ID --yes
mola-cloud migrate atlas --region eu-central --wait
mola-cloud action atlas --file action.json
mola-cloud session atlas --json
mola-cloud tunnel atlas 9222 --json
mola-cloud cua status atlas
mola-cloud cua open atlas
mola-cloud cua call atlas SESSION_ID list_windows
printf '%s\n' '{"x":640,"y":360,"scope":"desktop"}' > click-arguments.json
mola-cloud cua call atlas SESSION_ID click --file click-arguments.json
mola-cloud cua close atlas SESSION_IDPick desktop coordinates from a fresh Cua get_desktop_state image.
scope:"desktop" is required for desktop input on the current Omarchy image;
omitting it can select unavailable window input and return isError.
Restore replaces the entire disk, losing subsequent changes. Snapshot deletion
is irreversible. These commands require explicit --yes and preserve backend
prerequisite errors (for example, stop the computer, or wait for archive upload).
Saved snapshots remain in the account after their source computer is deleted.
Creating from one makes an independent computer with a new Mola identity and SSH
host keys. The acknowledgement is required because customer files, installed
credentials, and browser sessions inside the disk are copied too.
The CLI does not silently stop a computer. Migration and archived recovery still
require configured backends and available target capacity; a CLI command does
not enable those services. Action JSON uses the public API contract, such as
{"action":"read_file","path":"/home/dev/example.txt"}.
Cua sessions keep the driver's MCP connection open across calls, so an agent
can inspect state and act within one session. cua open returns the session ID
and advertised tool schemas. Cua tool results, including screenshots, pass
through unchanged; inspect isError before assuming an action succeeded.
The current Omarchy image supports desktop-scoped input, but its experimental
Hyprland plugin is disabled, so window-scoped input may be unavailable. The
public API and MCP server use the same owner-scoped session endpoints.
Automation, errors and retries
--json emits one JSON result on stdout; progress and authorization instructions
go to stderr. Errors include stable API codes, HTTP status, validation details
and the mutation request ID when available. Normal API failures exit 1; interrupted
commands exit 130; guest commands preserve their own exit status.
Lifecycle/storage mutations automatically generate an Idempotency-Key, reused
on at most two bounded retries for network errors or retryable 429/502/503/504.
Retry-After delays above five seconds are surfaced instead of waiting silently.
Use --request-id YOUR_STABLE_KEY across CLI invocations with the same payload
to replay a completed receipt. Never reuse a key for a different intent. A timeout
or server error can leave the result unknown; subsequent attempts with that key
return 409 idempotency_conflict. Inspect the computer and its operations before
issuing a new mutation. Elapsed time does not make an uncertain write safe to repeat.
Actions and device-auth/session requests are never automatically retried.
Request timeouts are separately bounded (normally 30 seconds).
The exported MolaClient provides the same authenticated transport, name
resolution, operation wait, connected persistent action sessions and scoped
tunnel grants for Node callers:
import { MolaClient } from 'mola-cloud';
const client = new MolaClient({ token: process.env.MOLA_TOKEN });
const { data } = await client.request('/computers');
const session = await client.openActionSession('atlas');
const result = await session.action({ action: 'exec', command: 'uname -a' });
session.close();
const cdp = await client.createTunnel('atlas', 9222);
// Pass cdp.websocket_url directly to a trusted WebSocket client. It contains
// a single-use token, so do not print, cache, retry, or expose it to a browser.The persistent action protocol carries {id, op:"action", action:{...}}
messages and returns the same id. It supports binary screenshot/read results,
binary file writes, screen subscriptions and ping/pong. A tunnel accepts binary
frames only and reaches the requested loopback port on that one computer. Both
grant types expire, have bounded session limits, and are invalidated by computer
lifecycle changes. openActionSession reconstructs binary screenshot and file
results into the same base64 fields returned by the HTTP API. Mint a new grant
after any disconnect.
Verification and packaging
cd packages/mola-cloud
npm test
npm run check
npm pack --dry-runTests use Node's built-in runner and local HTTP fixtures through an injected transport; the production client still refuses HTTP. They cover authentication, scopes, origin binding, credential file permissions, ambiguous names, shell quoting and exit codes, structured SSH, retry/idempotency behavior, operation waits, destructive confirmations, and archive-not-ready errors. There are no runtime dependencies or install scripts. macOS tests are executed locally; Linux/Windows compatibility is designed but requires their platform CI before claiming release qualification.
Ubuntu desktops
Discover the available images, then create an Ubuntu desktop:
mola-cloud images
mola-cloud create research --image ubuntu --waitWhen --profile is omitted, the selected image's default profile is used.
Ubuntu defaults to Lite (1 vCPU, 2 GB RAM and 20 GB persistent disk). Explicit
profiles still work when they meet the image's minimum resources. Omitting
--image keeps the configured default image, currently Omarchy.
Add --egress-country US to require verified U.S. egress. The request fails
when no eligible U.S. host is available; it does not relocate an existing
computer or allocate a dedicated IPv4 address. Account quotas still apply.
Bring your own Decodo browser proxy
Save and verify the Decodo HTTP endpoint credentials in the dashboard's Settings → Browser proxies. These are proxy username/password credentials, not a provider management API key. The customer pays Decodo directly. With the feature enabled, choose Ubuntu and attach the saved connection:
mola-cloud proxies --json
mola-cloud create browser --image ubuntu --proxy-connection <connection-id>Stdio MCP offers list_proxy_connections and proxy_connection_id on create_computer. Chrome uses the connection automatically and blocks traffic if it fails. Other applications retain the host's network. A U.S. proxy is independent of host placement; omit --egress-country to use any eligible host. Returned connection metadata never contains credentials.
Customer metadata and remote MCP credentials
mola-cloud create research --external-id customer-42 --label env=qa --ttl 120 --on-expire stop --wait
mola-cloud list --external-id customer-42 --label env=qa --status ready --json
mola-cloud update research --ttl never --clear-labels --json
mola-cloud grant create research worker --expires-in-days 7 --json
mola-cloud grant list research --json
mola-cloud grant revoke research GRANT_ID --yes --jsonUpdating labels replaces their complete map. Omitting TTL retains the existing
deadline; --ttl never clears it. Expiry action delete permanently removes the
computer and its disk. Expiry is separate from inactivity-based auto-stop and
is checked asynchronously once per minute. Storage recovery or unsafe lifecycle
states can defer the action. Activity does not extend the deadline; clear or reset
a passed deadline before waking the computer.
Remote MCP uses https://cloud.mola.sh/api/v1/mcp with an account bearer token
or browser OAuth approval. OAuth clients discover the authorization server and
register a callback dynamically, then use authorization code with S256 PKCE and
the canonical endpoint as their resource. Access tokens last up to one hour;
rotating refresh families expire after 30 days. Reusing a consumed refresh token
revokes the family. Manage approvals under Settings → Connected apps. OAuth
credentials authorize only account MCP, not REST or machine-specific endpoints.
Client ID metadata documents are not supported.
Remote MCP returns stateless JSON responses with no server-initiated SSE streams
or subscriptions. Authenticated GET/DELETE requests return 405; accepted
notifications return 202 with an empty body. Clients must accept both
application/json and text/event-stream. Remote tools currently cover inventory,
catalogs, metadata, lifecycle, commands, files, desktop, Cua and managed guest
tools, vault use, scoped viewers, jobs/events, pools, qualified checkpoints and
resize. Wallet, network and CAPTCHA tools require deployment qualification; saved
proxy selection, snapshots, fork and migration remain available through stdio MCP,
the CLI or REST.
A grant returns a one-time data.token and a machine-specific data.mcp_url.
Install that pair directly in your MCP client's secret settings. The machine
token can use only its exact computer MCP endpoint; it cannot use account,
REST/lifecycle/grant endpoints, or a sibling computer. It is never saved as the
CLI account login or minted through stdio MCP. Creation requires explicit JSON
output and is never automatically retried after a lost response. List/revoke
an ambiguous grant with your account credential before minting a replacement.
mola-cloud mcp-url [computer] --json returns a public endpoint without secrets.
The package exports a TypeScript-typed SDK:
import { MolaClient } from 'mola-cloud';
const client = new MolaClient({ token: process.env.MOLA_TOKEN });
const { data } = await client.listComputers({ labels: { env: 'qa' } });
await client.updateComputer(data[0], { ttl_minutes: null, labels: {} });SDK methods also include createComputer, listComputerGrants,
createComputerGrant, revokeComputerGrant and mcpUrl. A grant secret is
returned only by creation; callers control its secure handling.
Browser, vault and workflows
client.tool(computer, tool, arguments) exposes managed browser, installer, session, display and capture tools. Vault methods inject saved credentials without returning passwords or TOTP seeds. The client also exposes viewer grants, schedules/triggers and run history, pools, wallet payments, managed networking and CAPTCHA tasks. Mutations are not automatically retried; retain durable operation/request identities after uncertain outcomes. Consult the cloud guides and src/client.d.ts for method signatures. Paid provider features require deployment configuration and qualification. CLI JSON payloads can be piped with --file -; creation responses that contain one-time tokens require --json.
Scheduled and triggered exec jobs accept a timeout of up to 900 seconds on
durable-execution hosts. The request enqueues work; inspect run history for its
eventual result. Interactive exec remains limited to 120 seconds. A missing
receipt retains the original run and reservation, so do not submit a replacement
command after an uncertain response. For example:
await client.createSchedule('atlas', {
name: 'daily report',
cron: '@daily',
definition: { type: 'exec', command: 'generate-report', timeout: 900 },
wake: true,
stop_after: true,
});For an already submitted durable exec run, use client.cancelRun(computer, runId)
or mola-cloud run cancel atlas RUN_ID. Cancellation keeps the original run
identity and reservation until its execution scope is confirmed ended. Queued,
waking and legacy synchronous runs do not support this endpoint.
