query_emails
Search and filter emails across all mail folders using MongoDB-style query filters on subject, sender, recipients, dates, unread status, attachments, and other fields.
Instructions
Query emails using a MongoDB-style filter tree. Searches across ALL mail folders by default (Inbox, Sent, Archive, custom, etc.).
FIELDS (queryable): subject, from, from_name, to, cc, body (slow, requires allow_slow=true), received, sent, unread, has_attachments, importance, size.
OPERATORS: $eq $ne $in $nin $contains $not_contains $starts_with $ends_with $gte $lte $gt $lt $exists. COMBINATORS: $and $or $not.
DATES: ISO format ("2026-01-25" or "2026-01-25T14:30").
DEFAULT FIELDS in response: small queries (limit <= 20) include entry_id; larger scans omit it for token efficiency. Override with the 'fields' param.
PATTERN: For broad searches, scan first with limit > 20 (no entry_ids), then re-query narrowly to get entry_ids for the specific items you want to act on (read/reply/mark).
EXAMPLE filter: { "$and": [ { "from": { "$in": ["a@x.com","b@x.com"] } }, { "subject": { "$contains": "report" } }, { "received": { "$gte": "2026-01-01" } } ]}
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": "query_emails"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Max results (default 20, max 500) | |
| fields | No | Output fields. Default depends on limit. | |
| filter | No | Filter tree. Empty {} matches all. | |
| offset | No | Pagination offset | |
| account | No | Account email (substring match). Default: all accounts. | |
| order_by | No | Sort order | |
| allow_slow | No | Required to query the body field |