# Set up Legato

Legato gives a coding agent a desktop. You can also run a task from a terminal, from Python, or by speaking to the Mac app.

## Start

One command installs Legato and adds it to the coding agents on this computer (Claude Code, Codex, opencode, Cursor, Claude Desktop):

```bash
curl -LsSf https://legato.computer/install.sh | sh
```

On Windows, in PowerShell: `irm https://legato.computer/install.ps1 | iex`. If legato.computer answers with a "Security Checkpoint" page (some cloud machines get one), use the same script from GitHub: `curl -LsSf https://raw.githubusercontent.com/legatolabs/legato/main/site/install.sh | sh`. It uses [uv](https://docs.astral.sh/uv/), installing it first if needed, so the Python on your computer doesn't matter. No API key is needed: your coding agent drives Legato's desktop with its own model.

Start a new session of your coding agent and ask:

> Open example.com in a browser window and tell me the page's title.

You should see a Legato tool call and the answer **Example Domain**. When Legato has a model configured, it asks your agent to delegate the task with `desktop_run_task`; without one, your agent uses its own model with Legato's desktop tools.

**By hand.** `uv tool install legatolabs` (or `pipx install legatolabs`), then `legato setup --mcp claude` (or `codex`, `opencode`, `cursor`, `claude-desktop`). `pip install legatolabs` works inside a virtualenv; Ubuntu, Debian and Homebrew refuse it outside one.

**Where the browser opens.** Legato uses the desktop saved by `legato setup`. With no saved desktop, it uses a background Safari window on macOS or your real mouse and keyboard on Windows and Linux (X11). To work off your screen, start Docker and run `legato setup --yes --desktop docker --mcp claude` before opening the new session. The first Docker task pulls the desktop image. [Compare desktops](sandboxes.md).

**How to tell it’s working.** Watch the Legato tool call in Claude. On a Mac, the target window can sit behind your work while your pointer stays still. A delegated task appears as one call and returns its answer and final screen when it finishes. The on-screen progress pill belongs to the [standalone Mac app](mac.md#using-it).

**Other ways in.** For the Claude Desktop extension, one-click installs, or manual configuration, see [Coding agents (MCP)](mcp.md#connect-another-client).

## Choose a model for delegation, the terminal or Python

```bash
legato setup
```

Choose a vision model, a desktop, and the clients that should get it. Setup checks the model with a test image and offers a first task. You can use a provider key or a local model server. The task and screenshots go to the model that drives the desktop. Run setup again to change your choices and reconnect your MCP client to pick them up. [Models and providers](models.md).

For the menu bar app, [download Legato for Mac](https://github.com/legatolabs/legato/releases/latest/download/Legato.dmg) and follow [first launch](mac.md#first-launch).

## Steps for coding agents

If someone sends you *“Set up Legato for me”*, run the following steps in their environment.

1. **Install and connect.** Use the first that applies, in one command:
   - `uv` on PATH: `uv tool install legatolabs && legato setup --mcp claude`
   - else `pipx` on PATH: `pipx install legatolabs && legato setup --mcp claude`
   - else: `python3 -m venv ~/.local/share/legato/venv && ~/.local/share/legato/venv/bin/pip install legatolabs && ~/.local/share/legato/venv/bin/legato setup --mcp claude`
     (Windows: `py -m venv %LOCALAPPDATA%\legato\venv`, then that folder's `Scripts\pip` and `Scripts\legato`)

   Replace `claude` with `codex`, `opencode` or `cursor` for the current client, or `all`. Or run the script that does the same and installs uv first: `curl -LsSf https://legato.computer/install.sh -o legato-install.sh && sh legato-install.sh` (Windows PowerShell: `irm https://legato.computer/install.ps1 -OutFile legato-install.ps1; .\legato-install.ps1`). It needs no API key: don't ask the user for one unless they want `legato run`, Python or delegation. **In Codex,** it needs the network and writes outside the project, so run it with the user's approval outside the sandbox.
2. **Tell the user how to try it.** A client loads a new MCP server only in a new session, so ask the user to start one and send the browser prompt above. Say where input goes: with no saved desktop, a background Safari window on macOS, or the real mouse and keyboard on Windows and Linux (X11). A headless runner needs Docker, E2B or a custom sandbox ([desktops](sandboxes.md)).
3. **Only if the user asked for a terminal, Python or delegation:** configure a model as described below. If `legato setup --json` shows a working model, keep it.
4. **Grant local Mac access if needed.** For a local Mac window or screen, the user grants the app that launches Legato (terminal, editor, or MCP client) Accessibility for input and Screen Recording for capture in System Settings → Privacy & Security. `legato doctor` identifies the app and the settings panes. Restart the host app if macOS asks.
5. **Verify a terminal or Python setup** with `legato run "Open example.com in a browser and read the page's title" --json`. Look for `done: true` and **Example Domain** in `answer`, and report which desktop and model drove the task.

### Configure a model without prompts

With an existing provider key in the environment (for example `OPENROUTER_API_KEY` or `ANTHROPIC_API_KEY`), run `legato setup --yes --mcp none` to test and save the choice. The configuration records the variable’s name. The MCP server process needs access to that variable too.

For a new key, have the user enter it through the interactive setup, or supply it on stdin from their environment. For example, with the key already in `KEY`:

```bash
printf '%s' "$KEY" | legato setup --yes --provider openrouter --api-key - --mcp none
```

In PowerShell use `$KEY | legato setup --yes --provider openrouter --api-key - --mcp none`. A key supplied this way is stored in the user’s Legato configuration, normally `~/.config/legato/config.json`. [Key storage and removal](faq.md).

For a local vision server use `--provider local`. For another OpenAI-compatible endpoint use `--provider custom --base-url URL --model NAME`. Add `--desktop docker`, `--desktop e2b`, or `--desktop path/to/desktop.py:desktop` when the user chose a sandbox. E2B requires `pip install "legatolabs[e2b]"` and `E2B_API_KEY`. [Model options](models.md) · [Custom desktops](sandboxes.md).

## If something fails

| What you see | What to check |
|---|---|
| Claude does not list Legato | Run `claude mcp get legato` in your terminal. Look for **Connected**. If the server is missing, rerun `legato setup --mcp claude` and start a new Claude Code session. |
| Claude opens the desktop one action at a time | Its own model is driving. To delegate, run `legato setup`, check the model with `legato doctor --model`, then reconnect the client. A server started with a zero request cap also uses direct tools. |
| Docker fails to open a desktop | Start the Docker engine. Check `docker info` from the account that runs the MCP client and allow time for the first image pull. |
| Clicks do nothing or the image shows only wallpaper on macOS | Check Accessibility and Screen Recording for the host app using `legato doctor`. For a background task, keep the window on the current Space and restore it if minimized. |
| The model answers but never acts, or clicks in the wrong place | `legato doctor --model` checks image support, tool calls and click coordinates. |

For a machine-readable diagnostic, run `legato doctor --json`. [MCP tool reference](mcp.md#tool-reference) · [Terminal and Python](python.md) · [Mac app](mac.md).
