# OpenClaw Integration

**OpenClaw** is a powerful AI Agent framework. By installing the MoreLogin skill into your OpenClaw workspace, your agent gains the ability to fully manage browser profiles and cloud phones autonomously.

## Prerequisites

- [Node.js](https://nodejs.org/) v18 or later
- [OpenClaw](https://github.com/openclaw-ai/openclaw) installed and initialized
- MoreLogin desktop app running on the same machine (Local API at `http://localhost:40000`)


## Installation & Setup

### 1. Install OpenClaw (if not already installed)

```bash
npm install -g openclaw
openclaw init    # Creates ~/.openclaw/workspace/
```

After initialization, the workspace structure looks like this:

```
~/.openclaw/
├── workspace/
│   ├── skills/          ← Skill plugins live here
│   │   └── morelogin/   ← MoreLogin skill (you will create this)
│   ├── TOOLS.md         ← Tool configuration file
│   └── ...
└── config.yaml          ← OpenClaw global config
```

### 2. Install the MoreLogin Skill

Clone the official skill repository into the OpenClaw skills directory:

```bash
# Clone the skill into the correct location
git clone https://github.com/MoreLoginBrowser/morelogin-local-api-skill.git \
  ~/.openclaw/workspace/skills/morelogin

# Install dependencies
cd ~/.openclaw/workspace/skills/morelogin
npm install
```

> **Where does the skill come from?**
The skill source code is hosted on GitHub at [MoreLoginBrowser/morelogin-local-api-skill](https://github.com/MoreLoginBrowser/morelogin-local-api-skill). This repository contains the CLI wrapper and API bindings that OpenClaw uses to interact with MoreLogin.


### 3. Configure OpenClaw Tools

Add the MoreLogin tool definition to your `~/.openclaw/workspace/TOOLS.md` file:

```markdown
### Morelogin

- Install Path: /Applications/Morelogin.app (macOS) or C:\Program Files\MoreLogin (Windows)
- Default CDP Port: 9222
- Local API: http://localhost:40000
```

### 4. Verify Installation

Run a quick test to confirm the skill is installed correctly:

```bash
openclaw morelogin browser list --page 1 --page-size 5
```

If the MoreLogin app is running, you should see a JSON response with your browser profiles (or an empty list).

## Updating the Skill

To update to the latest version:

```bash
cd ~/.openclaw/workspace/skills/morelogin
git pull origin main
npm install
```

Check for breaking changes in the [release notes](https://github.com/MoreLoginBrowser/morelogin-local-api-skill/releases) before upgrading.

## CLI Commands Reference

The MoreLogin skill exposes CLI commands directly to the OpenClaw environment. The agent invokes these automatically during reasoning, but you can also run them manually for testing.

### Browser Profiles

```bash
# List profiles
openclaw morelogin browser list --page 1 --page-size 20

# Start a profile (Returns debugPort for CDP connection)
openclaw morelogin browser start --env-id abc123def

# View running status
openclaw morelogin browser status --env-id abc123def

# Close profile
openclaw morelogin browser close --env-id abc123def
```

### Cloud Phones

```bash
# List cloud phones
openclaw morelogin cloudphone list --page 1 --page-size 20

# Start/Stop
openclaw morelogin cloudphone start --id <cloudPhoneId>
openclaw morelogin cloudphone stop --id <cloudPhoneId>

# Get details (Includes ADB connection info)
openclaw morelogin cloudphone info --id <cloudPhoneId>

# Execute cloud phone command via ADB
openclaw morelogin cloudphone exec --id <cloudPhoneId> --command "ls /sdcard"
```

### Proxy & Group Management

```bash
# Proxy
openclaw morelogin proxy list
openclaw morelogin proxy add --payload '{"proxyIp":"1.2.3.4","proxyPort":8000,"proxyType":0}'

# Group
openclaw morelogin group list
openclaw morelogin group create --name "US-Group"
```

## Minimal End-to-End Example

Below is a complete example that creates a browser profile, launches it, visits a URL via CDP, and closes the profile — all orchestrated by the OpenClaw agent.

### Natural Language Prompt

> *"Create a new MoreLogin browser profile, open google.com, take a screenshot, and close it."*


### What the Agent Executes

```bash
# 1. Create a browser profile
openclaw morelogin browser create --name "demo-profile"
# → Returns: {"envId": "abc123def"}

# 2. Start the profile
openclaw morelogin browser start --env-id abc123def
# → Returns: {"debugPort": "9222", "webdriver": "/path/to/chromedriver"}

# 3. Connect via CDP (agent uses Puppeteer internally)
# The agent connects to ws://127.0.0.1:9222 and runs:
#   - page.goto("https://www.google.com")
#   - page.screenshot({path: "screenshot.png"})

# 4. Close the profile
openclaw morelogin browser close --env-id abc123def
```

### Equivalent Script (Node.js)

```javascript
const { execSync } = require('child_process');
const puppeteer = require('puppeteer-core');

async function main() {
  // 1. Create profile
  const createResult = JSON.parse(
    execSync('openclaw morelogin browser create --name "demo-profile"').toString()
  );
  const envId = createResult.data.envId;

  // 2. Start profile
  const startResult = JSON.parse(
    execSync(`openclaw morelogin browser start --env-id ${envId}`).toString()
  );
  const debugPort = startResult.data.debugPort;

  // 3. Connect via CDP and automate
  const browser = await puppeteer.connect({
    browserURL: `http://127.0.0.1:${debugPort}`,
    defaultViewport: null
  });
  const page = (await browser.pages())[0];
  await page.goto('https://www.google.com');
  await page.screenshot({ path: 'screenshot.png' });
  console.log('Screenshot saved.');

  // 4. Cleanup
  await browser.disconnect();
  execSync(`openclaw morelogin browser close --env-id ${envId}`);
  console.log('Profile closed.');
}

main().catch(console.error);
```

## How the Agent Reasons

When you ask the OpenClaw agent to *"create a profile and log into example.com"*, the agent will:

1. Call `openclaw morelogin browser create` (or API equivalent) to get an `envId`.
2. Call `openclaw morelogin browser start` to get the `debugPort`.
3. Use a CDP tool (like Puppeteer/Playwright) to connect to the `debugPort` and perform the login steps.
4. Verify the success via `openclaw morelogin browser status`.


## Troubleshooting

| Symptom | Solution |
|  --- | --- |
| `command not found: openclaw` | Ensure OpenClaw is installed globally: `npm install -g openclaw` |
| `Error: connect ECONNREFUSED 127.0.0.1:40000` | Start the MoreLogin desktop app before running commands |
| Skill directory missing | Run `openclaw init` to create the workspace, then clone the skill |
| Stale data after update | Run `npm install` again in the skill directory after `git pull` |