Skip to main content
Glama
README.md
# lethe

> *Lethaei ad fluminis undam / securos latices et longa oblivia potant.*
> At the waters of the river Lethe they drink the draught that frees from care, and long forgetting.
> — Virgil, *Aeneid* VI.714–715

<!-- mcp-name: io.github.SuperAngryMonkey/lethe -->

**An MCP server that finds every mailing list in your mailbox and unsubscribes from the ones you choose. It reads headers only. It cannot send, move or delete mail.**

Point it at a Microsoft 365 or Gmail mailbox, ask your assistant to scan the last 90 days, pick what to keep, and lethe makes the unsubscribe requests: the standard one-click kind (RFC 8058) that senders publish in their own `List-Unsubscribe` header.

## What it can and cannot do

| | Microsoft 365 | Gmail |
|---|---|---|
| Scope requested | `Mail.Read` | `gmail.metadata` |
| Reads message bodies | No (it asks only for headers, but the scope would allow it) | **Cannot** — the scope does not expose bodies |
| Sends, moves, deletes, labels mail | **Cannot** | **Cannot** |
| Outbound network calls | Only the unsubscribe URLs of senders you name, with `confirm=true` | Same |

Senders that only accept an unsubscribe *email* are never contacted. lethe cannot send mail, so it hands you the address instead.

See [SECURITY.md](SECURITY.md) for what these guarantees rest on and where they stop.

## Tools

| Tool | What it does |
|---|---|
| `lethe_auth_status` | Provider, signed-in account, scope, kill-switch state |
| `lethe_login` / `lethe_login_finish` | Sign in (M365 device code; Gmail opens a browser on the host) |
| `lethe_scan(days=90)` | Read `From` + `List-Unsubscribe` headers, group by sender, save a scan |
| `lethe_senders(query, method, limit, offset)` | Page through a scan, biggest senders first |
| `lethe_unsubscribe(senders=[...], confirm)` | Without `confirm`, returns the plan. With it, sends one-click unsubscribes |
| `lethe_report` | Everything done for a scan, per sender |

Typical session: *"Scan my mail for the last 90 days, show me the 40 biggest senders, then unsubscribe from everything except my bank and the airline."*

On its first real mailbox (90 days, 13,042 messages), lethe found 592 senders with an unsubscribe header covering 10,894 of those messages. 98% of them supported one-click.

### How unsubscribing works

- **one-click** — the sender advertises `List-Unsubscribe-Post: List-Unsubscribe=One-Click`. lethe POSTs that body to the sender's https URL. It is the same mechanism mail providers use behind their own Unsubscribe buttons, and Gmail and Yahoo require it of bulk senders, so most lists support it.
- **link** — an https URL with no one-click support. Skipped unless you pass `allow_link_visits=true`; a visited link may still need a confirm click on the sender's page.
- **mailto** — reported back to you, never sent.

### Safety rails

- **Flagged senders are skipped by default** — freemail addresses with list headers, display names imitating postal/tax/government brands on unrelated domains, and headers with unrendered templates. Unsubscribing from phishing only confirms your address is live; block those instead.
- **SSRF guard** — https only; every host, including every redirect hop, must resolve to a public IP.
- **Newest header wins** — unsubscribe tokens can expire, so the scan keeps each sender's most recent header.
- **Audit log** — every scan and request is appended to `audit.log` in `LETHE_HOME`.
- **Kill switch** — create `LETHE_HOME/DISABLED` or set `LETHE_DISABLED=1`.

## Install

