# AI Agent Usage

Set up an AI coding assistant to drive MoreLogin through `ml-cli`, then control browser profiles and cloud phones in plain language.

Works with Codex, Claude Code, Cursor, Gemini CLI, and any other assistant that can run shell commands.

> Looking for a different integration route? Use [MCP](/vi/mcp/overview) for MCP-capable clients, or
[Agent Skills](/vi/skills) for OpenClaw and Hermes. See the
[route comparison](/vi/ai-agent-integrations) if you are not sure which to pick.


## Step 1: Give your agent the setup prompt

Paste this into your assistant. It installs and verifies MoreLogin CLI without further hand-holding.

```text
This template's language is not my preference. Before your first substantive reply, detect and use my OS UI language (Windows: `Get-UICulture`, then `Get-Culture`); if unavailable, use my latest non-template message's language.

Follow the MoreLogin installation, verification, and `ml-cli` usage guide:
https://github.com/MoreLoginBrowser/morelogin-skills/blob/main/skills/morelogin-setup/install.md

Keep commands, paths, JSON/API fields, and original MoreLogin responses unchanged. Ask before permissions, login/security steps, downloads, installation, GUI launches, or state changes.
```

If the CLI is already installed, generate the same prompt from it:

```bash
ml-cli install-prompt
```

The last paragraph matters: it tells the agent to preserve MoreLogin responses verbatim and to stop and ask before anything that changes state. Keep it.

## Step 2: Point the agent at the built-in guide

```bash
ml-cli agent-guide
```

This is the agent's reference, not yours. It covers when to reach for `ml-cli`, how to discover command formats, how to map a natural-language request to a command, when to pause for confirmation, and how to recover from local sandbox failures such as `connect EPERM 127.0.0.1:40000`.

If your agent runs in a sandbox that blocks loopback connections, that `EPERM` error is the signal. Grant the agent local network access or run it outside the sandbox.

## Step 3: Verify connectivity

```bash
ml-cli doctor
ml-cli doctor --output-json
```

`doctor` discovers the local API port and calls the MoreLogin status endpoint. Use `--output-json` when you want the agent to parse the result instead of reading it.

Requires the MoreLogin desktop client to be running and signed in.

## Name-based lookup, and why it is safe

Users say "open P-1", not "open 1993244721490239488". The `find` and `open` commands accept names, and they refuse to guess:

```bash
ml-cli env find --name P-1
ml-cli env find --keyword Amazon
ml-cli env open --name P-1
ml-cli env open --name P-1 --exact
```

`--keyword` matches profile name, group name, tag name, and remark. `--name` matches the profile name; add `--exact` to require an exact match.

**`open` acts only when exactly one profile matches.** On multiple matches it prints the candidates and exits without starting anything. This is the behavior that makes it safe to hand to an agent: an ambiguous request never silently starts the wrong profile.

Cloud phones follow the same rule:

```bash
ml-cli cloudphone find --keyword "android-test"
ml-cli --timeout 120 cloudphone open --name CP-1
ml-cli --timeout 120 cloudphone open --name CP-1 --headless false
ml-cli --timeout 30 cloudphone close --name CP-1
```

Cloud phone operations are slow, so pass `--timeout`. For `--headless`, `false` shows the window and `true` hides it; the API default is `true`.

## What you can ask

### Browser profiles

| Ask | What the agent does |
|  --- | --- |
| How many browser profiles are on the first page? | Lists page 1 and counts |
| Show profile name, ID, and status for the first page | Lists page 1 with fields |
| Open the P-1 profile | Resolves the name, then starts it |
| Is P-1 already running? | Checks run status before acting |
| Close the P-1 profile | Stops it |
| Start the first profile and tell me the debug port | Starts it and returns the CDP debug port |


### Search by name, group, tag, or remark

| Ask | What the agent does |
|  --- | --- |
| Find profiles whose names contain Amazon | `env find --name` |
| Find profiles where name, group, tag, or remark contains Amazon | `env find --keyword` |
| Open the profile whose group or tag contains Amazon; show candidates if more than one | `env open --keyword`, stops on ambiguity |


### Cloud phones

| Ask | What the agent does |
|  --- | --- |
| Show me the cloud phone list | Lists cloud phones |
| Open the CP-1 cloud phone | Resolves the name, then powers on |
| Find cloud phones whose group, tag, or remark contains Android | `cloudphone find --keyword` |
| Open the cloud phone matching CP-204 and display the window | Opens with `--headless false` |
| Close the CP-1 cloud phone | Powers off |


### Shared resources

| Ask | What the agent does |
|  --- | --- |
| Show me all groups | Lists groups |
| Show me all tags | Lists tags |
| Show me the first page of proxy records | Lists proxies |


### Discovery

| Ask | What the agent does |
|  --- | --- |
| Read `ml-cli` help and summarize the common profile commands | Reads help output and summarizes |


Asking the agent to read its own help is the reliable way to handle a command this page does not cover.

## Next steps

| Topic | Where |
|  --- | --- |
| Full command and flag reference | [CLI Commands](/vi/cli/commands) |
| Installing and configuring the CLI | [CLI Quick Start](/vi/cli/quick-start) |
| CLI-side view of this guide | [CLI AI Agent Usage](/vi/cli/agent) |
| Underlying HTTP endpoints | [Browser Local API](/vi/api-reference/browser/local-api) |