Skip to main content

Module gmail_write

Module gmail_write 

Source
Expand description

The Gmail tool’s write actions (G3), named after Google’s Gmail MCP tools (SPEC_GOOGLE_CONNECTORS_GMAIL_CALENDAR_DRIVE_2026_10_14.md §5, §6): create_draft, update_draft, label_thread (no prompt with a write grant), send_draft and trash_thread (always ask the person).

There is no raw send: an agent writes a draft, and sending is send_draft, which shows the person the draft exactly as it will go. This module is the pure half, as super::gmail is for reads: the mail an agent describes as a message Google takes (outgoing, rfc822), the requests, what the person is shown (DraftView, send_question) and the check that what they approved is what is sent (DraftView::digest). The flow that asks and calls is super::gmail_flow.

Structs§

DraftView
A draft as it is stored: what send_draft shows the person and checks again before sending.
Outgoing
One mail as an agent describes it, checked.
Reply
What a reply needs from the thread it answers.

Constants§

WRITE_ACTIONS
The write actions, in the order the tool lists them.

Functions§

always_asks
Actions that always wait for the person (§6).
draft_fetch_plan
The request for a draft as it is now, to show the person and to check before sending.
draft_plan
The request for create_draft (or, with a draft id, update_draft). A thread_id makes the draft a reply in that thread: reply is that thread’s last message (see reply_of), which a reply needs for Gmail to thread it.
draft_raw_plan
The request for the draft’s message as raw MIME: the snapshot that is sent.
granted_for
Whether granted (full scope URLs, or bare names) covers the write action.
label_plan
The request for label_thread. Putting a thread in the trash takes trash_thread, which asks the person, so the trash label is not one this can add.
needs
The scopes an action can run with: any one is enough. A draft or a send is gmail.compose; labels and trash need gmail.modify (which includes compose).
outgoing
The mail args describes. A draft needs a recipient only in the end: create_draft may leave to empty for the person to fill in, but nothing is sent without one.
reply_fetch_plan
The request for the headers of the thread a draft replies to.
reply_of
The reply headers for an answer to the last message of thread (Google’s threads.get, format metadata); None when it has no usable Message-ID.
rfc822
The mail as RFC 5322 text, which Gmail takes (base64url) as a draft’s raw. No From: Gmail writes the account’s own address.
send_plan
The request that sends the draft id with exactly the message raw (base64url MIME) that was checked, so a save made after the check cannot put other text, recipients or files in its place.
send_question
The title and text of the window that asks the person to send view.
send_question_in
send_question for a draft that replies into a thread: the warning first, the thread after the recipients.
trash_plan
The request that moves a thread to the trash (it stays there for 30 days).
trash_question
The title and text of the window that asks the person to trash a thread. summary is the thread’s headers as super::gmail::summary_plan asks for them.
with_reply
o as a reply: its threading headers, and the original subject (with Re: ) when it has none.