Install straight from GitHub with [uv](https://docs.astral.sh/uv/):

```
uvx --from git+https://github.com/SuperAngryMonkey/lethe@v0.1.0 lethe-mcp --version
```

(A PyPI package, `lethe-mcp`, and an MCP registry listing are coming. Until then, use the GitHub form in the configs below.)

### Microsoft 365

lethe has no shared app registration. Register your own (five minutes):

1. Entra admin center → App registrations → New registration. Single tenant. No redirect URI.
2. Authentication → Settings → **Allow public client flows: Yes**.
3. API permissions → Microsoft Graph → Delegated → **Mail.Read**. Nothing else.
4. Copy the Application (client) ID and Directory (tenant) ID.

```json
{
  "mcpServers": {
    "lethe": {
      "command": "uvx",
      "args": ["--from", "git+https://github.com/SuperAngryMonkey/lethe@v0.1.0", "lethe-mcp"],
      "env": {
        "LETHE_PROVIDER": "m365",
        "LETHE_M365_CLIENT_ID": "<client id>",
        "LETHE_M365_TENANT_ID": "<tenant id>"
      }
    }
  }
}
```

Then ask your assistant to run `lethe_login`, enter the code it shows, and run `lethe_login_finish`. Or run `lethe-mcp auth` in a terminal with the same environment.

### Gmail

1. Google Cloud console → new project → enable the **Gmail API**.
2. OAuth consent screen → External, Testing, add yourself as a test user. Add the scope `https://www.googleapis.com/auth/gmail.metadata`.
3. Credentials → Create OAuth client ID → **Desktop app**. Download the JSON.

```json
"lethe-gmail": {
  "command": "uvx",
  "args": ["--from", "git+https://github.com/SuperAngryMonkey/lethe@v0.1.0", "lethe-mcp"],
  "env": {
    "LETHE_PROVIDER": "gmail",
    "LETHE_GMAIL_CLIENT_SECRETS": "/path/to/client_secret.json",
    "LETHE_HOME": "~/.config/lethe-gmail"
  }
}
```

Sign in with `lethe-mcp auth` in a terminal (a browser opens), or ask for `lethe_login`. `gmail.metadata` is a restricted scope: in Testing mode Google lets you and your listed test users use your own client without verification, and the refresh token lasts seven days before you sign in again.

`gmail.metadata` does not allow Gmail's search syntax, so lethe pages through mail newest-first and stops at the cutoff date. A new Google Cloud project has a low per-minute quota; lethe backs off and retries when it hits it, so a large 90-day Gmail scan can take several minutes.

### Several mailboxes

Run one entry per mailbox, each with its own `LETHE_HOME`.

## Configuration

| Variable | Default | |
|---|---|---|
| `LETHE_PROVIDER` | — | `m365` or `gmail` (required) |
| `LETHE_HOME` | `~/.config/lethe` | token, saved scans, audit log, kill switch |
| `LETHE_M365_CLIENT_ID` | — | your Entra app |
| `LETHE_M365_TENANT_ID` | `organizations` | your tenant |
| `LETHE_GMAIL_CLIENT_SECRETS` | — | path to the desktop-client JSON |
| `LETHE_WORKERS` | `6` | parallel unsubscribe requests (1–16) |

## Limits

- Unsubscribing stops future mail; existing messages are untouched. Senders are allowed up to ten days to comply.
- Some senders reject automated requests (403/429) or publish broken headers. These are reported as failures; do them by hand.
- Microsoft 365 is `/me` only — no shared mailboxes.

## Documentation

- [SECURITY.md](SECURITY.md): what the read-only guarantee rests on, and where it stops
- [DESIGN.md](DESIGN.md): how a scan and an unsubscribe work, and why
- [OPERATIONS.md](OPERATIONS.md): sign-in, reading results, the audit log, the kill switch, removal
- [docs/decisions/](docs/decisions/): architecture decision records
- [CONTRIBUTING.md](CONTRIBUTING.md): send us the headers lethe gets wrong

## License

MIT © 2026 800 Pound Gorilla Inc.

TDQS

A3.6/5.0

Scored across 7 tools

Disambiguation5/5

Each tool maps to a distinct stage of the workflow: auth_status/login/login_finish handle authentication, scan creates a saved scan, senders pages it, unsubscribe acts on senders, and report reviews outcomes. The two-step login pair is clearly differentiated by the descriptions.

Naming Consistency4/5

All seven tools use the lethe_ prefix and lowercase snake_case, with no mixed casing conventions. The only minor deviation is that some names are verbs (scan, unsubscribe) while others are nouns (senders, report), but the pattern remains readable.

Tool Count5/5

Seven tools are well scoped for a focused email-unsubscribe workflow, and each tool has a clear role. There is no obvious redundancy or missing operational stage that would require more tools.

Completeness4/5

The core lifecycle is covered: authenticate, scan the mailbox, inspect senders, unsubscribe, and report results. Minor gaps include no logout or kill-switch toggle despite auth_status mentioning it, and no explicit scan listing/deletion management.

Maintenance

ActivityMaintained
ResponsivenessNo recent community issues