Gmail Automation via Rube MCP
Automate Gmail operations through Composio's Gmail toolkit via Rube MCP.
Toolkit docs: composio.dev/toolkits/gmail
Prerequisites
- Rube MCP must be connected (RUBE_SEARCH_TOOLS available)
- Active Gmail connection via
RUBE_MANAGE_CONNECTIONS with toolkit gmail
- Always call
RUBE_SEARCH_TOOLS first to get current tool schemas
Setup
Get Rube MCP: Add https://rube.app/mcp as an MCP server in your client configuration. No API keys needed — just add the endpoint and it works.
- Verify Rube MCP is available by confirming
RUBE_SEARCH_TOOLS responds
- Call
RUBE_MANAGE_CONNECTIONS with toolkit gmail
- If connection is not ACTIVE, follow the returned auth link to complete Google OAuth
- Confirm connection status shows ACTIVE before running any workflows
Core Workflows
1. Send an Email
When to use: User wants to compose and send a new email
Tool sequence:
GMAIL_SEARCH_PEOPLE - Resolve contact name to email address [Optional]
GMAIL_SEND_EMAIL - Send the email [Required]
Key parameters:
recipient_email: Email address or 'me' for self
subject: Email subject line
body: Email content (plain text or HTML)
is_html: Must be true if body contains HTML markup
cc/bcc: Arrays of email addresses
attachment: Object with {s3key, mimetype, name} from prior download
Pitfalls:
- At least one of
recipient_email, cc, or bcc required
- At least one of
subject or body required
- Attachment
mimetype MUST contain '/' (e.g., 'application/pdf', not 'pdf')
- Total message size limit ~25MB after base64 encoding
- Use
from_email only for verified aliases in Gmail 'Send mail as' settings
2. Reply to a Thread
When to use: User wants to reply to an existing email conversation
Tool sequence:
GMAIL_FETCH_EMAILS - Find the email/thread to reply to [Prerequisite]
GMAIL_REPLY_TO_THREAD - Send reply within the thread [Required]
Key parameters:
thread_id: Hex string from FETCH_EMAILS (e.g., '169eefc8138e68ca')
message_body: Reply content
recipient_email: Reply recipient
is_html: Set true for HTML content
Pitfalls:
thread_id must be hex string; prefixes like 'msg-f:' are auto-stripped
- Legacy Gmail web UI IDs (e.g., 'FMfcgz...') are NOT supported
- Subject is inherited from original thread; setting it creates a new thread instead
- Do NOT include subject parameter to stay within thread
3. Search and Filter Emails
When to use: User wants to find specific emails by sender, subject, date, label, etc.
Tool sequence:
GMAIL_FETCH_EMAILS - Search with Gmail query syntax [Required]
GMAIL_FETCH_MESSAGE_BY_MESSAGE_ID - Get full message details for selected results [Optional]
Key parameters:
query: Gmail search syntax (from:, to:, subject:, is:unread, has:attachment, after:YYYY/MM/DD, before:YYYY/MM/DD)
max_results: 1-500 messages per page
label_ids: System IDs like 'INBOX', 'UNREAD'
include_payload: Set true to get full message content
ids_only: Set true for just message IDs
page_token: For pagination (from nextPageToken)
Pitfalls:
- Returns max ~500 per page; follow
nextPageToken via page_token until absent
resultSizeEstimate is approximate, not exact count
- Use 'is:' for states (is:unread, is:snoozed, is:starred)
- Use 'label:' ONLY for user-created labels
- Common mistake: 'label:snoozed' is WRONG — use 'is:snoozed'
include_payload=true on broad searches creates huge responses; default to metadata
- Custom labels require label ID (e.g., 'Label_123'), NOT label name
4. Manage Labels
When to use: User wants to create, modify, or organize labels
Tool sequence:
GMAIL_LIST_LABELS - List all labels to find IDs and detect conflicts [Required]
GMAIL_CREATE_LABEL - Create a new label [Optional]
GMAIL_PATCH_LABEL - Rename or change label colors/visibility [Optional]
GMAIL_DELETE_LABEL - Delete a user-created label (irreversible) [Optional]
Key parameters:
label_name: Max 225 chars, no commas, '/' for nesting (e.g., 'Work/Projects')
background_color/text_color: Hex values from Gmail's predefined palette
id: Label ID for PATCH/DELETE operations
Pitfalls:
- 400/409 error if name is blank, duplicate, or reserved (INBOX, SPAM, CATEGORY_*)
- Color specs must use Gmail's predefined palette of 102 hex values
- DELETE is permanent and removes label from all messages
- Cannot delete system labels (INBOX, SENT, DRAFT, etc.)
5. Apply/Remove Labels on Messages
When to use: User wants to label, archive, or mark emails as read/unread
Tool sequence:
GMAIL_LIST_LABELS - Get label IDs for custom labels [Prerequisite]
GMAIL_FETCH_EMAILS - Find target messages [Prerequisite]
GMAIL_BATCH_MODIFY_MESSAGES - Bulk add/remove labels (up to 1000 messages) [Required]
GMAIL_ADD_LABEL_TO_EMAIL - Single-message label changes [Fallback]
Key parameters:
messageIds: Array of message IDs (max 1000)
addLabelIds: Array of label IDs to add
removeLabelIds: Array of label IDs to remove
message_id: 15-16 char hex string for single operations
Pitfalls:
- Max 1000 messageIds per BATCH call; chunk larger sets
- Use 'CATEGORY_UPDATES' not 'UPDATES'; full prefix required for category labels
- SENT, DRAFT, CHAT are immutable — cannot be added/removed
- To mark as read: REMOVE 'UNREAD'. To archive: REMOVE 'INBOX'
message_id must be 15-16 char hex, NOT UUIDs or web UI IDs
6. Handle Drafts and Attachments
When to use: User wants to create, edit, or send email drafts, possibly with attachments
Tool sequence:
GMAIL_CREATE_EMAIL_DRAFT - Create a new draft [Required]
GMAIL_UPDATE_DRAFT - Edit draft content [Optional]
GMAIL_LIST_DRAFTS - List existing drafts [Optional]
GMAIL_SEND_DRAFT - Send a draft (requires explicit user approval) [Optional]
GMAIL_GET_ATTACHMENT - Download attachment from existing message [Optional]
Key parameters:
recipient_email: Draft recipient
subject: Draft subject (omit for reply drafts to stay in thread)
body: Draft content
is_html: Set true for HTML content
attachment: Object with {s3key, mimetype, name}
thread_id: For reply drafts (leave subject empty to stay in thread)
Pitfalls:
- Response includes
data.id (draft_id) AND data.message.id; use data.id for draft operations
- Setting subject on a thread reply draft creates a NEW thread instead
- Attachment capped at ~25MB; base64 overhead can push near-limit files over
- UPDATE_DRAFT replaces entire content, not patches; include all fields you want to keep
- HTTP 429 on bulk draft creation; use exponential backoff
Common Patterns
ID Resolution
Label name → Label ID:
1. Call GMAIL_LIST_LABELS
2. Find label by name in response
3. Extract id field (e.g., 'Label_123')
Contact name → Email:
1. Call GMAIL_SEARCH_PEOPLE with query=contact_name
2. Extract emailAddresses from response
Thread ID from search:
1. Call GMAIL_FETCH_EMAILS or GMAIL_LIST_THREADS
2. Extract threadId (15-16 char hex string)
Pagination
- Set
max_results up to 500 per page
- Check response for
nextPageToken
- Pass token as
page_token in next request
- Continue until
nextPageToken is absent or empty string
resultSizeEstimate is approximate, not exact
Gmail Query Syntax
Operators:
from:sender@example.com - Emails from sender
to:recipient@example.com - Emails to recipient
subject:"exact phrase" - Subject contains exact phrase
is:unread - Unread messages
is:starred - Starred messages
is:snoozed - Snoozed messages
has:attachment - Has attachments
after:2024/01/01 - After date (YYYY/MM/DD)
before:2024/12/31 - Before date
label:custom_label - User-created label (use label ID)
in:sent - In sent folder
category:primary - Primary category
Combinators:
AND - Both conditions (default)
OR - Either condition
NOT - Exclude condition
() - Group conditions
Examples:
from:boss@company.com is:unread - Unread emails from boss
subject:invoice has:attachment after:2024/01/01 - Invoices with attachments this year
(from:alice OR from:bob) is:starred - Starred emails from Alice or Bob
Known Pitfalls
ID Formats:
- Custom label operations require label IDs (e.g., 'Label_123'), not display names
- Always call LIST_LABELS first to resolve names to IDs
- Message IDs are 15-16 char hex strings
- Do NOT use UUIDs, web UI IDs, or 'thread-f:' prefixes
Query Syntax:
- Use 'is:' for states (unread, snoozed, starred)
- Use 'label:' ONLY for user-created labels
- System labels use 'is:' or 'in:' (e.g., 'is:sent', 'in:inbox')
Rate Limits:
- BATCH_MODIFY_MESSAGES max 1000 messages per call
- Heavy use triggers 403/429 rate limits
- Implement exponential backoff for bulk operations
Response Parsing:
- Response data may be nested under
data_preview or data.messages
- Parse defensively with fallbacks
- Timestamp
messageTimestamp uses RFC3339 with 'Z' suffix
- Normalize to '+00:00' for parsing if needed
Attachments:
- Attachment
s3key from prior download may expire
- Use promptly after retrieval
- Mimetype must include '/' separator
Quick Reference
| Task |
Tool Slug |
Key Params |
| Send email |
GMAIL_SEND_EMAIL |
recipient_email, subject, body, is_html |
| Reply to thread |
GMAIL_REPLY_TO_THREAD |
thread_id, message_body, recipient_email |
| Search emails |
GMAIL_FETCH_EMAILS |
query, max_results, label_ids, page_token |
| Get message details |
GMAIL_FETCH_MESSAGE_BY_MESSAGE_ID |
message_id |
| List labels |
GMAIL_LIST_LABELS |
(none) |
| Create label |
GMAIL_CREATE_LABEL |
label_name, background_color, text_color |
| Modify labels bulk |
GMAIL_BATCH_MODIFY_MESSAGES |
messageIds, addLabelIds, removeLabelIds |
| Create draft |
GMAIL_CREATE_EMAIL_DRAFT |
recipient_email, subject, body, thread_id |
| Send draft |
GMAIL_SEND_DRAFT |
draft_id |
| Get attachment |
GMAIL_GET_ATTACHMENT |
message_id, attachment_id |
| Search contacts |
GMAIL_SEARCH_PEOPLE |
query |
| Get profile |
GMAIL_GET_PROFILE |
(none) |
Powered by Composio
Source: davepoon/buildwithclaude → plugins/all-skills/skills/gmail-automation/SKILL.md
1---2name: gmail-automation-23description: Automate Gmail tasks via Rube MCP (Composio): send/reply, search, labels, drafts, attachments. Always search tools first for current schemas.4---5
6
7# Gmail Automation via Rube MCP
8
9Automate Gmail operations through Composio's Gmail toolkit via Rube MCP.
10
11**Toolkit docs**: [composio.dev/toolkits/gmail](https://composio.dev/toolkits/gmail)
12
13## Prerequisites
14
15- Rube MCP must be connected (RUBE_SEARCH_TOOLS available)
16- Active Gmail connection via `RUBE_MANAGE_CONNECTIONS` with toolkit `gmail`
17- Always call `RUBE_SEARCH_TOOLS` first to get current tool schemas
18
19## Setup
20
21**Get Rube MCP**: Add `https://rube.app/mcp` as an MCP server in your client configuration. No API keys needed — just add the endpoint and it works.
22
23
241. Verify Rube MCP is available by confirming `RUBE_SEARCH_TOOLS` responds
252. Call `RUBE_MANAGE_CONNECTIONS` with toolkit `gmail`
263. If connection is not ACTIVE, follow the returned auth link to complete Google OAuth
274. Confirm connection status shows ACTIVE before running any workflows
28
29## Core Workflows
30
31### 1. Send an Email
32
33**When to use**: User wants to compose and send a new email
34
35**Tool sequence**:
361. `GMAIL_SEARCH_PEOPLE` - Resolve contact name to email address [Optional]
372. `GMAIL_SEND_EMAIL` - Send the email [Required]
38
39**Key parameters**:
40- `recipient_email`: Email address or 'me' for self
41- `subject`: Email subject line
42- `body`: Email content (plain text or HTML)
43- `is_html`: Must be `true` if body contains HTML markup
44- `cc`/`bcc`: Arrays of email addresses
45- `attachment`: Object with `{s3key, mimetype, name}` from prior download
46
47**Pitfalls**:
48- At least one of `recipient_email`, `cc`, or `bcc` required
49- At least one of `subject` or `body` required
50- Attachment `mimetype` MUST contain '/' (e.g., 'application/pdf', not 'pdf')
51- Total message size limit ~25MB after base64 encoding
52- Use `from_email` only for verified aliases in Gmail 'Send mail as' settings
53
54### 2. Reply to a Thread
55
56**When to use**: User wants to reply to an existing email conversation
57
58**Tool sequence**:
591. `GMAIL_FETCH_EMAILS` - Find the email/thread to reply to [Prerequisite]
602. `GMAIL_REPLY_TO_THREAD` - Send reply within the thread [Required]
61
62**Key parameters**:
63- `thread_id`: Hex string from FETCH_EMAILS (e.g., '169eefc8138e68ca')
64- `message_body`: Reply content
65- `recipient_email`: Reply recipient
66- `is_html`: Set `true` for HTML content
67
68**Pitfalls**:
69- `thread_id` must be hex string; prefixes like 'msg-f:' are auto-stripped
70- Legacy Gmail web UI IDs (e.g., 'FMfcgz...') are NOT supported
71- Subject is inherited from original thread; setting it creates a new thread instead
72- Do NOT include subject parameter to stay within thread
73
74### 3. Search and Filter Emails
75
76**When to use**: User wants to find specific emails by sender, subject, date, label, etc.
77
78**Tool sequence**:
791. `GMAIL_FETCH_EMAILS` - Search with Gmail query syntax [Required]
802. `GMAIL_FETCH_MESSAGE_BY_MESSAGE_ID` - Get full message details for selected results [Optional]
81
82**Key parameters**:
83- `query`: Gmail search syntax (from:, to:, subject:, is:unread, has:attachment, after:YYYY/MM/DD, before:YYYY/MM/DD)
84- `max_results`: 1-500 messages per page
85- `label_ids`: System IDs like 'INBOX', 'UNREAD'
86- `include_payload`: Set `true` to get full message content
87- `ids_only`: Set `true` for just message IDs
88- `page_token`: For pagination (from `nextPageToken`)
89
90**Pitfalls**:
91- Returns max ~500 per page; follow `nextPageToken` via `page_token` until absent
92- `resultSizeEstimate` is approximate, not exact count
93- Use 'is:' for states (is:unread, is:snoozed, is:starred)
94- Use 'label:' ONLY for user-created labels
95- Common mistake: 'label:snoozed' is WRONG — use 'is:snoozed'
96- `include_payload=true` on broad searches creates huge responses; default to metadata
97- Custom labels require label ID (e.g., 'Label_123'), NOT label name
98
99### 4. Manage Labels
100
101**When to use**: User wants to create, modify, or organize labels
102
103**Tool sequence**:
1041. `GMAIL_LIST_LABELS` - List all labels to find IDs and detect conflicts [Required]
1052. `GMAIL_CREATE_LABEL` - Create a new label [Optional]
1063. `GMAIL_PATCH_LABEL` - Rename or change label colors/visibility [Optional]
1074. `GMAIL_DELETE_LABEL` - Delete a user-created label (irreversible) [Optional]
108
109**Key parameters**:
110- `label_name`: Max 225 chars, no commas, '/' for nesting (e.g., 'Work/Projects')
111- `background_color`/`text_color`: Hex values from Gmail's predefined palette
112- `id`: Label ID for PATCH/DELETE operations
113
114**Pitfalls**:
115- 400/409 error if name is blank, duplicate, or reserved (INBOX, SPAM, CATEGORY_*)
116- Color specs must use Gmail's predefined palette of 102 hex values
117- DELETE is permanent and removes label from all messages
118- Cannot delete system labels (INBOX, SENT, DRAFT, etc.)
119
120### 5. Apply/Remove Labels on Messages
121
122**When to use**: User wants to label, archive, or mark emails as read/unread
123
124**Tool sequence**:
1251. `GMAIL_LIST_LABELS` - Get label IDs for custom labels [Prerequisite]
1262. `GMAIL_FETCH_EMAILS` - Find target messages [Prerequisite]
1273. `GMAIL_BATCH_MODIFY_MESSAGES` - Bulk add/remove labels (up to 1000 messages) [Required]
1284. `GMAIL_ADD_LABEL_TO_EMAIL` - Single-message label changes [Fallback]
129
130**Key parameters**:
131- `messageIds`: Array of message IDs (max 1000)
132- `addLabelIds`: Array of label IDs to add
133- `removeLabelIds`: Array of label IDs to remove
134- `message_id`: 15-16 char hex string for single operations
135
136**Pitfalls**:
137- Max 1000 messageIds per BATCH call; chunk larger sets
138- Use 'CATEGORY_UPDATES' not 'UPDATES'; full prefix required for category labels
139- SENT, DRAFT, CHAT are immutable — cannot be added/removed
140- To mark as read: REMOVE 'UNREAD'. To archive: REMOVE 'INBOX'
141- `message_id` must be 15-16 char hex, NOT UUIDs or web UI IDs
142
143### 6. Handle Drafts and Attachments
144
145**When to use**: User wants to create, edit, or send email drafts, possibly with attachments
146
147**Tool sequence**:
1481. `GMAIL_CREATE_EMAIL_DRAFT` - Create a new draft [Required]
1492. `GMAIL_UPDATE_DRAFT` - Edit draft content [Optional]
1503. `GMAIL_LIST_DRAFTS` - List existing drafts [Optional]
1514. `GMAIL_SEND_DRAFT` - Send a draft (requires explicit user approval) [Optional]
1525. `GMAIL_GET_ATTACHMENT` - Download attachment from existing message [Optional]
153
154**Key parameters**:
155- `recipient_email`: Draft recipient
156- `subject`: Draft subject (omit for reply drafts to stay in thread)
157- `body`: Draft content
158- `is_html`: Set `true` for HTML content
159- `attachment`: Object with `{s3key, mimetype, name}`
160- `thread_id`: For reply drafts (leave subject empty to stay in thread)
161
162**Pitfalls**:
163- Response includes `data.id` (draft_id) AND `data.message.id`; use `data.id` for draft operations
164- Setting subject on a thread reply draft creates a NEW thread instead
165- Attachment capped at ~25MB; base64 overhead can push near-limit files over
166- UPDATE_DRAFT replaces entire content, not patches; include all fields you want to keep
167- HTTP 429 on bulk draft creation; use exponential backoff
168
169## Common Patterns
170
171### ID Resolution
172
173**Label name → Label ID**:
174```
1751. Call GMAIL_LIST_LABELS
1762. Find label by name in response
1773. Extract id field (e.g., 'Label_123')
178```
179
180**Contact name → Email**:
181```
1821. Call GMAIL_SEARCH_PEOPLE with query=contact_name
1832. Extract emailAddresses from response
184```
185
186**Thread ID from search**:
187```
1881. Call GMAIL_FETCH_EMAILS or GMAIL_LIST_THREADS
1892. Extract threadId (15-16 char hex string)
190```
191
192### Pagination
193
194- Set `max_results` up to 500 per page
195- Check response for `nextPageToken`
196- Pass token as `page_token` in next request
197- Continue until `nextPageToken` is absent or empty string
198- `resultSizeEstimate` is approximate, not exact
199
200### Gmail Query Syntax
201
202**Operators**:
203- `from:sender@example.com` - Emails from sender
204- `to:recipient@example.com` - Emails to recipient
205- `subject:"exact phrase"` - Subject contains exact phrase
206- `is:unread` - Unread messages
207- `is:starred` - Starred messages
208- `is:snoozed` - Snoozed messages
209- `has:attachment` - Has attachments
210- `after:2024/01/01` - After date (YYYY/MM/DD)
211- `before:2024/12/31` - Before date
212- `label:custom_label` - User-created label (use label ID)
213- `in:sent` - In sent folder
214- `category:primary` - Primary category
215
216**Combinators**:
217- `AND` - Both conditions (default)
218- `OR` - Either condition
219- `NOT` - Exclude condition
220- `()` - Group conditions
221
222**Examples**:
223- `from:boss@company.com is:unread` - Unread emails from boss
224- `subject:invoice has:attachment after:2024/01/01` - Invoices with attachments this year
225- `(from:alice OR from:bob) is:starred` - Starred emails from Alice or Bob
226
227## Known Pitfalls
228
229**ID Formats**:
230- Custom label operations require label IDs (e.g., 'Label_123'), not display names
231- Always call LIST_LABELS first to resolve names to IDs
232- Message IDs are 15-16 char hex strings
233- Do NOT use UUIDs, web UI IDs, or 'thread-f:' prefixes
234
235**Query Syntax**:
236- Use 'is:' for states (unread, snoozed, starred)
237- Use 'label:' ONLY for user-created labels
238- System labels use 'is:' or 'in:' (e.g., 'is:sent', 'in:inbox')
239
240**Rate Limits**:
241- BATCH_MODIFY_MESSAGES max 1000 messages per call
242- Heavy use triggers 403/429 rate limits
243- Implement exponential backoff for bulk operations
244
245**Response Parsing**:
246- Response data may be nested under `data_preview` or `data.messages`
247- Parse defensively with fallbacks
248- Timestamp `messageTimestamp` uses RFC3339 with 'Z' suffix
249- Normalize to '+00:00' for parsing if needed
250
251**Attachments**:
252- Attachment `s3key` from prior download may expire
253- Use promptly after retrieval
254- Mimetype must include '/' separator
255
256## Quick Reference
257
258| Task | Tool Slug | Key Params |
259|------|-----------|------------|
260| Send email | GMAIL_SEND_EMAIL | recipient_email, subject, body, is_html |
261| Reply to thread | GMAIL_REPLY_TO_THREAD | thread_id, message_body, recipient_email |
262| Search emails | GMAIL_FETCH_EMAILS | query, max_results, label_ids, page_token |
263| Get message details | GMAIL_FETCH_MESSAGE_BY_MESSAGE_ID | message_id |
264| List labels | GMAIL_LIST_LABELS | (none) |
265| Create label | GMAIL_CREATE_LABEL | label_name, background_color, text_color |
266| Modify labels bulk | GMAIL_BATCH_MODIFY_MESSAGES | messageIds, addLabelIds, removeLabelIds |
267| Create draft | GMAIL_CREATE_EMAIL_DRAFT | recipient_email, subject, body, thread_id |
268| Send draft | GMAIL_SEND_DRAFT | draft_id |
269| Get attachment | GMAIL_GET_ATTACHMENT | message_id, attachment_id |
270| Search contacts | GMAIL_SEARCH_PEOPLE | query |
271| Get profile | GMAIL_GET_PROFILE | (none) |
272---
273*Powered by [Composio](https://composio.dev)*
274
275---
276
277**Source:** [`davepoon/buildwithclaude`](https://github.com/davepoon/buildwithclaude) → `plugins/all-skills/skills/gmail-automation/SKILL.md`