Outlook Semantic MCP - Flows — Unique AI Documentation

Outlook Semantic MCP - Flows

This page documents the key flows in the Outlook Semantic MCP Server: how users connect, how emails are synced in real time and historically, how subscriptions stay alive, and how email drafts are created.

User OAuth Connection Flow

When a user opens their MCP client and connects to the Outlook Semantic MCP Server for the first time, the following flow executes:

After the user-authorized event is published, the server automatically creates a Microsoft Graph webhook subscription and starts a full email sync — no further user action is needed.

Key points:

Microsoft Token Refresh Flow

Microsoft access tokens expire after approximately one hour. The server refreshes them transparently:

Key points:

Subscription Creation and Renewal Lifecycle

Microsoft Graph webhook subscriptions for messages can last up to 7 days (Microsoft limit). The service creates subscriptions that renew daily at the configured UTC hour. The server manages the full lifecycle:

Subscription states:

Status Meaning Action
active Subscription valid, more than 15 minutes until expiry None required
expiring_soon Less than 15 minutes until expiry Renewal is automatic; no action needed
expired Subscription has lapsed Call reconnect_inbox
not_configured No subscription exists Call reconnect_inbox

Key points:

Live Catch-Up: Webhook-Driven Email Ingestion

When a new email arrives in the user's Outlook mailbox, Microsoft Graph sends a webhook notification. The server enqueues the notification in RabbitMQ and returns 202 Accepted immediately. The consumer then fetches and ingests new messages inline within the same execution.

Key points:

Full Sync: Historical Email Ingestion

After a subscription is created, the server automatically begins ingesting the user's historical emails. It fetches messages from Microsoft Graph in paginated batches (newest first), applies the configured mail filters, and uploads them to the Unique Knowledge Base. The sync is resumable across restarts.

Key points:

Directory Sync Flow

The server continuously syncs the user's Outlook folder structure from Microsoft Graph. This serves two purposes: enabling folder-based search filtering via the list_mailboxes_and_directories tool, and tracking email movement between folders to handle "deleted" emails without relying on delete notifications.

Key points:

Delegated Access Discovery Flow

When DELEGATED_ACCESS_SCAN is not disabled, two background jobs maintain delegated access state. The discovery job identifies which connected users have access to other connected users' mailboxes. The verification job (granular_access mode only) runs more frequently and confirms which specific folders within each delegated mailbox are still readable.

Neither job triggers email ingestion. They write permission records that search_emails reads at query time to include the owner's scope alongside the delegate's own scope.

Key points:

Email Draft Creation Flow

When the user calls the create_draft_email tool:

Key points:

Related Documentation