# Panda for AI agents

Panda is an Android app. With the owner's permission, it does tasks on their phone through
Android accessibility: it opens apps, reads the screen, taps, types and scrolls. Any AI agent with a
shell (Grok Bot, Claude Code, Codex, Cursor and others) can send Panda a task in plain words and get the
result back.

This page tells an agent exactly how to do that.

## 1. Get a key from the owner

The phone owner makes the key. You can't make one yourself.

> On the phone: **Panda → Agents → ⋮ → Link Devices (Control from computer) → Connect an AI agent →
> name it → Always ask or Always allow → Create API key**. Then **Copy API key** and save it in the agent's
> secrets / API key field as `PANDA_API_KEY`. **Copy instructions** gives a short message for the
> agent's chat that points here. It doesn't contain the key.

A key looks like `panda_sk_live_…` (or `panda_sk_dev_…` for the Panda test build). It should reach you
as the `PANDA_API_KEY` environment variable or secret, not in the chat. If it isn't set, ask the owner to
add it to your secrets, not to paste it into the conversation. Treat it as a secret: never print it,
echo it, commit it, or send it anywhere except the commands below.

- **Always ask**: the owner gets a notification and approves each task. Wait for it.
- **Always allow**: the task starts right away.
- Payments always stop and ask the owner, in both modes.

Never ask the owner for passwords, OTPs or card numbers. Panda works with the apps they're already
signed in to.

## 2. Install and connect

Needs Node.js 20 or newer.

```bash
test -n "$PANDA_API_KEY" || echo "Ask the owner to add PANDA_API_KEY to my secrets"
npx -y @steepwind/panda-mcp status           # shows the paired phone
```

To save the key on this computer instead of using the environment
(`~/.config/panda-mcp/identity.json`, mode 0600):

```bash
printenv PANDA_API_KEY | npx -y @steepwind/panda-mcp login -
```

## 3. Send a task

```bash
npx -y @steepwind/panda-mcp run "Open WhatsApp and tell me the last message from Mom" --timeout 600
```

`run` prints progress lines and then the result. It exits 0 when the task succeeded and 1 otherwise.
`--timeout` is how long to wait, in seconds (default 300, maximum 900).

### As an MCP server (tools instead of the shell)

The server runs on stdio: `npx -y @steepwind/panda-mcp serve`, with `PANDA_API_KEY` in its environment.

Claude Code:

```bash
claude mcp add panda -e PANDA_API_KEY="$PANDA_API_KEY" -- npx -y @steepwind/panda-mcp serve
```

Codex (`~/.codex/config.toml`) and other TOML-config agents:

```toml
[mcp_servers.panda]
command = "npx"
args = ["-y", "@steepwind/panda-mcp", "serve"]
env = { PANDA_API_KEY = "panda_sk_live_..." }
tool_timeout_sec = 900
```

Generic JSON (`mcpServers`):

```json
{ "mcpServers": { "panda": { "command": "npx", "args": ["-y", "@steepwind/panda-mcp", "serve"],
  "env": { "PANDA_API_KEY": "panda_sk_live_..." } } } }
```

Tools:

| Tool | Use |
|---|---|
| `list_devices` | Phones this key can reach. Pass `device_id` only when there is more than one. |
| `run_task` | Send a task and wait for the result (`timeout_sec` up to 900). |
| `start_task` | Send a task and return a `taskId` right away. |
| `wait_task` / `get_task` | Wait for, or check, a started task. |
| `cancel_task` | Stop a task that hasn't finished. |

Set your MCP tool timeout to 900 seconds if your agent has one. Phone tasks often take 1–5 minutes,
and many agents give up after 60 seconds by default. If you can't change the timeout, use `start_task`
and then poll `wait_task`.

## 4. What the statuses mean

| Status | What to do |
|---|---|
| `succeeded` | Use the result text. |
| `failed` | Panda tried and couldn't finish. Read the reason. Retry once only if the reason looks temporary. |
| `rejected` | The owner said no, or the phone is busy or has control turned off. **Don't retry.** Tell the owner. |
| `expired` | Nobody answered in time. **Don't retry.** Tell the owner. |
| `cancelled` | It was stopped. |

Common errors:

- "key was removed on the phone": the owner removed this agent. Ask them for a new key.
- "phone is already running a task": wait for it to finish, then send the next one.
- "Too many tasks": the limit is 30 tasks per hour per key.

## 5. Writing good tasks

One job per task, in plain words, with everything Panda needs. Panda can't see your conversation.
Tasks can be up to 2000 characters.

- Good: "Open Swiggy and tell me the delivery time and total for my last order. Don't place a new order."
- Good: "In Settings, turn on Do Not Disturb until 7 am."
- Good: "Open Gmail, find the latest email from IRCTC and read me the PNR and train time."
- Bad: "Do the thing we discussed." (Panda can't see that.)
- Bad: "Book a cab and also message Rahul and also check my bank balance." (Send three tasks.)

Say what not to do when it matters ("don't send", "don't pay"). To send a message or make a
payment, say so clearly. Panda asks the owner before paying.

## Safety

The key is an Ed25519 signing key made on the owner's phone. Every task is signed with it, and the
phone checks the signature itself, so Panda's servers can't fake a task. The owner can remove an
agent at any time from the same screen.

Questions: support@heypanda.org
