Bulk Label Gmail Messages by Search Query
gmail_bulk_label_by_searchApply labels in bulk to Gmail messages found by search query. Add or remove labels on all matching emails at once, using Gmail's native search syntax.
Instructions
Search Gmail messages using a query and apply label changes to all matching messages.
Args:
query (string): Gmail search query (same syntax as Gmail search box)
add_label_ids (string[]): Label IDs to add to all matching messages
remove_label_ids (string[]): Label IDs to remove from all matching messages
max_results (number): Max messages to process (default: 20, max: 100)
Common query examples:
"from:sender@example.com" - emails from a sender
"subject:invoice" - emails with 'invoice' in subject
"is:unread" - unread emails
"after:2024/01/01 before:2024/12/31" - date range
Returns: Count of messages updated and their IDs.
Examples:
Use when: "Label all emails from compliance@firm.com as 'Compliance'"
Use when: "Archive all emails with subject 'Newsletter'"
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Gmail search query (e.g. 'from:user@example.com is:unread') | |
| max_results | No | Maximum number of messages to process (default: 20) | |
| add_label_ids | No | Label IDs to add to matching messages | |
| remove_label_ids | No | Label IDs to remove from matching messages |