For people who use Gmail for personal correspondence and want an agent to prepare replies.
Blueprint: Email + Claude
Version 1.1 · November 19, 2026. Use this specification to build a personal Gmail workflow. Important messages trigger a Telegram alert, and prepared replies wait for review in a panel. The examples are fictional.
I want to know when an important email arrives, even when I’m not looking at my inbox. And when I ask Claude to prepare a reply, I want to read it, check the translation, open the attachments, edit the text and click Send myself.
I use two connected workflows. Mail Watcher applies my rules to incoming mail and sends me a Telegram alert when something matters. When I ask for a reply, the agent prepares a draft and queues a proposal for review. I open it in Mission Control, read the whole email and decide whether to send it or edit it.
For a text alert, the wrapper needs a bot token and your chat ID to call sendMessage. If you want buttons below the alert, you also need a process that stays online to handle button presses. See the Telegram + Claude blueprint.
What you get
- Notifications about important email based on rules in plain language. You choose the schedule and quiet hours.
- Email tools let the agent search for messages, read available excerpts, retrieve attachments and queue drafts for review.
- A review page: sender, To/Cc/Bcc, subject, outgoing text, a translation for you, files and status.
- An editor for text and attachments: changes are saved before sending, and you can restore the agent’s original text.
- Freshness checks flag an old draft, a meeting date or deadline in the text that has already passed, and a translation that is out of date.
- After a restart you can recover the queue, the agent’s original text, the time of the last edit and any unfinished operations.
Our version uses one Gmail account with verified sender addresses. The outgoing text can be in the language you need, with a Russian translation alongside it. Switching the interface between Russian and English does not mean the system automatically translates into any language. A different review language is an adaptation to make when you build.
How to set it up
- Open a coding agent in a separate code directory. Use your notes base for rules and documentation.
- Give it this file: “Build me a system following Blueprint Email + Claude. Start with the adaptation questions. Implement it in phases and verify each phase with synthetic emails.”
- Choose one email account, a review language and a way to access the panel.
- Complete Google authorization yourself. Use the system keychain or a secret manager for the token. If it must live in a file, keep it outside Git and allow only the owner to read and write it (
0600on Unix). - Start with reading and a trial classification run. Add the queue and manual approval next. Turn on scheduled notifications after checking the rules.
- Send the first real email yourself, to a test address you own, from the review panel.
Here gmail-mcp is our custom local adapter for the Gmail API. Google also offers a Gmail MCP server with tools for search, reading, labels and draft creation. You still need to supply the queue, review translation, panel and approval check for your build. Google’s MCP tool reference.
When to use it
- Email needs your reply, but checking the inbox all the time breaks your focus.
- You write in several languages and want to understand every outgoing message.
- You regularly send files and want to inspect what is actually attached.
- You want help preparing replies while keeping the final decision yourself.
- You are willing to maintain a background process and occasionally investigate a failure.
When not to use it
- Gmail’s built-in filters and notifications already do enough for you.
- You need bulk mail, CRM campaigns or a departmental shared inbox: those have different requirements.
- You need a guaranteed alert within seconds. This watcher polls email on a schedule.
- Your organization’s rules do not allow email content to be shared with the model you chose.
The core idea
Separate observation, preparation and permission to send. Each process gets its own authority.
The human sets importance rules, requests a reply, reviews the email and authorizes sending. The agent reads permitted context, writes, translates and proposes. The watcher periodically classifies incoming mail. Ordinary code delivers notifications, stores state and executes the approved action.
The alert goes to your own chat. If you add buttons, give each one a single, explicit action. For example, “Got it” dismisses the card. A reply to the correspondent still requires approval in the email panel.
Architecture
Gmail → Mail Watcher → classification using your rules
↓
notification delivery → your Telegram
Your request → agent → gmail_propose_send
↓
Gmail draft + local queue
↓
Mission Control review panel
text · translation · files · edits
↓
your explicit confirmation
↓
sending backend → Gmail
↓
result recorded in the queue
What the system is made of
Email adapter. gmail_propose_send creates a proposal and gmail_list_pending shows its status. The adapter exposes no direct send tool. Define what a read operation returns when preparing a reply. Return plain text up to a configured size, flag truncation and omit raw HTML and base64 attachment data.
Mail Watcher. The scheduler starts a classifier with the owner’s rules. Our version classifies messages from the sender, subject and snippet. Give the classifier in your build read-only access. The wrapper validates its output, delivers alerts and keeps track of processed messages.
Queue. Gmail holds the draft itself. SQLite holds the review proposal: draft ID, recipients, text, translation, attachment metadata, timestamps and status. The proposal remains available after the agent session ends.
Review panel. I review email in Mission Control. A single page is enough for your build. The panel talks to the mail backend, which manages the queue and communicates with Gmail.
Editor and attachment viewer. Text and files are changed through the same proposal. On save, the backend checks the Gmail draft, updates it, reads it back and only then records the result in the queue. Attachment preview reads bytes from the draft and checks them against the proposal.
Operations wrapper. Limits run duration, detects stalls, retries eligible operations and reports repeated failures and recovery. Checking service availability should not require reading real email.
How we use it
1. An important email arrives
The watcher reloads the rules on every run. A synthetic mailbox query might be is:unread newer_than:1d -label:<test-label>. Supply your own label and choose the search window. Have the classifier return the number of messages checked (checked), the number flagged (important), the run status (status) and a notifications list with message_id and text for each alert. The wrapper treats invalid output as a failed run. Email content can still sway the classification. If there is too little context or a request is ambiguous, flag the message for human review with a neutral alert.
A rule for a synthetic test might read:
Notify me when an email asks for a decision on an active task. Skip promotional mail. If you’re unsure, say what is uncertain. Send only a neutral alert and a link to Telegram, without the email text or files.
Choose the level of detail according to what data you are allowed to transfer. Even a short summary reveals content. For sensitive mail, “There is an email that needs review” and a link to a protected interface may be enough.
The search selects recent unread messages without the processing label. If you open a message before the run, it will produce no alert. Show the owner the search window and the time of the last successful run. The label helps prevent duplicates. It cannot confirm that the owner saw the alert.
2. You ask for a reply
At your request, the agent prepares a reply and review translation, selects an allowed sender address and attaches files. If it has only a snippet, have it retrieve the permitted thread text or ask you for the missing context first. gmail_propose_send creates a Gmail draft and a proposal with the status pending. You get a link to the proposal.
To add a reply to a Gmail thread, supply its threadId, set the References and In-Reply-To headers per RFC 2822, and match the Subject. A thread_id field in the adapter alone does not establish this. In the acceptance test, open the test conversation and check where the reply appears. Google’s threading guide.
3. You review, edit and send
Open the proposal: who the email is from and to, what it says and which files it includes. Edit the text, add or remove attachments if needed, and save. Sending is unavailable until the save has completed.
The editor changes the body and attachments. If the subject or recipients are wrong, prepare a new proposal. “Restore agent text” restores the original body and keeps the current attachments. The recipient gets a text/plain email. If you want a signature, include it in the text.
The review translation stays separate from the body the recipient will receive. Once you edit the original, the panel marks the translation as stale. Before approving, read the original or ask the agent to prepare a new proposal with a fresh translation.
After you confirm, the backend sends the email and records the result. The agent can check status through gmail_list_pending; that tool gives it no approval authority.
4. You inspect attachments
Choose the folders the agent may attach files from. Before creating a draft, resolve each file’s path, including symbolic links. Reject files outside the allowed folders or inside secret directories or token stores. Cap the number of files and their combined size, allowing room for MIME encoding.
The proposal shows each attachment’s name, size and SHA-256 hash. Selecting its name opens the file from the Gmail draft.
PDFs, images and text can be viewed in the browser. Our DOCX preview shows extracted text with an option to download the original: it does not promise exact layout, comments or images. On macOS, the system utility textutil extracts the text. On another OS, supply a DOCX-to-text converter or offer the original as a download. Active formats such as HTML and SVG are offered as downloads, without execution inside the panel.
The sending gate
Implement the check as backend behavior. A prompt saying “ask me first” blocks nothing on its own.
- Separate preparation from sending. The agent queues a proposal. The approval handler sends the email after the human confirms.
- Only the approved version is sent. Approval is bound to the proposal, its contents and the user’s session. Review the proposal again if the message or approval conditions change. Immediately before sending, the backend compares the Gmail draft with the version you reviewed. A mismatch blocks sending until you review it again. If they match, the backend sends the approved message bytes to Gmail.
- Actions are serialized. Editing, approving and rejecting one proposal must not race each other. A double click must not cause a second send.
- An uncertain outcome blocks further action. If a Gmail request leaves it unclear whether the email was sent, the interface says so and requires reconciliation. It must not automatically send again.
- Protect access to the panel. Use a user session, request-origin checks and CSRF protection. For phone access, connect through a private network that verifies the device. Keep the panel off the public internet.
- Email remains untrusted content. HTML is not executed, attachments are not run, and a request inside an email to change the rules does not become an instruction from the owner.
- Give the agent one path to sending. Check every mail tool it can use. The agent may submit a proposal. Approval, sending and edits to a queued email must go through the panel.
The gate protects against model mistakes and instructions embedded in email. If the agent has shell access, isolate the mail backend and token from its OS account, for example with a separate account or a container with restricted access to secrets. Use a test proposal to verify that the agent can prepare an email and cannot approve it itself.
Storage and data boundaries
In Gmail: messages and drafts. Locally: the queue, rules, the agent’s original text and the time of the last edit, unfinished-operation records and operational logs. During preparation, attachments are read and included in the draft; later changes to the source file do not change the bytes already attached.
At the model: content given to the agent for reading, classification or a reply. A local MCP server does not imply local inference. In Telegram: the delivered alert, with the detail level you chose. Decide in advance which data is allowed in each service.
A queue containing texts and translations is private email too. Restrict access to it and its backups. Use the token storage you selected during authorization. Don’t put email bodies, files or secrets into git, shared team memory, public reports or telemetry. Use an operation ID and a safe error code in diagnostics.
Our review page does not store email content in localStorage/sessionStorage. That does not remove the copies in Gmail, the queue, model context or your chosen notification transport. Set retention and cleanup separately for each layer.
Gmail API and OAuth
For a local app, create a Desktop app OAuth client and enable the Gmail API. If you use an External audience for a personal Gmail account, switch the app to In production and authorize it again before relying on background runs. In Testing, a refresh token with Gmail scopes expires after seven days. For Workspace, Internal is an option when the project belongs to the organization and only its members use the app. Administrator policies still apply. The Gmail scopes below are restricted. For an unverified External app, Google may display a warning and cap the number of users. Google’s audience settings.
Choose permissions by operation:
- Search and read messages with
gmail.readonly. A watcher with only this scope can store processed message IDs in SQLite. - Create a draft with
gmail.compose. This scope also allows sending, so the application must enforce approval. - Apply a message label with
gmail.modifyformessages.modify. This scope also allows sending. If you use labels, let the wrapper apply them and restrict the classifier to read tools. Gmail API scopes · Permissions for modifying message labels.
A Gmail draft has a stable ID, while the message it contains is replaced on edit. Sending deletes the draft and creates a sent message. The queue therefore needs to distinguish proposal, draft and message IDs; post-send preview availability must not be promised as an archive. Google: Create and send draft emails, updated September 10, 2026.
Choose the polling interval using your project quotas and the cost of each method. Searching and fetching full MIME consume different numbers of units. As of November 2026, Google plans to charge for usage above a daily threshold, with at least 90 days’ notice. Check the terms for your project before setup. Google’s quota and pricing guidance.
For requests that are safe to repeat, such as reads, use a limited number of retries with increasing delays. A sent queue entry means Gmail accepted the send request. Delivery to the recipient is still unconfirmed. If the outcome is unclear, check Gmail before taking further action. Gmail API error handling.
Build phases
Phase 1 — reading and trial classification
Build the email adapter, authorization and rules file. Prepare a separate test mailbox or a set of synthetic messages: important, promotional, ambiguous and an email trying to instruct the agent. For now, the classifier only explains its decisions.
Done when: search and reading work from the environment where the scheduler will run; results can be checked; trial mode neither changes labels nor sends notifications. Email access is not tested by sending a message.
Phase 2 — queue and manual approval
Add draft creation, a local queue and a simple review page. A minimal proposal contains an ID, a reference to the Gmail draft, From/To/Cc/Bcc, subject, text, a translation bound to its original, file metadata, timestamps, version and state.
Minimal states are pending, sent and rejected. Alongside them, track unfinished saves and external operations with unknown outcomes. Don’t collapse “unknown” into “not sent”: they are different situations.
Done when: with a simulated Gmail client, the agent can submit a proposal and only the user can authorize sending through the panel. Test cancellation, a double click and a draft changed after review. A mismatch must block the send until the draft is reviewed again. If the provider received a request but the outcome is unknown, the queue must retain a record for reconciliation.
Phase 3 — translation, editing and attachments
Add two clearly labeled areas: “Sent to the recipient” and “Translation for review.” Bind the translation to the original text version. Implement backend saving with read-back, preview files from the draft and restore the original text.
Done when: after an edit, the translation no longer appears current; an unfinished save blocks sending; a stale tab cannot approve a new version; preview opens the attached file, not its old source on disk. Check on a phone and a computer.
Phase 4 — scheduled notifications and operations
Connect Telegram delivery, the scheduler, protection against overlapping runs and failure alerts. For an important message, first record the alert as pending delivery. Apply the processing label or mark the ID as processed only after Telegram acknowledges delivery. If delivery fails, leave the alert queued for reconciliation. On the first run, the owner may explicitly choose to mark the backlog as processed without notifications.
Done when: trial mode sends nothing; an ordinary repeat doesn’t notify again for processed messages; repeated failures are visible; state survives restart; after extended downtime, there’s a clear way to review the missed period. Running from a terminal does not replace checking under the actual scheduler.
A starter brief for your agent
Build a personal Email + Claude system following this blueprint. First ask the adaptation questions and show a phased plan. One Gmail account, notifications to my Telegram, outgoing email only through a manual review page. Show separately what is implemented, what is limited and what still needs to be built. Don’t ask for secrets in chat. Use synthetic emails and a fake email client for development and tests. Connecting the real mailbox, changing labels and the first send are separate owner actions. At the end, provide a component map, settings, tests and failure-recovery instructions.
A synthetic request for the finished system:
Prepare an email in English to [email protected] asking them to suggest two times for a short call. Show a Russian translation. Attach a test file named agenda.txt containing “Synthetic meeting agenda”. Put it in the review queue.
example.com and the file in this example are test data. Don’t substitute real correspondence in public demonstrations.
Resilience
The watcher is silent. There may be no important email, or authorization may have failed, the agent may have stalled or the network may be unavailable. Show the last successful classification time separately from the last notification time. Bound both total runtime and time without progress. Checking one email adapter is cheaper than starting every integration on the machine.
The machine has been offline for a while. A rolling search window won’t automatically catch everything up. In the first version, provide a manual review of the missed period. For stricter change tracking, Gmail history synchronization can be implemented separately; Google requires a full sync when historyId is too old. This is an extension, not a feature of the watcher described here. Google: Synchronize clients, updated September 15, 2026.
It’s unclear whether an edit was saved. The backend compares the actual draft with expected versions. It records an edit already applied, or shows a conflict to the human. Sending stays closed until this is resolved.
The send outcome is unclear. Record the attempt before contacting Gmail and block automatic retries. The operator checks the proposal against sent mail and drafts in Gmail, then records the outcome manually. Include a reconciliation action in your build. If the matching sent message is found, mark the proposal sent. If you can confirm that nothing was sent and the original draft is intact, restore pending for a new approval. Clear the attempt flag and log the decision in the same transaction. If the evidence is inconclusive, keep sending blocked.
You need a rollback. Code and sending state are restored differently. Restoring an old database can revive proposals that have already been executed. Don’t roll the queue and attempt history back with the code, or remove an unfinished operation just to get a green indicator.
Gotchas
- Test the scheduled run. Choose a scheduler for your OS, such as launchd on macOS or a systemd timer on Linux. Test it under the same account. On macOS even a folder-access prompt can wait in an invisible dialog.
- An OAuth failure can look like an empty inbox. Changing the Google account password may invalidate a token with Gmail scopes. A token can also expire after six months of inactivity. If refresh is denied, the watcher ends the run with a visible error without trying to open a browser in the background. The owner authorizes access again interactively. Google’s refresh token expiration rules.
- Silence doesn’t prove health. Failing to parse the model’s response is not the same as finding zero important messages. Use distinct states and an alert.
- Deduplication is not delivery. For more reliable notifications, distinguish “classified,” “queued for delivery” and “delivery confirmed.” Don’t promise exactly-once behavior without implementing and testing it separately.
- A past date doesn’t always make an email stale. “We met on November 2” and “I suggest meeting on November 2” call for different decisions. Our date check is a bounded heuristic; it doesn’t replace human reading.
- A current original with an old translation creates false confidence. Show the translation’s version binding and a warning after an edit.
- A filename doesn’t prove its contents. Preview should show bytes from the prepared email. Check the file list after restoring the original text too.
- One recipient can receive different emails. A newer proposal to the same person is a reason to show a hint, not to delete the old one automatically.
- The sender address needs its own check. One mailbox with verified aliases is not multi-account support. A custom domain and its delivery setup are separate work.
Questions to adapt it to you
- Which single mailbox comes first, and may its content be processed by your chosen model?
- What counts as important? Give a few synthetic examples of “notify / skip / ask.”
- How often should email be checked, in which time zone, and when should notifications stay quiet?
- What may appear in Telegram: only an alert, a subject or a short summary?
- Which languages do you write to recipients in, and which language should the review translation use?
- Do you need verified sender addresses, Cc/Bcc and replies within existing threads?
- Which folders may supply attachments, which file types are allowed and what limits do you need on count, size and retention?
- Which OS runs the scheduler and DOCX viewer, how does the phone join the panel’s private network, and who restores the system after a failure?
Readiness checklist
- Every mail tool available to the agent has been checked. It can create a proposal. It cannot send, approve or edit a queued email outside the panel.
- The human sees From/To/Cc/Bcc, subject, outgoing text, translation and every file.
- Changes are saved and read back before sending becomes available.
- An old translation and an old tab do not present themselves as a current review.
- Cancellation, double clicks, version conflicts and unknown outcomes are tested with synthetic data.
- Old drafts and past meeting dates or deadlines in the text require another review.
- Attachments come from the draft; active content does not execute.
- Importance rules, quiet hours and the search window are visible to the owner.
- Trial mode, first activation and repeat runs don’t produce unexpected notifications.
- Authorization failures, stalls and extended downtime have clear alerts and recovery steps.
- Secrets, the queue, backups and model context are accounted for as separate places where data can be accessed.
- A human has made the first real send to a test address they own.
What’s outside this blueprint
This build excludes HTML email layouts, automatic Gmail signatures, bulk mail and unattended replies. Multiple independent accounts, arbitrary translation languages, instant alerts, a post-send preview archive and custom-domain mail setup each require additional work.
Reference implementation
Our implementation is private: Python, FastMCP, Gmail API, SQLite and FastAPI for email; a TypeScript interface in Mission Control; the macOS scheduler and a wrapper for the watcher; Telegram Bot API for notifications. You don’t need links to private repositories to reproduce it: the contract, phases and checks are described above.
You end up with one clear path: an important email becomes an alert, a request becomes a reviewable draft, and your click becomes a send. You will have a few small components to maintain. They earn their keep when they reduce how often you need to switch into email and leave the decision about an outgoing message with you.