#### Cloud Agents

# Self-hosted machines

Self-Hosted Machines moves Cloud Agent tool execution to a machine you manage. Your team still uses Cloud Agents through the desktop app, [cursor.com/agents](https://cursor.com/agents), and [mobile](/build/agents-window/cloud-agent/mobile). Grok Build runs the agent loop, inference, and planning. Your worker performs file edits and terminal commands. It also runs computer-use tools and local MCP servers.

> [!NOTE]
>
> Managed Cloud Agents are the recommended path for most teams and the
> fastest way to get started. See [Choose where Cloud Agents
> run](/build/agents-window/cloud-agent/self-hosted/choose-runtime) before bringing
> Cloud Agents to your own machines.

## Who should use self-hosted machines

Use Self-Hosted Machines when Grok Build's managed cloud can't meet your constraints:

* You have strict network requirements, and code or services can't be reached from outside your network. For private source control or package registries, start with managed Cloud Agents and [private connectivity](/build/agents-window/cloud-agent/private-connectivity) ([AWS PrivateLink](/build/agents-window/cloud-agent/private-connectivity#aws-privatelink) or [Cloudflare Tunnel](/build/agents-window/cloud-agent/private-connectivity#cloudflare-tunnel)).
* You have custom hardware, such as GPU machines or Macs for iOS development. Use a machine you already run, or a VM from a [partner host](/build/agents-window/cloud-agent/self-hosted/integrations) such as AWS Lambda, Cloudflare, Namespace, Modal, Daytona, E2B, Vercel, Tensorlake, Superserve, or Render.
* You have custom images, such as a different operating system or an existing build pipeline, that are difficult to save as a [Cloud Agent build](/build/agents-window/cloud-agent/builds).

> [!TIP]
>
> If you want to try this out, check out the [My Machines
> quickstart](/build/agents-window/cloud-agent/self-hosted/my-machines#quickstart).

### Prefer managed Cloud Agents when

You don't need to own the compute to keep agents inside your security perimeter. Stay on managed Cloud Agents when these controls cover your requirements:

* Isolated VMs per agent, provisioned and torn down by Grok Build, with no worker fleet to size, patch, scale, or keep on call.
* [Network allowlists](/build/agents-window/cloud-agent/security-network#network-access) that restrict outbound domains by user, team, or environment.
* [Private connectivity](/build/agents-window/cloud-agent/private-connectivity) over AWS PrivateLink or Cloudflare Tunnel to self-hosted GitHub Enterprise Server, GitLab Enterprise, and private source control APIs, plus [Tailscale or a similar client](/build/agents-window/cloud-agent/security-network#private-network-access) for services in your VPC.
* Privacy Mode and customer-controlled secrets scoped to the environments you choose. See [Cloud Agent security and network](/build/agents-window/cloud-agent/security-network) for the full model.

## What leaves your network

The full checkout, build cache, and machine-local credentials stay on your machine. During a run, the worker sends Grok Build the content the agent needs, such as file contents, terminal output, diffs, screenshots, local MCP results, and routing metadata. If you enable [desktop sharing](/build/agents-window/cloud-agent/self-hosted/computer-use#share-the-agent-desktop), it also streams the agent desktop. If you enable the [live workspace](#live-workspace), it relays the agent's files, terminal, and forwarded ports to people who open the agent in the desktop app.

The worker uploads Cloud Agent artifacts, such as screenshots, videos, and log references, to managed storage so they can appear in pull requests and the dashboard. Keep secrets out of tool output and artifacts.

> [!NOTE]
>
> [Privacy Mode](https://cursor.com/data-use) also applies to Self-Hosted Machines. When enabled,
> code sent from the worker is not used for training by Grok Build or model
> providers.

Workers need outbound HTTPS access to:

* `api2.cursor.sh` and `api2direct.cursor.sh` for the agent session
* `api3.cursor.sh` for worker metrics
* `downloads.cursor.com` for the CLI installer and updates
* `agent-stores.s3.us-east-1.amazonaws.com` for agent store sync and artifact uploads, including screenshots
* `cloud-agent-artifacts.s3.us-east-1.amazonaws.com` for artifact uploads when the agent's store isn't available

See [Networking](/build/agents-window/cloud-agent/self-hosted/pool#networking) for a connectivity check and what breaks when each host is blocked.

No inbound ports, public IPs, or VPN tunnels are required. If you use a proxy, set `HTTPS_PROXY` or `https_proxy` in the worker environment.

To disable artifact uploads, block outbound traffic to both artifact hosts on the worker. Workers upload artifacts to `agent-stores.s3.us-east-1.amazonaws.com` and use `cloud-agent-artifacts.s3.us-east-1.amazonaws.com` only when the agent's store isn't available, so blocking `cloud-agent-artifacts` alone doesn't stop uploads. Blocking both only prevents artifacts from uploading. The agent continues to work, including tool calls and results, but its artifacts won't appear in pull requests or the dashboard.

> [!NOTE]
>
> You can connect up to 10,000 workers per user and 10,000 per team. For
> larger company-wide deployments, [contact
> us](https://cursor.com/contact-sales?source=self-hosted-agents) to discuss
> scaling.

## How it works

| Term | Definition | Example |
| :--- | :--- | :--- |
| **Worker** | A machine you own, registered to Grok Build with `cursor-agent`. The place where the agent gets work done: editing files, running commands, and accessing code. | A Linux VM in your AWS account, or a Mac mini on your desk. |
| **Pool** | A routing target you can select in the Grok Build client UI. Chats wait in the pool until a worker claims them. Once a worker claims a chat, all activity in that chat is forwarded to the worker. | A `gpu` pool routes requests that need GPUs, served only by machines with GPUs. An `ios` pool is served only by Macs for chats related to iOS development. |
| **Controller** | Code you run that adjusts worker capacity based on demand. | A request arrives on a pool with no idle workers. Your controller notices and starts a new machine. |

Use `cursor-agent`, the CLI that runs self-hosted workers, to start a worker on your machine. `cursor-agent worker start` opens a long-lived outbound HTTPS connection to Grok Build's backend, and Grok Build sends agent tool calls over that connection. Grok Build never connects into your network: the outbound connection from your machine to Grok Build is all that's required.

Diagram: the Agents Window, the agent loop and inference run in Grok Build’s cloud; the worker and its terminal, filesystem and browser tools run inside your network, linked by one outbound HTTP/2 connection the worker opens.

Workers come in two configurations:

1. **My Machines.** Best for personal workflows and one-offs: your devbox, a spare VM, or a machine with state you don't want to recreate. Connect a machine to your account. Multiple agents can run on the same machine. See [My Machines](/build/agents-window/cloud-agent/self-hosted/my-machines).
2. **Pools.** Best for teams and enterprises: shared capacity, service account authentication, and centrally managed images. Register machines under a pool name, and Grok Build routes each new chat to an available machine in the pool, one agent per machine. Run a controller to scale the pool up and down. See [pools](/build/agents-window/cloud-agent/self-hosted/pool).

To run pool workers on a third-party VM or sandbox, see [Integrations](/build/agents-window/cloud-agent/self-hosted/integrations).

## Environments on self-hosted machines

A [Cloud Agent environment](/build/agents-window/cloud-agent/setup#what-is-a-cloud-agent-environment) is the saved setup a managed agent starts from: repositories, dependencies, secrets, startup commands, and network access. A self-hosted run uses only the environment's repositories. Pool workers that opt in to Secret sync also get team and user secrets. Every other environment setting applies only to managed Cloud Agents, so you set those up on the machine.

**Repositories.** What the worker does with the environment's repositories depends on how you run it:

* An [any-repo pool](/build/agents-window/cloud-agent/self-hosted/pool#any-repo-pools) worker started with `--clone-git-repos` checks out every repository at the requested branch or commit.
* A repo-backed pool worker or a My Machines worker uses the checkouts it already has, without switching branches or cloning. Your [`sessionStart` hook](/build/agents-window/cloud-agent/self-hosted/pool#hooks) receives every repository in the request as `repo_urls` and `repos`, so it can clone the ones the worker doesn't have.

**Secrets.** A pool worker started with `--sync-dashboard-secrets` gets secrets as environment variables once a team admin turns on **Secret sync** in the [Cloud Agents dashboard](https://grok.com/dashboard/cloud-agents/machines):

* Team and user secrets available to the run's repositories. Any-repo pools get only secrets that aren't limited to a repository.
* `envVars` passed to [Create An Agent](/build/agents-window/cloud-agent/api/endpoints#create-an-agent).

Environment-scoped secrets and Build Secrets never reach a worker. My Machines workers get no dashboard secrets and use the machine's own credentials.

**Everything else.** Replace each remaining setting with its self-hosted equivalent:

| Environment setting | Self-hosted equivalent |
| :--- | :--- |
| Install script and startup commands | A `sessionStart` hook in `.cursor/hooks.json`, [`--on-session-start`](/build/agents-window/cloud-agent/self-hosted/pool#hooks) on pool workers, or the worker image |
| Terminals and ports | A hook or your own process manager |
| Dockerfile, image, snapshot, and user | The machine or worker image, running as the worker's OS user |
| [Builds](/build/agents-window/cloud-agent/builds) | A prepared worker image, or warm workers from the [worker controller](/build/agents-window/cloud-agent/self-hosted/pool#warm-pool) |
| [Network access settings](/build/agents-window/cloud-agent/security-network#network-access) | The machine's firewall or HTTPS proxy |
| Environment-scoped secrets | Secrets on the machine, or team and user secrets through Secret sync |
| MCP server limits in `environment.json` | Your team's [MCP servers](/build/agents-window/cloud-agent/self-hosted/pool#mcp-servers), available to every run with no per-environment limit |
| `.cursor/environment.json` in the repository | `.cursor/hooks.json` in the worker directory |

## Live workspace

Start a Linux worker with `--connect-workspace` to open an agent's live workspace from the Grok Build desktop app: its files and changes, a terminal, and forwarded ports. It works on [My Machines](/build/agents-window/cloud-agent/self-hosted/my-machines) and [pools](/build/agents-window/cloud-agent/self-hosted/pool) workers.

```bash
# My Machines
cursor-agent worker --connect-workspace start

# Pools
cursor-agent worker --pool my-pool --connect-workspace start
```

* **Off by default.** Grok Build never turns it on for you. The worker reads the flag at startup, so restart it after you add the flag. To turn it off, restart the worker without the flag.
* **Linux only.** On macOS and Windows, the worker logs `--connect-workspace requires a Linux worker` and starts without the live workspace. Those workers behave as they do today.
* **Grok Build 3.25 or later.** The worker installs only server builds whose published signature verifies. Older Grok Build versions show "Update Grok Build to 3.25 or later to open this workspace."
* **Server download.** When the desktop app opens one of its agents, the worker downloads the server build for that Grok Build version from `downloads.cursor.com`, falling back to `cursor.blob.core.windows.net`, into `~/.cursor-server/bin/<commit>/`, once per version, and runs it on `127.0.0.1`. Workspace traffic uses the worker's existing outbound connection, so no inbound ports open.

> [!WARNING]
>
> The live workspace runs as the worker's OS user. Anyone who can open one of
> the worker's agents gets a terminal and file access as that user: the agent's
> owner, plus teammates when a team admin turns on **Allow VM sharing** in the
> [Cloud Agents dashboard](https://grok.com/dashboard/cloud-agents). Tasks and
> settings in the repository also run as that user, including tasks that run
> when the workspace opens. The worker serves only agents it's already running.

### Troubleshoot the live workspace

**Why does the workspace say Worker offline?**

The agent's worker isn't connected to Grok Build. Start the worker again. The
desktop app reconnects when the worker is back.

**Why is the terminal unavailable?**

The terminal tab says why. "To use the terminal, restart the worker with
the --connect-workspace flag" means the worker started without the flag.
"Terminal is only available on Linux workers" means it runs on macOS or
Windows. To confirm the flag took effect, restart with `--verbose` and look
for `cursor-server enabled (--connect-workspace)` in the startup output.

**Why does Grok Build ask me to update to 3.25 or later?**

Your Grok Build version has no signed server build, and the worker refuses
unsigned builds. Update the desktop app, then open the agent again.

**Why didn't the server download verify?**

When a download doesn't match its Grok Build signature or carries an invalid
one, the worker installs and runs nothing, and the worker log says why. If
another agent or worker process on the machine is still running a copy of
that build, end that session or stop that worker, then retry. A download
whose bytes don't match fails again on retry. If the log shows the download
itself failed, allow outbound HTTPS to `downloads.cursor.com` and
`cursor.blob.core.windows.net`.
Grok Build provides no mirror.

## Supported deployment patterns

Run a worker anywhere you can install `cursor-agent` and its dependencies:

* **Personal machines.** Connect a laptop, devbox, Mac, or remote VM through [My Machines](/build/agents-window/cloud-agent/self-hosted/my-machines).
* **Persistent hosts or containers.** Run one or more pool workers under `systemd`, `launchd`, Docker, or another process manager.
* **Dynamic infrastructure.** Use the built-in [worker controller](/build/agents-window/cloud-agent/self-hosted/pool#worker-controller) or the Cloud Agents API to start machines when requests arrive.
* **Kubernetes.** Start from the [anysphere/k8s-workers](https://github.com/anysphere/k8s-workers) template. It runs `cursor-agent worker controller --spawn` in your cluster and creates one worker Pod per claimed request, or keeps warm Pods with `--warm-idle`, without a CRD. See [Integrations](/build/agents-window/cloud-agent/self-hosted/integrations#reference-templates).
* **Partner hosts and templates.** Run pool workers on AWS Lambda, Cloudflare, Namespace, Modal, Daytona, E2B, Vercel, Tensorlake, Coder, Superserve, or Render with partner guides, or clone a Grok Build reference template for AWS Lambda MicroVMs, Cloudflare Containers, or Kubernetes. See [Integrations](/build/agents-window/cloud-agent/self-hosted/integrations).

Deployment guides, partner guides, and templates are reference architectures. You own the worker image, infrastructure, secrets, scaling policy, and production validation.

## Cost

Every runtime option uses the selected model and follows its [pricing](/build/agents-window/models-and-pricing#model-pricing). Managed Cloud Agents include the execution infrastructure. With Self-Hosted Machines, you also pay for and operate your machines, containers, or cluster.

## Requirements

Every worker needs [`cursor-agent`](/build/agents-window/cloud-agent/self-hosted/worker-reference#install-grok-build-tui) and outbound HTTPS access. Install it on each machine:

```bash
curl https://cursor.com/install -fsS | bash
```

On Windows, run `irm 'https://cursor.com/install?win32=true' | iex` in PowerShell. The Grok Build TUI installer doesn't install `cursor-agent`.

**My Machines**

* A personal credential: browser login, or a personal user API key from [Grok Dashboard → API Keys](https://grok.com/dashboard/api-keys).

  ```bash
  cursor-agent login
  ```

* On a team, **Allow personal machines** or **Enable self-hosted machines** turned on by a team admin in the [Cloud Agents dashboard](https://grok.com/dashboard/cloud-agents/machines). **Allow personal machines** is the team's Remote Control setting. While both are off, Cloud Agents can't run on members' machines. When an admin turns **Allow personal machines** off, no run, including an [automation](/build/agents-window/cloud-agent/automations) run, can use a machine registered with a personal login. Workers registered with a service account aren't affected.

**Pools**

* A **Grok Build Enterprise plan**.

* A [service account API key](/build/agents-window/account/enterprise/service-accounts) for worker authentication. Personal logins and other API key types can't start pool workers.

  ```bash
  export CURSOR_API_KEY="<team service-account API key>"
  ```

* Self-hosted settings configured by a team admin in the [Cloud Agents dashboard](https://grok.com/dashboard/cloud-agents/machines): **Enable self-hosted machines** lets users opt in, and **Require self-hosted and personal machines** keeps every Cloud Agent run on self-hosted or personal machines.

**Computer use** (optional)

* A macOS worker with a signed-in desktop session. The CLI installs the **Cursor Computer Use** helper app on first start; grant it **Accessibility** and **Screen Recording** in System Settings.
* Or a Linux worker with the desktop packages. The worker creates its own desktop or reuses an existing X11 display:

  ```bash
  sudo apt-get install -y --no-install-recommends \
    dbus-x11 ffmpeg tigervnc-standalone-server \
    x11-utils x11-xserver-utils xdotool xfce4
  ```

  See [Computer use and desktop sharing](/build/agents-window/cloud-agent/self-hosted/computer-use) for the macOS permission steps and the full Linux setup.

## Next steps

* [Choose where Cloud Agents run](/build/agents-window/cloud-agent/self-hosted/choose-runtime): compare managed Cloud Agents, My Machines, and pools.
* [My Machines](/build/agents-window/cloud-agent/self-hosted/my-machines): connect your first worker in a few minutes, then configure personal workers, workspace roots, and local MCP servers.
* [Pools](/build/agents-window/cloud-agent/self-hosted/pool): organize workers into pools, and [scale worker capacity](/build/agents-window/cloud-agent/self-hosted/pool#worker-controller) with a controller.
* [Integrations](/build/agents-window/cloud-agent/self-hosted/integrations): partner guides for AWS Lambda, Cloudflare, Namespace, Modal, Daytona, E2B, Vercel, Tensorlake, Coder, Superserve, and Render, and reference templates for AWS Lambda MicroVMs, Cloudflare Containers, and Kubernetes ([anysphere/k8s-workers](https://github.com/anysphere/k8s-workers)).
* [Computer use](/build/agents-window/cloud-agent/self-hosted/computer-use): let agents drive a desktop and browser on your workers.
* [API reference](/build/agents-window/cloud-agent/api/endpoints#workers-and-pools): endpoints for workers, pools, the pending-request queue (list, SSE watch, claim, and release), and worker tokens.
* [Self-Hosted Machines](/build/agents-window/help/ai-features/self-hosted-machines): short answers for setup, pools, integrations, and troubleshooting.
