# Command line

Source: https://docs.lightair.app/developers/control/command-line

> Call any Remote API method from a shell script with lightair call, or run Lightair's MCP server over stdio with lightair mcp, on macOS and Windows.

In short:
- `lightair call <method> [params]` makes one call to the running Lightair and prints the result as JSON.
- `lightair mcp` is Lightair's MCP server on stdin and stdout, for agents that start their tools as programs.
- Both read the Remote API password from the system's credential store, so you never type it.
- The program is `/Applications/Lightair.app/Contents/MacOS/lightair` on a Mac and `lightair.exe` in Lightair's folder on Windows.

The Lightair program has two commands for scripts and agents. Both talk to the Lightair that's already running, through its Remote API on this computer.

## Where the program is

| Platform | Path |
|---|---|
| macOS | `/Applications/Lightair.app/Contents/MacOS/lightair` |
| Windows | `C:\Program Files\Lightair\lightair.exe` when installed for all users |

**Settings › Remote API › Connect › AI agents (MCP)** shows the path of the copy you're running.

On a Mac, add an alias to your shell so the examples below work as written:

```sh
alias lightair="/Applications/Lightair.app/Contents/MacOS/lightair"
```

## Call a method

```sh
lightair call <method> [params as JSON]
```

The method is any [Remote API method](/developers/remote-api/app.version); the parameters are one JSON object, in single quotes so the shell leaves it alone. Without parameters, `{}` is sent.

```sh
lightair call app.version
lightair call scene.switch '{"scene": "Main"}'
lightair call object.update '{"object": "Webcam", "visible": false}'
lightair call record.start
```

The result is printed on stdout as indented JSON. Use it with `jq`:

```sh
lightair call state.get | jq -r '.program.name'
```

### How it connects

- It connects to `ws://127.0.0.1:<port>/rpc`, the port set in **Settings › Remote API**. The `LIGHTAIR_REMOTE_PORT` environment variable overrides it.
- When **Ask for the password** or **Other devices on your network** is on, it reads the password from the Keychain or Windows Credential Manager and sends it.
- It waits up to 60 seconds for the answer, and ignores any event that arrives first.
- Lightair must be running with **Let other apps control Lightair** on. `lightair call` doesn't open it.

### Exit codes

| Code | Meaning |
|---|---|
| `0` | The call worked. The result is on stdout |
| `1` | The call failed. The error's message is on stderr, for example "no scene Main", or "Lightair isn't running (…)" when nothing answers on the port |
| `2` | Used wrongly: no method ("usage: lightair call <method> [params as JSON]"), or parameters that aren't JSON |

```sh
if ! lightair call stream.start; then
  echo "Couldn't go live" >&2
fi
```

The command line is the person's own tool: going live and the other on-air actions don't ask for confirmation, as they do for AI agents.

### On Windows

`lightair.exe` is a windowed program, so a console doesn't wait for it or show what it prints unless its output is captured. In PowerShell, capture it:

```powershell
$lightair = "C:\Program Files\Lightair\lightair.exe"
$result = & $lightair call record.start | Out-String
$LASTEXITCODE
```

Older versions of PowerShell remove the double quotes inside an argument before the program sees them, so check that JSON parameters arrive intact.

## Run the MCP server over stdio

```sh
lightair mcp
```

`lightair mcp` reads MCP messages from stdin, one JSON message per line, and writes the answers, and any notifications for resources the agent subscribed to, to stdout, one per line. It passes them to the running Lightair's `/mcp` with the password from the credential store. You don't run it yourself: an agent starts it. For example, for Claude Code:

```sh
claude mcp add lightair -- "/Applications/Lightair.app/Contents/MacOS/lightair" mcp
```

What it adds to the HTTP server:

- **Lightair can be closed.** It answers `initialize`, `ping`, the lists and `prompts/get` by itself. On the first tool call it opens Lightair (on a Mac, in the background) and waits up to 40 seconds for the Remote API. If the Remote API is off in Settings, the call fails with "Lightair isn't running (open it, and turn on Settings › Remote API)".
- **Lightair can restart.** If Lightair quits and starts again, it starts a new session with the agent's own `initialize` and makes its subscriptions again.
- **Questions can wait.** A tool call that makes Lightair ask the person runs while other messages go on, and waits up to 150 seconds for its answer.

Everything else, the tools, resources, prompts and confirmations, is in [MCP server](/developers/control/mcp).

## Related

- [Connect to the Remote API](/developers/control/connect)
- [MCP server](/developers/control/mcp)
- [Errors](/developers/control/errors#command-line)
