get_recent_emails
Retrieve recent emails from your Fastmail inbox to quickly view and manage your latest messages. Specify mailbox and limit to customize results.
Instructions
Get the most recent emails from inbox (like top-ten)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Number of recent emails to retrieve (default: 10, max: 50) | |
| mailboxName | No | Mailbox to search (default: inbox) | inbox |
Implementation Reference
- src/jmap-client.ts:300-333 (handler)Core handler function in JmapClient that implements the logic to fetch recent emails from a specified mailbox using JMAP Email/query and Email/get methods.async getRecentEmails(limit: number = 10, mailboxName: string = 'inbox'): Promise<any[]> { const session = await this.getSession(); // Find the specified mailbox (default to inbox) const mailboxes = await this.getMailboxes(); const targetMailbox = mailboxes.find(mb => mb.role === mailboxName.toLowerCase() || mb.name.toLowerCase().includes(mailboxName.toLowerCase()) ); if (!targetMailbox) { throw new Error(`Could not find mailbox: ${mailboxName}`); } const request: JmapRequest = { using: ['urn:ietf:params:jmap:core', 'urn:ietf:params:jmap:mail'], methodCalls: [ ['Email/query', { accountId: session.accountId, filter: { inMailbox: targetMailbox.id }, sort: [{ property: 'receivedAt', isAscending: false }], limit: Math.min(limit, 50) }, 'query'], ['Email/get', { accountId: session.accountId, '#ids': { resultOf: 'query', name: 'Email/query', path: '/ids' }, properties: ['id', 'subject', 'from', 'to', 'receivedAt', 'preview', 'hasAttachment', 'keywords'] }, 'emails'] ] }; const response = await this.makeRequest(request); return response.methodResponses[1][1].list; }
- src/index.ts:383-400 (schema)Input schema definition for the get_recent_emails tool, including parameters for limit and mailboxName.name: 'get_recent_emails', description: 'Get the most recent emails from inbox (like top-ten)', inputSchema: { type: 'object', properties: { limit: { type: 'number', description: 'Number of recent emails to retrieve (default: 10, max: 50)', default: 10, }, mailboxName: { type: 'string', description: 'Mailbox to search (default: inbox)', default: 'inbox', }, }, }, },
- src/index.ts:905-917 (registration)MCP server tool dispatch/registration case that extracts parameters, initializes the JmapClient, calls getRecentEmails, and returns the result as MCP content.case 'get_recent_emails': { const { limit = 10, mailboxName = 'inbox' } = args as any; const client = initializeClient(); const emails = await client.getRecentEmails(limit, mailboxName); return { content: [ { type: 'text', text: JSON.stringify(emails, null, 2), }, ], }; }