Context
Mint is a side project I built in March 2026, over 45 commits in about two weeks. It is one MCP URL that you add to Claude, ChatGPT or Claude Code. At sign-in you pick Google or Microsoft, and from then on the assistant can read your mail and calendar, rank what matters, and save draft replies. It runs as a container on Azure Container Apps.
The problem
The obvious way to connect an assistant to email is to expose CRUD tools: list inbox, read message, search. My first version did exactly that, with nine tools and six prompts. The model then had to read dozens of raw messages to answer “what do I need to deal with today?”, and it spent its context on newsletters and notifications.
I wanted the server to do the triage: a short ranked list, the reason for each item, and the calendar feeding the ranking. Two more constraints: one deployment had to serve both Google and Microsoft users, and nothing should ever be sent without a person reviewing it.
Design
Intelligence-gated tools. Commit 1e30caf replaced the CRUD tools with tools that return conclusions, not data. There are 13 now. Ten are read tools marked readOnlyHint, such as get_daily_brief, get_priority_emails and summarize_day. The three write tools are draft_email_reply, compose_email and create_reminder. Each tool fetches mail and calendar in parallel with asyncio.gather, returns a typed Pydantic model, and carries a worked example in its description so the model calls it correctly.
Priority scoring. score_email in mint/intelligence.py is a transparent heuristic, not a model. It adds weighted signals and records each one in a signals list that the assistant can see:
- a sender who is an attendee of a meeting today adds 0.50, and the score is floored at 0.80. Tomorrow adds 0.35 with a 0.65 floor.
- urgency keywords add 0.12 each, capped at 0.35. Payment, deadline and direct-question cues add up to 0.30.
- unread, recency (half weight once read), sender frequency, VIP senders and active threads add smaller boosts.
- automated senders (
noreply, bulk-mail subdomains and similar) are capped at 0.10, unless the text is transactional and has no marketing words. - callers can pass
scoring_overridesto boost or demote senders, domains and keywords.
The score is clamped to 0 to 1 and mapped to critical, high, medium or low. rank_emails then collapses each thread to its best message with participants and last reply, merges near-identical automated mails by sender plus normalised subject, and caps any one sender at three slots.
Cross-referencing. enrich_events attaches unread mail from attendees to each meeting, labels recurring events (“2 of 5 this window”), flags overlapping timed events as conflicts, and classifies locations as physical or virtual. Physical meetings get a Google Maps link and an Uber deep link. get_next_departure uses the Google Routes API, when a key is set, to return a leave-by time and a status from plenty_of_time to running_late.
Providers. EmailProvider and CalendarProvider are protocols with Gmail, Google Calendar and Microsoft Graph implementations, registered by name. Most tools take an optional mailbox argument that switches the base URL to users/{mailbox}, which is how shared and delegated mailboxes work. Mint does not grant that access itself: Google or Microsoft decides whether the signed-in user may open that mailbox.
Guardrails
- Drafts only. No tool sends mail.
draft_email_replyandcompose_emailsave drafts, andget_pending_draftslists them for review. - Draft scanning. Before saving, the body is checked for patterns that look like SSNs, card numbers, API keys, AWS keys and private keys. A match blocks the draft with a structured error.
- One OAuth proxy, two providers.
MintProvidersubclasses FastMCP’sOAuthProxyand replaces the consent page with a provider picker. The choice is embedded asupstream_claims.providerin the HS256 JWT that Mint issues. The client never sees the Google or Microsoft token. Mint keeps it in the proxy’s token store, keyed by the JWT’sjti. - Two-layer token check.
load_access_tokenverifies Mint’s own JWT, then the parent proxy validates the upstream token live: Google through tokeninfo, Microsoft against Entra JWKS with themcp-accessscope required. - Per-request isolation. Every tool call gets a fresh
httpxclient and fresh provider instances, built from that request’s token. There are no shared caches or connection pools between users. Refresh-token exchange swaps client credentials under anasyncio.Lock, with the provider held in aContextVar. - Audit log. Every call writes one JSON line with tool, user, parameters, status and duration. Keys containing
body,token,secretorpasswordare redacted.
Evals and results
There is no automated test suite. pytest and respx are dev dependencies, but the only test file, test_e2e.py, is a manual script that opens a browser for Google login. It still calls read_inbox and search_emails, tools I removed in 1e30caf, so it no longer runs against the current server. I tuned the scoring weights by hand against real inbox output. Commit 560ebf8 records why: without overrides, base scores only spread from 0.20 to 0.32.
What is not measured: ranking quality, latency and cost. I have no labelled set of emails, no precision figure for the top ten, and no load test. The tool count has also drifted: the README says 11, /health reports 10, and the code registers 13. A test that lists the registered tools would catch that. The Gmail provider also fetches message summaries one at a time, which I would batch next.
A failure I handled
Security and billing notices come from automated senders, so the newsletter ceiling pushed them down with the marketing mail. My first fix (376bc3c) set floors: 0.55 for a security alert, 0.45 for a billing alert, triggered by single keywords. It made things worse. Seven emails landed at exactly 0.55, so the ranking among them meant nothing. And a password manager’s upsell scored as a security alert, because it mentioned passwords.
The fix in e950319 changed both the trigger and the arithmetic. An alert now needs a topic word and an action word together, such as “secret” with “leaked”, or “payment” with “failed”. Any marketing word (“upgrade”, “premium”, “offer”) disables the alert path, so upsells stay at the ceiling. The boost is additive (+0.30 security, +0.20 billing) rather than a floor, so alerts keep their relative order.
A second, smaller failure: get_daily_brief and summarize_day timed out at 45 seconds after I added travel times, because each Maps call opened a new HTTP client and paid for a TLS handshake. I removed Maps calls from those tools (0fdda91) and left travel estimates to get_next_departure, which the descriptions tell the model to call in parallel.
Stack
Python 3.13, FastMCP 3 with Streamable HTTP transport, FastMCP OAuthProxy, Pydantic, httpx, Gmail API, Google Calendar API, Microsoft Graph, Google Routes API, Docker, Azure Container Apps.