search_emails
Search emails across inboxes by keyword, filtering by sender, date, attachments, or direction to find specific messages.
Instructions
Search emails across all inboxes by keyword. Matches against subject, sender address, and body preview. Optionally scope to a single inbox or filter by sender, direction, date, or attachments.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Search query (e.g. "invoice", "verification code") | |
| inbox_id | No | Scope search to a specific inbox ID | |
| from | No | Filter by sender address (partial match) | |
| direction | No | Filter by email direction | |
| since | No | Only emails after this ISO 8601 date | |
| until | No | Only emails before this ISO 8601 date | |
| has_attachments | No | Filter by attachment presence | |
| limit | No | Max results (1-50, default 20) |
Implementation Reference
- src/index.ts:242-257 (handler)The handler function that executes the search_emails tool by calling the LobsterMail client's searchEmails method.
}, async ({ query, inbox_id, from, direction, since, until, has_attachments, limit }) => { const lm = await getClient(); const results = await lm.searchEmails({ q: query, inboxId: inbox_id, from, direction, since, until, hasAttachments: has_attachments, limit, }); if (results.data.length === 0) { return { content: [{ type: 'text' as const, text: `No emails found matching "${query}".` }], - src/index.ts:226-241 (registration)Registration and schema definition for the search_emails tool.
server.registerTool('search_emails', { title: 'Search Emails', description: 'Search emails across all inboxes by keyword. ' + 'Matches against subject, sender address, and body preview. ' + 'Optionally scope to a single inbox or filter by sender, direction, date, or attachments.', inputSchema: { query: z.string().describe('Search query (e.g. "invoice", "verification code")'), inbox_id: z.string().optional().describe('Scope search to a specific inbox ID'), from: z.string().optional().describe('Filter by sender address (partial match)'), direction: z.enum(['inbound', 'outbound']).optional().describe('Filter by email direction'), since: z.string().optional().describe('Only emails after this ISO 8601 date'), until: z.string().optional().describe('Only emails before this ISO 8601 date'), has_attachments: z.boolean().optional().describe('Filter by attachment presence'), limit: z.number().optional().describe('Max results (1-50, default 20)'), },