Real-Time SSE & Streamable HTTP MCP
Event payloads on /api/v1/events and the 12 tools exposed by the built-in bryfo-mail MCP server.
Real-Time Events (GET /api/v1/events)
Authenticated browsers connect to /api/v1/events (text/event-stream) with a 25-second heartbeat and 50-event per-user ring-buffer replay (Last-Event-ID):
| Event Name | Payload Highlights | Description |
|---|---|---|
thread.updated | thread_ids, action | New mail ingested, draft sent, archived, snoozed, or follow-up triggered |
account.sync_status | account_id, sync_status, last_error | Live IMAP IDLE / incremental sync transition |
ai.classify_progress | processed, total | Background inbox categorization progress |
ai.digest_ready | digest_id, period | Morning, evening, or manual AI Brief completed |
mcp.approval_requested | action_id, tool, summary | confirm_write MCP tool awaiting human approval |
session.revoked | reason | Immediate live disconnect upon logout or admin containment |
Streamable HTTP MCP (/mcp, bryfo-mail v0.2.0)
Authenticate with Authorization: Bearer <token> minted at POST /api/v1/mcp/tokens. Every email subject, sender name, and body is wrapped inside `<untrusted_email_content>` tags, and outbound PII redaction runs whenever apply_privacy_filter = true.
| Tool Name | Minimum Scope | Purpose |
|---|---|---|
list_accounts | read_only | List connected mailboxes permitted for this token |
list_threads | read_only | Paginate threads by folder, account, label, or unread state |
search_emails | read_only | Run hybrid lexical + vector RRF (k=60) search with operators |
get_thread | read_only | Read full messages and attachment metadata in a thread |
create_draft | draft_only | Create an unsent draft message |
apply_label | confirm_write / full | Attach or remove thread labels |
mark_read | confirm_write / full | Mark threads read or unread |
archive_thread | confirm_write / full | Archive threads and propagate MOVE to IMAP |
snooze_thread | confirm_write / full | Snooze threads until an ISO-8601 timestamp |
trash_thread | confirm_write / full | Move threads to Trash |
send_email | confirm_write / full | Transmit outbound email over SMTP |
delete_thread | confirm_write / full | Permanently expunge threads |
HTTP Conventions, CSRF, Step-Up & Error Codes
Authentication cookies, X-Bryfo-Step-Up elevation, CSRF checks, Redis rate limits, and structured JSON errors.
Managed Mail Server Contract (Rev 2)
Wire contract, durable 202 operations, localpart validation, and error codes for Stalwart v1.2.1 domain mailboxes.