Problem
Emails sent via the Gmail MCP tool (send-email) cannot be threaded correctly for recipients. The threadId parameter only groups messages on the sender's Gmail — recipients see each reply as a separate conversation.
This is because:
send-email has no parameters for thread_id, in_reply_to, or references headers
- There is no
get-email action to retrieve the Message-ID header from a sent/received message
- Without knowing the Gmail-assigned
Message-ID, it's impossible to set proper In-Reply-To and References headers on replies
Background
Per RFC 2822 and Gmail's threading logic, recipient-side threading requires:
In-Reply-To: <Message-ID of parent email>
References: <space-separated Message-IDs of conversation chain>
Subject: Re: <original subject>
The threadId in the Gmail API request body only affects the sender's mailbox. Recipients rely entirely on these RFC headers.
Proposed Changes
1. Add threading parameters to send-email and create-draft
thread_id (string, optional) — Gmail thread ID for sender-side threading
in_reply_to (string, optional) — RFC 2822 Message-ID of the email being replied to
references (string[], optional) — List of Message-IDs from the conversation chain
2. Add new get-email action
message_id (string, required) — The ID of the message to retrieve
format (enum, optional) — full, metadata, minimal, raw
metadata_headers (string[], optional) — Specific headers to return (e.g., ["Message-ID", "In-Reply-To", "References"])
3. Backend: pass threading headers through to Gmail API
The invoke-action backend needs to:
- Include
threadId in the Gmail API send request body
- Set
In-Reply-To and References in the raw MIME when provided
- Return
Message-ID header in get-email responses
Intended Workflow
- Receive/find an email → note its Gmail
id
- Call
get-email with format=metadata, metadata_headers=["Message-ID"] → get the RFC Message-ID
- Call
send-email with thread_id, in_reply_to=<that Message-ID>, references=[<that Message-ID>], subject="Re: ..."
- Email threads correctly for both sender AND recipient ✅
Reference Implementation
I have a working fork with the client-side changes (parameters, prompts, tools, configuration):
https://github.com/frankhli843/agent-toolkit/tree/fix/gmail-threading-support
Happy to open a PR if helpful.
Problem
Emails sent via the Gmail MCP tool (
send-email) cannot be threaded correctly for recipients. ThethreadIdparameter only groups messages on the sender's Gmail — recipients see each reply as a separate conversation.This is because:
send-emailhas no parameters forthread_id,in_reply_to, orreferencesheadersget-emailaction to retrieve theMessage-IDheader from a sent/received messageMessage-ID, it's impossible to set properIn-Reply-ToandReferencesheaders on repliesBackground
Per RFC 2822 and Gmail's threading logic, recipient-side threading requires:
In-Reply-To: <Message-ID of parent email>References: <space-separated Message-IDs of conversation chain>Subject: Re: <original subject>The
threadIdin the Gmail API request body only affects the sender's mailbox. Recipients rely entirely on these RFC headers.Proposed Changes
1. Add threading parameters to
send-emailandcreate-draftthread_id(string, optional) — Gmail thread ID for sender-side threadingin_reply_to(string, optional) — RFC 2822 Message-ID of the email being replied toreferences(string[], optional) — List of Message-IDs from the conversation chain2. Add new
get-emailactionmessage_id(string, required) — The ID of the message to retrieveformat(enum, optional) —full,metadata,minimal,rawmetadata_headers(string[], optional) — Specific headers to return (e.g.,["Message-ID", "In-Reply-To", "References"])3. Backend: pass threading headers through to Gmail API
The
invoke-actionbackend needs to:threadIdin the Gmail API send request bodyIn-Reply-ToandReferencesin the raw MIME when providedMessage-IDheader inget-emailresponsesIntended Workflow
idget-emailwithformat=metadata,metadata_headers=["Message-ID"]→ get the RFC Message-IDsend-emailwiththread_id,in_reply_to=<that Message-ID>,references=[<that Message-ID>],subject="Re: ..."Reference Implementation
I have a working fork with the client-side changes (parameters, prompts, tools, configuration):
https://github.com/frankhli843/agent-toolkit/tree/fix/gmail-threading-support
Happy to open a PR if helpful.