> ## Documentation Index
> Fetch the complete documentation index at: https://docs.langmail.me/llms.txt
> Use this file to discover all available pages before exploring further.

# Architecture

> How Langmail is put together — the open-protocol data layer, the MCP action layer, and one identity for humans and agents.

Langmail separates *where your data lives* from *how agents act on it*. Both layers are open: standard protocols at the bottom, MCP on top.

```text theme={null}
              your agent (Claude, Cursor, ...)          you (browser, mail client)
                          │                                       │
                          │ MCP over Streamable HTTP              │ webmail · IMAP/SMTP
                          ▼                                       ▼
              ┌───────────────────────┐               ┌───────────────────────┐
              │  MCP server           │               │  Webmail & mail apps  │
              │  mcp.langmail.me      │               │  webmail.langmail.me  │
              └───────────┬───────────┘               └───────────┬───────────┘
                          │ JMAP + CalDAV                         │ JMAP · IMAP
                          ▼                                       ▼
              ┌───────────────────────────────────────────────────────────────┐
              │  Mail server (data layer) — mail.langmail.me                  │
              │  your mailbox and calendars · JMAP · CalDAV · IMAP · SMTP     │
              └───────────────────────────────────────────────────────────────┘
```

## The data layer

Your mailbox and calendars live on Langmail's own mail server ([Stalwart](https://stalw.art)) at `mail.langmail.me` — not in a hyperscaler's cloud. The server speaks:

* **JMAP** for mail — the modern, JSON-based successor to IMAP
* **CalDAV** for calendars and scheduling
* **IMAP and SMTP** for compatibility with every existing mail client

Because the data layer is standard protocols end to end, nothing about your mail is locked in a proprietary format. Any JMAP or IMAP client can export everything. Endpoints and ports are listed in [Open protocols](/reference/protocols).

## The action layer

The MCP server at `mcp.langmail.me` is a thin, stateless translation layer: it authenticates the agent, then executes tools against the data layer over JMAP (email tools) and CalDAV (calendar tools) on the caller's behalf. It holds no copy of your mail.

Its design goals, visible in the tool surface:

* **Token-frugal.** Search and thread results are compact plain text without message bodies; the agent fetches a body only when it needs one.
* **Structured over scraping.** Category, sender, date-range, and mailbox filters answer most questions in one call.
* **Deliberately scoped.** Email tools are read-only; calendar tools are read-write. Expanding the mutation surface is a deliberate decision, not a default.

## One identity for humans and agents

A single identity service (`auth.langmail.me`) signs you into the app, webmail, and every agent grant:

| Consumer               | How it authenticates                                                                           |
| ---------------------- | ---------------------------------------------------------------------------------------------- |
| Web app and webmail    | Google sign-in, shared browser session                                                         |
| MCP clients (agents)   | OAuth 2.1 grant you approve per client — see [How authorization works](/connect/authorization) |
| IMAP/SMTP mail clients | Per-device [app passwords](/guides/mail-clients)                                               |

Every path resolves to the same principal: your `you@langmail.me` mailbox. An agent's token is scoped to the user who granted it — it can never reach another mailbox.

## Humans and agents, same mailbox

There is no "agent copy" of your data. When [classification](/concepts/email-intelligence) flags a message as a to-do or tags it `receipt`, the result is a standard mailbox keyword — you see it as a label in webmail, and a connected agent can filter by it a second later. The mailbox is the single source of truth, and every surface — human or agent — reads the same one.
