search_emails
Find emails in your Fastmail account by searching subject lines or message content. Use this tool to locate specific messages or conversations quickly.
Instructions
Search emails by subject or content
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Search query string | |
| limit | No | Maximum number of results (default: 20) |
Implementation Reference
- src/index.ts:736-772 (handler)The main handler for the 'search_emails' tool. It performs a JMAP Email/query with text filter and retrieves email details using Email/get, sorting by receivedAt descending.case 'search_emails': { const { query, limit = 20 } = args as any; if (!query) { throw new McpError(ErrorCode.InvalidParams, 'query is required'); } // For search, we'll use the Email/query method with a text filter const session = await client.getSession(); const request: JmapRequest = { using: ['urn:ietf:params:jmap:core', 'urn:ietf:params:jmap:mail'], methodCalls: [ ['Email/query', { accountId: session.accountId, filter: { text: query }, sort: [{ property: 'receivedAt', isAscending: false }], limit }, 'query'], ['Email/get', { accountId: session.accountId, '#ids': { resultOf: 'query', name: 'Email/query', path: '/ids' }, properties: ['id', 'subject', 'from', 'to', 'receivedAt', 'preview', 'hasAttachment'] }, 'emails'] ] }; const response = await client.makeRequest(request); const emails = response.methodResponses[1][1].list; return { content: [ { type: 'text', text: JSON.stringify(emails, null, 2), }, ], }; }
- src/index.ts:223-241 (schema)Tool schema definition for 'search_emails', including name, description, and input schema requiring a 'query' string and optional 'limit' number.{ name: 'search_emails', description: 'Search emails by subject or content', inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'Search query string', }, limit: { type: 'number', description: 'Maximum number of results (default: 20)', default: 20, }, }, required: ['query'], }, },
- src/index.ts:1139-1143 (registration)Registration of 'search_emails' in the list of available email functions in the check_function_availability tool.'list_mailboxes', 'list_emails', 'get_email', 'send_email', 'search_emails', 'get_recent_emails', 'mark_email_read', 'delete_email', 'move_email', 'get_email_attachments', 'download_attachment', 'advanced_search', 'get_thread', 'get_mailbox_stats', 'get_account_summary', 'bulk_mark_read', 'bulk_move', 'bulk_delete' ]