Automate Gmail tasks via Rube MCP (Composio): send/reply, search, labels, drafts, attachments. Always search tools first for current schemas.
Add this skill
npx mdskills install sickn33/gmail-automationComprehensive Gmail automation with clear workflows, parameter details, and extensive pitfall documentation
1---2name: gmail-automation3description: "Automate Gmail tasks via Rube MCP (Composio): send/reply, search, labels, drafts, attachments. Always search tools first for current schemas."4requires:5 mcp: [rube]6---78# Gmail Automation via Rube MCP910Automate Gmail operations through Composio's Gmail toolkit via Rube MCP.1112## Prerequisites1314- Rube MCP must be connected (RUBE_SEARCH_TOOLS available)15- Active Gmail connection via `RUBE_MANAGE_CONNECTIONS` with toolkit `gmail`16- Always call `RUBE_SEARCH_TOOLS` first to get current tool schemas1718## Setup1920**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.2122231. Verify Rube MCP is available by confirming `RUBE_SEARCH_TOOLS` responds242. Call `RUBE_MANAGE_CONNECTIONS` with toolkit `gmail`253. If connection is not ACTIVE, follow the returned auth link to complete Google OAuth264. Confirm connection status shows ACTIVE before running any workflows2728## Core Workflows2930### 1. Send an Email3132**When to use**: User wants to compose and send a new email3334**Tool sequence**:351. `GMAIL_SEARCH_PEOPLE` - Resolve contact name to email address [Optional]362. `GMAIL_SEND_EMAIL` - Send the email [Required]3738**Key parameters**:39- `recipient_email`: Email address or 'me' for self40- `subject`: Email subject line41- `body`: Email content (plain text or HTML)42- `is_html`: Must be `true` if body contains HTML markup43- `cc`/`bcc`: Arrays of email addresses44- `attachment`: Object with `{s3key, mimetype, name}` from prior download4546**Pitfalls**:47- At least one of `recipient_email`, `cc`, or `bcc` required48- At least one of `subject` or `body` required49- Attachment `mimetype` MUST contain '/' (e.g., 'application/pdf', not 'pdf')50- Total message size limit ~25MB after base64 encoding51- Use `from_email` only for verified aliases in Gmail 'Send mail as' settings5253### 2. Reply to a Thread5455**When to use**: User wants to reply to an existing email conversation5657**Tool sequence**:581. `GMAIL_FETCH_EMAILS` - Find the email/thread to reply to [Prerequisite]592. `GMAIL_REPLY_TO_THREAD` - Send reply within the thread [Required]6061**Key parameters**:62- `thread_id`: Hex string from FETCH_EMAILS (e.g., '169eefc8138e68ca')63- `message_body`: Reply content64- `recipient_email`: Reply recipient65- `is_html`: Set `true` for HTML content6667**Pitfalls**:68- `thread_id` must be hex string; prefixes like 'msg-f:' are auto-stripped69- Legacy Gmail web UI IDs (e.g., 'FMfcgz...') are NOT supported70- Subject is inherited from original thread; setting it creates a new thread instead71- Do NOT include subject parameter to stay within thread7273### 3. Search and Filter Emails7475**When to use**: User wants to find specific emails by sender, subject, date, label, etc.7677**Tool sequence**:781. `GMAIL_FETCH_EMAILS` - Search with Gmail query syntax [Required]792. `GMAIL_FETCH_MESSAGE_BY_MESSAGE_ID` - Get full message details for selected results [Optional]8081**Key parameters**:82- `query`: Gmail search syntax (from:, to:, subject:, is:unread, has:attachment, after:YYYY/MM/DD, before:YYYY/MM/DD)83- `max_results`: 1-500 messages per page84- `label_ids`: System IDs like 'INBOX', 'UNREAD'85- `include_payload`: Set `true` to get full message content86- `ids_only`: Set `true` for just message IDs87- `page_token`: For pagination (from `nextPageToken`)8889**Pitfalls**:90- Returns max ~500 per page; follow `nextPageToken` via `page_token` until absent91- `resultSizeEstimate` is approximate, not exact count92- Use 'is:' for states (is:unread, is:snoozed, is:starred)93- Use 'label:' ONLY for user-created labels94- Common mistake: 'label:snoozed' is WRONG — use 'is:snoozed'95- `include_payload=true` on broad searches creates huge responses; default to metadata96- Custom labels require label ID (e.g., 'Label_123'), NOT label name9798### 4. Manage Labels99100**When to use**: User wants to create, modify, or organize labels101102**Tool sequence**:1031. `GMAIL_LIST_LABELS` - List all labels to find IDs and detect conflicts [Required]1042. `GMAIL_CREATE_LABEL` - Create a new label [Optional]1053. `GMAIL_PATCH_LABEL` - Rename or change label colors/visibility [Optional]1064. `GMAIL_DELETE_LABEL` - Delete a user-created label (irreversible) [Optional]107108**Key parameters**:109- `label_name`: Max 225 chars, no commas, '/' for nesting (e.g., 'Work/Projects')110- `background_color`/`text_color`: Hex values from Gmail's predefined palette111- `id`: Label ID for PATCH/DELETE operations112113**Pitfalls**:114- 400/409 error if name is blank, duplicate, or reserved (INBOX, SPAM, CATEGORY_*)115- Color specs must use Gmail's predefined palette of 102 hex values116- DELETE is permanent and removes label from all messages117- Cannot delete system labels (INBOX, SENT, DRAFT, etc.)118119### 5. Apply/Remove Labels on Messages120121**When to use**: User wants to label, archive, or mark emails as read/unread122123**Tool sequence**:1241. `GMAIL_LIST_LABELS` - Get label IDs for custom labels [Prerequisite]1252. `GMAIL_FETCH_EMAILS` - Find target messages [Prerequisite]1263. `GMAIL_BATCH_MODIFY_MESSAGES` - Bulk add/remove labels (up to 1000 messages) [Required]1274. `GMAIL_ADD_LABEL_TO_EMAIL` - Single-message label changes [Fallback]128129**Key parameters**:130- `messageIds`: Array of message IDs (max 1000)131- `addLabelIds`: Array of label IDs to add132- `removeLabelIds`: Array of label IDs to remove133- `message_id`: 15-16 char hex string for single operations134135**Pitfalls**:136- Max 1000 messageIds per BATCH call; chunk larger sets137- Use 'CATEGORY_UPDATES' not 'UPDATES'; full prefix required for category labels138- SENT, DRAFT, CHAT are immutable — cannot be added/removed139- To mark as read: REMOVE 'UNREAD'. To archive: REMOVE 'INBOX'140- `message_id` must be 15-16 char hex, NOT UUIDs or web UI IDs141142### 6. Handle Drafts and Attachments143144**When to use**: User wants to create, edit, or send email drafts, possibly with attachments145146**Tool sequence**:1471. `GMAIL_CREATE_EMAIL_DRAFT` - Create a new draft [Required]1482. `GMAIL_UPDATE_DRAFT` - Edit draft content [Optional]1493. `GMAIL_LIST_DRAFTS` - List existing drafts [Optional]1504. `GMAIL_SEND_DRAFT` - Send a draft (requires explicit user approval) [Optional]1515. `GMAIL_GET_ATTACHMENT` - Download attachment from existing message [Optional]152153**Key parameters**:154- `recipient_email`: Draft recipient155- `subject`: Draft subject (omit for reply drafts to stay in thread)156- `body`: Draft content157- `is_html`: Set `true` for HTML content158- `attachment`: Object with `{s3key, mimetype, name}`159- `thread_id`: For reply drafts (leave subject empty to stay in thread)160161**Pitfalls**:162- Response includes `data.id` (draft_id) AND `data.message.id`; use `data.id` for draft operations163- Setting subject on a thread reply draft creates a NEW thread instead164- Attachment capped at ~25MB; base64 overhead can push near-limit files over165- UPDATE_DRAFT replaces entire content, not patches; include all fields you want to keep166- HTTP 429 on bulk draft creation; use exponential backoff167168## Common Patterns169170### ID Resolution171172**Label name → Label ID**:173```1741. Call GMAIL_LIST_LABELS1752. Find label by name in response1763. Extract id field (e.g., 'Label_123')177```178179**Contact name → Email**:180```1811. Call GMAIL_SEARCH_PEOPLE with query=contact_name1822. Extract emailAddresses from response183```184185**Thread ID from search**:186```1871. Call GMAIL_FETCH_EMAILS or GMAIL_LIST_THREADS1882. Extract threadId (15-16 char hex string)189```190191### Pagination192193- Set `max_results` up to 500 per page194- Check response for `nextPageToken`195- Pass token as `page_token` in next request196- Continue until `nextPageToken` is absent or empty string197- `resultSizeEstimate` is approximate, not exact198199### Gmail Query Syntax200201**Operators**:202- `from:sender@example.com` - Emails from sender203- `to:recipient@example.com` - Emails to recipient204- `subject:"exact phrase"` - Subject contains exact phrase205- `is:unread` - Unread messages206- `is:starred` - Starred messages207- `is:snoozed` - Snoozed messages208- `has:attachment` - Has attachments209- `after:2024/01/01` - After date (YYYY/MM/DD)210- `before:2024/12/31` - Before date211- `label:custom_label` - User-created label (use label ID)212- `in:sent` - In sent folder213- `category:primary` - Primary category214215**Combinators**:216- `AND` - Both conditions (default)217- `OR` - Either condition218- `NOT` - Exclude condition219- `()` - Group conditions220221**Examples**:222- `from:boss@company.com is:unread` - Unread emails from boss223- `subject:invoice has:attachment after:2024/01/01` - Invoices with attachments this year224- `(from:alice OR from:bob) is:starred` - Starred emails from Alice or Bob225226## Known Pitfalls227228**ID Formats**:229- Custom label operations require label IDs (e.g., 'Label_123'), not display names230- Always call LIST_LABELS first to resolve names to IDs231- Message IDs are 15-16 char hex strings232- Do NOT use UUIDs, web UI IDs, or 'thread-f:' prefixes233234**Query Syntax**:235- Use 'is:' for states (unread, snoozed, starred)236- Use 'label:' ONLY for user-created labels237- System labels use 'is:' or 'in:' (e.g., 'is:sent', 'in:inbox')238239**Rate Limits**:240- BATCH_MODIFY_MESSAGES max 1000 messages per call241- Heavy use triggers 403/429 rate limits242- Implement exponential backoff for bulk operations243244**Response Parsing**:245- Response data may be nested under `data_preview` or `data.messages`246- Parse defensively with fallbacks247- Timestamp `messageTimestamp` uses RFC3339 with 'Z' suffix248- Normalize to '+00:00' for parsing if needed249250**Attachments**:251- Attachment `s3key` from prior download may expire252- Use promptly after retrieval253- Mimetype must include '/' separator254255## Quick Reference256257| Task | Tool Slug | Key Params |258|------|-----------|------------|259| Send email | GMAIL_SEND_EMAIL | recipient_email, subject, body, is_html |260| Reply to thread | GMAIL_REPLY_TO_THREAD | thread_id, message_body, recipient_email |261| Search emails | GMAIL_FETCH_EMAILS | query, max_results, label_ids, page_token |262| Get message details | GMAIL_FETCH_MESSAGE_BY_MESSAGE_ID | message_id |263| List labels | GMAIL_LIST_LABELS | (none) |264| Create label | GMAIL_CREATE_LABEL | label_name, background_color, text_color |265| Modify labels bulk | GMAIL_BATCH_MODIFY_MESSAGES | messageIds, addLabelIds, removeLabelIds |266| Create draft | GMAIL_CREATE_EMAIL_DRAFT | recipient_email, subject, body, thread_id |267| Send draft | GMAIL_SEND_DRAFT | draft_id |268| Get attachment | GMAIL_GET_ATTACHMENT | message_id, attachment_id |269| Search contacts | GMAIL_SEARCH_PEOPLE | query |270| Get profile | GMAIL_GET_PROFILE | (none) |
Full transparency — inspect the skill content before installing.