Search email
search_messagesSearches email in one mailbox (accountId) or in all mailboxes at once (no accountId). Without folder, searches the whole mailbox: inbox, archive, sent and user folders (not spam, trash or drafts; on Gmail, All Mail). No age limit. Filters can be combined: full text (query), subject only (subject), sender (from), recipient (to), date range (since, before), unread only. Results are newest first, or oldest first with order=oldest. limit applies PER MAILBOX. Returns summaries (account, folder, uid, date, sender, subject; on Gmail accounts also labels (INBOX = in the inbox, ARCHIVED = archived, SENT, IMPORTANT, user labels: Gmail is searched through All Mail, so folder does not tell where the message is) and webUrl, a link that opens the message in Gmail) and, per mailbox, matches and truncated; when truncated, more messages exist and are fetched with before = nextBefore (or since = nextSince with order=oldest). Full content is read with get_message. Unreachable mailboxes are listed in failures. Does not mark anything as read.
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "search_messages"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| to | No | Recipient address or name. | |
| from | No | Sender address or name. | |
| limit | No | Maximum number of messages PER MAILBOX (at most 50). | |
| order | No | newest (default): most recent first. oldest: oldest first. | newest |
| query | No | Text searched everywhere (subject, body, headers). | |
| since | No | Messages dated on or after this day (or instant). | |
| before | No | Messages dated strictly before this day (or instant). | |
| folder | No | A specific folder (INBOX, Archive, "[Gmail]/Sent Mail"...). Omit to search the whole mailbox. | |
| subject | No | Text searched in the subject only. | |
| accountId | No | A single mailbox. Omit to search all mailboxes. | |
| unreadOnly | No | Unread messages only. |