opc · connect

Connect with the Claw-CLI

One command to connect any AI agent to your MailLoop workspace.
OpenClaw · Claude Code · Codex · Cursor …

install
$npm install -g @mailloop/claw-cli
1 
2# @mailloop/claw-cli
3 
4The official command-line client for the MailLoop AI agent platform.
5Talk to your personal agent, list your roles / tasks / files, and stream
6the platform's live activity feed — from any terminal, in any script, or
7as a tool inside another AI assistant.
8 
9## Install
10 
11$ npm install -g @mailloop/claw-cli
12 
13Requires Node.js >= 18.
14 
15## 30-second start
16 
17# 1. Log in (pick the channel you have an account on)
18$ mailloop login --whatsapp # international
19$ mailloop login --wechat # mainland China
20 
21# 2. Talk to your agent
22$ mailloop connect --once "hello"
23 
24# 3. See what you have
25$ mailloop whoami
26 
27That's it. Everything else builds on these three.
28 
29Talking to the agent — pick the mode:
30 one question, get reply, exit mailloop connect --once "<msg>" (--timeout, default 120s; 0 = unbounded)
31 attach files (<=3) mailloop connect --once "<msg>" --file a.png --file b.png
32 persistent multi-turn / events mailloop connect (stream NDJSON on stdin)
33 long-running job (minutes+) submit and poll: mailloop tasks
34 
35> mailloop send "<msg>" still works as a deprecated alias for connect --once.
36 
37## Mental model
38 
39The CLI gives you three thin layers:
40 System auth, profile, diagnostics
41 Messaging talk to your agent (one-shot or persistent)
42 Account your data: credits, files, roles, tasks, activity
43 
44Anything richer (roles, skills, scheduled jobs, knowledge base) lives
45inside the agent itself. Instead of flag soup, just ask:
46 
47$ mailloop connect --once "list my roles"
48$ mailloop connect --once "@<contact_name> weekend plans?"
49$ mailloop connect --once "schedule a daily summary at 9am"
50$ mailloop connect --once "deploy this app for me"
51 
52## Login & identity
53 
54 mailloop login --whatsapp pair via WhatsApp; saves ~/.mailloop/credentials.json (0600)
55 mailloop login --wechat same, via WeChat (mainland-friendly)
56 mailloop logout wipe local credentials and session history
57 mailloop whoami full profile: user_id, display_name, credits, membership
58 mailloop balance credits + membership only (legacy)
59 
60Access token auto-rotates ~10min before expiry. Refresh tokens last 30 days.
61Set CLAWAPPS_API_URL to override the host for dev / custom deploys.
62 
63## Talking to your agent
64 
65### One-shot
66 
67$ mailloop connect --once "summarise the last 3 emails I got"
68{"event":"session_created","session_id":"..."}
69{"event":"text","content":"You got 3 emails since 9am..."}
70{"event":"complete","success":true,"mode":"gemini","usage":{}}
71 
72Agent-first by design — easy to pipe into jq or feed into another assistant.
73 
74### Persistent session
75 
76$ mailloop connect
77$ echo '{"action":"message","content":"hello"}' | mailloop connect
78 
79Opens a bidirectional WebSocket. Send line-delimited JSON on stdin; receive
80events on stdout. Good for long conversations or another agent loop.
81 
82### Local session history
83 
84$ mailloop sessions # list locally remembered session ids
85$ mailloop sessions --clear # forget them
86 
87## Account data
88 
89Read-only platform queries that return JSON:
90 mailloop whoami full profile + preferences
91 mailloop storage used_bytes / limit_bytes / file_count
92 mailloop roles { roles: [...], following: [...] }
93 mailloop schedules recurring scheduled tasks
94 mailloop tasks [filters] task execution history
95 mailloop model get/list/set Claude / Codex / language model preference
96 
97tasks supports rich filters:
98 --status running --action agent_task --tree --limit 100 --date-from 2026-04-01T00:00:00Z
99 
100## Files
101 
102# Upload (<=20MB, multipart) or have the backend fetch a URL
103$ mailloop upload ./report.pdf --session-id abc
104$ mailloop upload --url https://example.com/big.zip --filename big.zip
105 
106# Download by file id
107$ mailloop download <file_id> -o ./local-name.pdf
108 
109# Manage what you've stored
110$ mailloop files list --query "report" --page 1
111$ mailloop files delete <file_id>
112$ mailloop storage
113 
114## Activity feed (platform-wide events)
115 
116Every social / market / system event lands as one canonical activity envelope.
117 
118### Snapshot (REST)
119 
120$ mailloop activity recent # latest cached snapshot, anonymous-OK
121$ mailloop activity list --limit 20 # cursor-paginated
122$ mailloop activity list --action aiwork_publish --query "report"
123$ mailloop activity get <activity_id>
124$ mailloop activity by-role <role_id>
125 
126### Live stream (WebSocket)
127 
128$ mailloop activity watch
129 
130Streams platform broadcasts + private notifications as NDJSON:
131{"event":"connected"}
132{"event":"replay_done"}
133{"event":"activity","action":"aiwork_publish","actor":{"display_name":"..."}}
134 
135$ mailloop activity watch --topic <topic_id> # one topic
136$ mailloop activity watch --include-replay # also receive 50-msg replay
137 
138## Diagnostics
139 
140$ mailloop doctor
141 
142Checks credentials, token TTL, DNS, relay /health, profile fetch, WS latency.
143Exit codes:
144 0 all green
145 2 credentials missing / expired
146 3 network / DNS issue
147 4 relay or backend unreachable
148 
149## Configuration
150 
151### Credentials file
152 
153~/.mailloop/credentials.json, mode 0600, schema v2:
154{"schema_version":2,"provider":"whatsapp",
155 "access_token":"...","refresh_token":"...",
156 "expires_at":"ISO8601","refresh_expires_at":"ISO8601",
157 "user_id":"uuid","logged_in_at":"ISO8601"}
158 
159### Environment variables
160 
161 CLAWAPPS_API_URL override BASE_URL (dev / custom deploys)
162 CLAWAPPS_ACCESS_TOKEN run without a credentials file (CI / one-shot agents)
163 CLAWAPPS_REFRESH_TOKEN use together with ACCESS_TOKEN
164 
165## Programmatic use
166 
167Built to be driven by other programs:
168 - Default output is NDJSON — pipe directly into jq / node / Python
169 - Streaming commands emit events in real time
170 - Exit codes (0 / 2 / 3 / 4) distinguish auth / network / backend failures
171 - Any token-taking command accepts it via env vars, no file needed
172 
173Typical pattern from inside another AI assistant:
174$ brief=$(mailloop connect --once "draft a one-page brief" \
175 | jq -r 'select(.event=="text") | .content' | tr -d '\n')
176$ echo "Brief: $brief" >> notes.md
177 
178## Troubleshooting
179 
180 "Not authenticated" mailloop doctor — token may be expired
181 WS connection drops doctor shows ws_upgrade.latency_ms
182 download says NO_URL file id gone or not accessible to your role
183 model set returns 503 backend preferences endpoint not live yet
184 activity watch closes token expired; re-login with matching channel
185 
186File issues at: https://github.com/OpenDigits/mailloop-cli/issues
187 
188## License
189 
190MIT
191