# CLI

> Serve, sync, digest and token management from the terminal.

---

LLMS index: [llms.txt](/llms.txt)

---

The `pigeon` binary is both the server and a small mail client.

```bash
pigeon serve [--addr ADDR] [--data DIR]   # Web UI + REST API + MCP HTTP
pigeon mcp [--data DIR]                   # MCP server over stdio
pigeon digest [flags]                     # print a mail summary
pigeon backup [-o FILE]                   # back up the database and secret key
pigeon restore [-f FILE]                  # restore the database and secret key from a backup
pigeon token create|list|delete ...       # manage API tokens
pigeon version
pigeon help
```

Running `pigeon` without a subcommand is the same as `pigeon serve`.

## digest

Prints a mailbox summary from the local cache — no server required, it opens
the data directory directly.

| Flag | Default | Description |
| --- | --- | --- |
| `--account` | the only account | Account ID, email or name |
| `--mailbox` | `INBOX` | Mailbox path or display name |
| `--limit` | `10` | Number of messages to show |
| `--unread` | — | Only unread messages |
| `--sync` | — | Sync before printing; falls back to cached mail if sync fails |
| `--json` | — | Emit JSON instead of a table |
| `--data` | `~/.pigeon` | Data directory |

```bash
pigeon digest                          # recent inbox mail
pigeon digest --unread --limit 5       # five unread messages
pigeon digest --sync --json            # sync first, machine-readable output
pigeon digest --mailbox Sent           # look at sent mail
```

Sample output:

```
收件箱 · someone@qq.com · 3 未读 / 128 封

11-30 10:00  ●  Billing         Invoice for November
11-29 18:24     GitHub          [pigeon] New release published
11-28 09:12  ● ★ Ada Lovelace    Re: design review
```

`●` marks unread and `★` marks starred messages. With `--json` the output is:

```json
{
  "account": "someone@qq.com",
  "mailbox": "INBOX",
  "unread": 3,
  "total": 128,
  "messages": [
    {"id": 42, "subject": "Invoice for November", "date": 1764500000, "seen": false, "...": "..."}
  ]
}
```

## backup

`pigeon backup` writes a gzip-compressed tar archive containing a consistent
`pigeon.db` snapshot, the `secret.key` used to decrypt account passwords, and a
`manifest.json`. See [Backup & Restore](../backup/) for flags, restore steps
and security notes.

## restore

`pigeon restore -f FILE` verifies a backup archive and installs its database
and secret key into the data directory. See [Backup & Restore](../backup/)
for details and restrictions.

## token

```bash
pigeon token create --name agent   # create; the token is printed once to stdout
pigeon token list                  # id, name, created and last-used times
pigeon token delete <id>           # revoke
```

The same operations are available over the REST API; see
[Tokens & Auth](../tokens/).

## Environment variables

| Variable | Default | Description |
| --- | --- | --- |
| `PIGEON_ADDR` | `127.0.0.1:8787` | Listen address for `serve` |
| `PIGEON_DATA` | OS config dir + `/pigeon` | Data directory |
| `PIGEON_DEBUG` | — | Any non-empty value enables debug logging |

Flags take precedence over environment variables, which take precedence over
defaults.

`serve`, `mcp` and `digest --sync` also write their logs to
`<data-dir>/logs/pigeon-YYYY-MM-DD.log` — one file per local date, alongside
stderr output.

To run a second instance alongside the default one, override the address (and
optionally the data directory):

```bash
PIGEON_ADDR=127.0.0.1:8788 pigeon serve
PIGEON_ADDR=127.0.0.1:8788 PIGEON_DATA=/tmp/pigeon-dev pigeon serve
```

---

Backlinks:

- [Documentation](/docs/)
