本页面介绍如何在 Codex、Claude Code、Cursor、Gemini CLI 等 AI 编程助手中使用 ml-cli。
将以下提示词复制并粘贴到您的 AI 助手中,即可自动安装配置 MoreLogin CLI:
Set up MoreLogin CLI for me, then use it whenever I ask you to operate MoreLogin.
Official docs:
https://guide.morelogin.com/cli
Goal:
- Install or update `ml-cli`.
- Verify MoreLogin Desktop local API access.
- Read the built-in agent package and guide.
- After setup, ask what MoreLogin task I want to automate first.
First detect my OS and CPU architecture, then run the matching install command.
Windows x64 PowerShell:
```powershell
$dir = "$env:USERPROFILE\.morelogin\bin"
New-Item -ItemType Directory -Force -Path $dir | Out-Null
Invoke-WebRequest -Uri "https://releases.morelogin.com/prod/MoreLogin_AirDrop_window_x64_cli/2.6.3/MoreLogin_AirDrop_window_x64_cli_2.6.3.0.exe" -OutFile "$dir\ml-cli.exe"
$userPath = [Environment]::GetEnvironmentVariable("Path", "User")
if ($userPath -notlike "*$dir*") { [Environment]::SetEnvironmentVariable("Path", "$userPath;$dir", "User") }
& "$dir\ml-cli.exe" --version
```
macOS Intel x64:
```bash
mkdir -p "$HOME/.local/bin"
curl -L "https://releases.morelogin.com/prod/MoreLogin_AirDrop_darwin_x64_cli/2.6.3/MoreLogin_AirDrop_darwin_x64_cli_2.6.3.0" -o "$HOME/.local/bin/ml-cli"
chmod +x "$HOME/.local/bin/ml-cli"
export PATH="$HOME/.local/bin:$PATH"
ml-cli --version
```
macOS Apple Silicon arm64:
```bash
mkdir -p "$HOME/.local/bin"
curl -L "https://releases.morelogin.com/prod/MoreLogin_AirDrop_darwin_arm64_cli/2.6.3/MoreLogin_AirDrop_darwin_arm64_cli_2.6.3.0" -o "$HOME/.local/bin/ml-cli"
chmod +x "$HOME/.local/bin/ml-cli"
export PATH="$HOME/.local/bin:$PATH"
ml-cli --version
```
Linux x64:
```bash
mkdir -p "$HOME/.local/bin"
curl -L "https://releases.morelogin.com/prod/MoreLogin_AirDrop_linux_x64_cli/2.6.3/MoreLogin_AirDrop_linux_x64_cli_2.6.3.0" -o "$HOME/.local/bin/ml-cli"
chmod +x "$HOME/.local/bin/ml-cli"
export PATH="$HOME/.local/bin:$PATH"
ml-cli --version
```
After installation, run:
```bash
ml-cli --help
ml-cli doctor --output-json
ml-cli agent-bootstrap
ml-cli agent-package
ml-cli agent-guide
```
For long-term use, install persistent rules for my AI agent:
```bash
ml-cli agent-list
ml-cli agent-init --agent <agent> --scope user --dry-run
ml-cli agent-init --agent <agent> --scope user --write
```
Use the correct `<agent>` value for my AI client. Supported values are listed by `ml-cli agent-list`, including `codex`, `claude-code`, `cursor`, `gemini`, `qwen-code`, `opencode`, `openclaw`, `trae`, `hermes`, `qclaw`, `easyclaw`, and `workbuddy`.
Use `ml-cli` for MoreLogin browser profiles, environment lists, cloud phones, proxies, groups, tags, schedules, and local API status.
Do not guess IDs, payload fields, or command formats. If unsure, inspect help first:
```bash
ml-cli env --help
ml-cli cloudphone --help
ml-cli proxy --help
ml-cli schedule --help
```
Operation timing:
- `env start` / `env open` takes 3-5 seconds; use `--timeout 30`.
- `cloudphone power-on` / `cloudphone open` takes 30-90 seconds; always use `--timeout 120`.
- All other commands complete within the default `--timeout 15`.
Natural language routing rules:
- "How many browser profiles are on the first page?" -> run `ml-cli env list --page-no 1 --page-size 20`, then count `data.dataList`.
- "Open P-1" -> run `ml-cli --timeout 30 env open --name P-1`.
- "Find browser profiles by group, tag, name, or remark containing Amazon" -> run `ml-cli env find --keyword Amazon`.
- "Open the profile whose group, tag, name, or remark contains Amazon" -> run `ml-cli --timeout 30 env open --keyword Amazon`.
- "Open cloud phone CP-204 and show the window" -> run `ml-cli --timeout 120 cloudphone open --keyword CP-204 --headless false`.
- "Close cloud phone CP-204" -> run `ml-cli --timeout 30 cloudphone close --keyword CP-204`.
- "Create a new browser profile" -> run `ml-cli env create-quick`.
- "Delete browser profile P-1" -> find it first with `ml-cli env find --name P-1`, confirm with the user, then run `ml-cli env delete --env-ids <id>`.
- "Create a proxy" -> run `ml-cli proxy create --proxy-ip <ip> --proxy-port <port> --proxy-provider 0`.
- "Show all tags" -> run `ml-cli tag list`.
- "Create a group called test" -> run `ml-cli group create --group-name test`.
- "Set proxy for profile P-1" -> find the profile first, then run `ml-cli env set-proxy --env-ids <id> --proxy-ip <ip> --proxy-port <port> --proxy-type 0 --proxy-provider 0`.
Candidate selection rule:
- `env open`, `cloudphone open`, and `cloudphone close` may operate only when exactly one candidate matches.
- If zero or multiple candidates match, show the candidates and ask me which one to operate.
Local access rule:
MoreLogin CLI connects to `127.0.0.1:<port>`, usually `127.0.0.1:40000`. Started browser profiles may expose `127.0.0.1:<debugPort>`.
If Codex, Claude Code, Cursor, or another AI client reports `connect EPERM 127.0.0.1:40000`, `connect EPERM 127.0.0.1:<debugPort>`, `connection refused`, `request timeout`, or `Could not detect MoreLogin port`, treat it as local sandbox/permission first. Request local access approval or elevated execution and rerun the same command. Do not repeatedly start the same profile after an EPERM error; check status first.
When a command fails, show the original MoreLogin response. Do not redact proxy passwords, phone numbers, device identifiers, or other fields unless I explicitly ask you to. For scripts, add `--fail-on-business-error` when a non-zero top-level JSON `code` should fail the command.
Future updates:
- To update `ml-cli`, run `ml-cli self-update`. Or rerun this setup prompt and overwrite the existing binary with the newest official download.
- To update persistent agent rules, rerun `ml-cli agent-init --agent <agent> --scope <scope> --write`.
- Restart the AI agent if it only loads memory/rules files on startup.
After verification, tell me:
- install path
- `ml-cli --version`
- `ml-cli doctor --output-json` result
- available top-level commands
Then ask me what MoreLogin task I want to automate first.您也可以通过已安装的 CLI 生成相同的提示词:
ml-cli install-prompt安装后,AI Agent 应读取内置指南:
ml-cli agent-guide该指南会告诉 Agent:
- 何时使用
ml-cli - 如何发现命令格式
- 如何将自然语言映射到命令
- 何时需要确认
- 如何处理本地沙箱错误,例如
connect EPERM 127.0.0.1:40000
使用 doctor 验证本地 API 连通性:
ml-cli doctor
ml-cli doctor --output-jsondoctor 会检查端口发现,并调用 MoreLogin 本地状态接口。
当用户通过名称引用浏览器环境时,使用以下命令:
ml-cli env find --name P-1
ml-cli env find --keyword Amazon
ml-cli env open --name P-1
ml-cli env open --keyword "team-a"
ml-cli env open --name P-1 --exactenv find --keyword 通过 MoreLogin 本地 API 搜索环境名称、分组名、标签名和备注。 env open 仅在恰好匹配一个候选项时才启动环境。如果匹配到多个,将打印候选列表并退出,不启动任何环境。
当用户通过名称引用云手机时,使用以下命令:
ml-cli cloudphone find --name CP-1
ml-cli cloudphone find --keyword "android-test"
ml-cli --timeout 120 cloudphone open --name CP-1
ml-cli --timeout 120 cloudphone open --keyword "android-test"
ml-cli --timeout 120 cloudphone open --name CP-1 --headless false
ml-cli --timeout 30 cloudphone close --name CP-1
ml-cli --timeout 30 cloudphone close --keyword "android-test"
ml-cli --timeout 120 cloudphone open --name CP-1 --exactcloudphone find --keyword 通过 MoreLogin 本地 API 搜索云手机名称、分组名、标签名和备注。 cloudphone open 和 cloudphone close 仅在恰好匹配一个候选项时才操作。如果匹配到多个,将打印候选列表并退出,不改变任何状态。 对于 --headless,false 显示云手机窗口,true 不显示。API 默认值为 true。
设置完成后,您可以这样说:
MoreLogin 第一页有多少个浏览器环境?显示 MoreLogin 浏览器环境第一页,包含环境名称、ID 和状态。打开 P-1 环境。检查 P-1 环境是否正在运行。关闭 P-1 环境。查找名称包含 Amazon 的浏览器环境。查找环境名称、分组名、标签名或备注包含 Amazon 的浏览器环境。打开分组或标签包含 Amazon 的浏览器环境。如果有多个,先显示候选列表。启动第一个浏览器环境,并告诉我调试端口。显示所有 MoreLogin 分组。显示所有 MoreLogin 标签。显示代理记录第一页。显示云手机列表。打开 CP-1 云手机。查找分组、标签或备注包含 Android 的云手机。打开名称、分组、标签或备注包含 CP-204 的云手机,并显示窗口。关闭 CP-1 云手机。阅读 ml-cli 帮助,总结常用浏览器环境命令。