bulk_mark_read
Mark multiple emails as read or unread in Fastmail. Provide a list of email IDs and specify true to mark as read, false to mark as unread.
Instructions
Mark multiple emails as read/unread
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| emailIds | Yes | Array of email IDs to mark | |
| read | No | true to mark as read, false as unread |
Implementation Reference
- src/index.ts:844-863 (registration)Tool 'bulk_mark_read' is registered in the ListTools handler with inputSchema accepting emailIds (array) and read (boolean, default true).
{ name: 'bulk_mark_read', description: 'Mark multiple emails as read/unread', inputSchema: { type: 'object', properties: { emailIds: { type: 'array', items: { type: 'string' }, description: 'Array of email IDs to mark', }, read: { type: 'boolean', description: 'true to mark as read, false as unread', default: true, }, }, required: ['emailIds'], }, }, - src/index.ts:1636-1651 (handler)The CallTool handler for 'bulk_mark_read' validates the emailIds array argument, then delegates to client.bulkMarkRead(emailIds, read).
case 'bulk_mark_read': { const { emailIds, read = true } = args as any; if (!emailIds || !Array.isArray(emailIds) || emailIds.length === 0) { throw new McpError(ErrorCode.InvalidParams, 'emailIds array is required and must not be empty'); } const client = initializeClient(); await client.bulkMarkRead(emailIds, read); return { content: [ { type: 'text', text: `${emailIds.length} emails ${read ? 'marked as read' : 'marked as unread'} successfully`, }, ], }; } - src/jmap-client.ts:1387-1413 (helper)The actual JMAP logic: builds an Email/set update with keywords/$seen for each email ID, sends the request, and throws on any notUpdated errors.
async bulkMarkRead(emailIds: string[], read: boolean = true): Promise<void> { const session = await this.getSession(); const updates: Record<string, any> = {}; emailIds.forEach(id => { updates[id] = read ? { 'keywords/$seen': true } : { 'keywords/$seen': null }; }); const request: JmapRequest = { using: ['urn:ietf:params:jmap:core', 'urn:ietf:params:jmap:mail'], methodCalls: [ ['Email/set', { accountId: session.accountId, update: updates }, 'bulkUpdate'] ] }; const response = await this.makeRequest(request); const result = this.getMethodResult(response, 0); if (result.notUpdated && Object.keys(result.notUpdated).length > 0) { throw new Error('Failed to update some emails.'); } }