# CLI Overview

`ml-cli` is a command-line interface for the MoreLogin local `httpServer`. It translates CLI arguments into HTTP requests and forwards them to the local APIs exposed by the MoreLogin client.

## Overview

**Who is it for?**
DevOps engineers, QA automation engineers, and developers who prefer working in the terminal or need to integrate MoreLogin into CI/CD pipelines (such as GitHub Actions, Jenkins, or shell scripts).

**What can it do?**

- Call MoreLogin local APIs directly from a terminal without writing HTTP request code.
- Manage browser environments, proxies, cloud phones, and schedules from one unified interface.
- Use stable CLI flags instead of manually building JSON payloads.


**How to start?**

1. Read the **Prerequisites** below.
2. Download and install the CLI for your platform.
3. Check the [Quick Start](/cli/quick-start) to run your first command.


## Prerequisites

Before using `ml-cli`, make sure the following requirements are met:

- **MoreLogin desktop client** is installed and running on the same machine
- You have an active MoreLogin account with **API credentials** (API ID + API Key)


## Download & Installation

Download the latest `ml-cli` binary for your platform:

| Platform | Architecture | Link |
|  --- | --- | --- |
| Windows | x64 | [download](https://get.morelogin.com/client/prod/win/x64/2.6.1/ml-cli.exe) |
| macOS | x64 (Intel) | [download](https://get.morelogin.com/client/prod/mac/x64/2.6.1/ml-cli) |
| macOS | arm64 (Apple Silicon) | [download](https://get.morelogin.com/client/prod/mac/arm64/2.6.1/ml-cli) |
| Linux | x64 | [download](https://get.morelogin.com/client/prod/linux/x64/2.6.1/ml-cli) |


### Windows

1. Create a directory for the CLI, for example `C:\Program Files\MoreLogin\`:

```powershell
New-Item -ItemType Directory -Force -Path "C:\Program Files\MoreLogin"
```
2. Move the downloaded `ml-cli.exe` into that directory.
3. Add the directory to your system `PATH`:

```powershell
# Add to the current user's PATH permanently
$currentPath = [Environment]::GetEnvironmentVariable("Path", "User")
[Environment]::SetEnvironmentVariable("Path", "$currentPath;C:\Program Files\MoreLogin", "User")
```
4. **Restart your terminal** (or open a new one) for the change to take effect.
5. Verify:

```powershell
ml-cli --version
```


### macOS

1. Make the binary executable:

```bash
chmod +x ml-cli
```
2. Move it to a directory in your `PATH`:

```bash
sudo mv ml-cli /usr/local/bin/
```
> If `/usr/local/bin` does not exist, create it first: `sudo mkdir -p /usr/local/bin`
3. On macOS, the downloaded binary may be blocked by Gatekeeper. Remove the quarantine attribute:

```bash
xattr -d com.apple.quarantine /usr/local/bin/ml-cli
```
4. Verify:

```bash
ml-cli --version
```


### Linux

1. Make the binary executable:

```bash
chmod +x ml-cli
```
2. Move it to a directory in your `PATH`:

```bash
sudo mv ml-cli /usr/local/bin/
```
3. Verify:

```bash
ml-cli --version
```


Once installed, see [Quick Start](/cli/quick-start) to connect to the MoreLogin client and run your first command.

## Core Capabilities

The current CLI covers these resource groups:

- service status and login
- browser environment management via `env`
- cloud phone management via `cloudphone`
- group management via `group`
- tag management via `tag`
- proxy management via `proxy`
- cloud phone schedule management via `schedule`


## Request Model

The CLI supports two input styles:

- explicit flags, such as `--env-id` or `--group-name`
- raw JSON via `--json-data`


They can be combined. The merge rules are:

- `--json-data` provides the base request body
- explicit CLI flags override matching keys from `--json-data`


This is useful for endpoints with many fields or nested payloads where dedicated flags would be too heavy.

## Exit Codes

| Code | Meaning |
|  --- | --- |
| `0` | The HTTP request completed and a response was received. Check the JSON body for business success or failure. |
| `1` | Local CLI validation failed, or the command is not supported on the current platform. |
| `2` | Port resolution failed, JSON parsing failed, or the request could not be sent. |


## Port Resolution & Troubleshooting

The CLI needs to find the local `httpServer` port to send requests. It checks in this order:

1. `--port` flag — explicitly pass the port on every call
2. `ML_PORT` environment variable — set once per session
3. IPC auto-discovery — the CLI reads the port from a local IPC pipe (no configuration needed)


Default IPC paths:

| Platform | Path |
|  --- | --- |
| macOS / Linux | `/tmp/MoreLogin-cli` |
| Windows | `\\.\pipe\MoreLogin-cli` |


If you see the error **"Could not detect MoreLogin port"**, check:

- Is the MoreLogin desktop client running?
- If using `--port`, is the port number correct?
- On Linux / macOS, does `/tmp/MoreLogin-cli` exist?


## Documentation Map

- [Quick Start](/cli/quick-start)
- [Commands](/cli/commands)