bulk_pin
Pin or unpin multiple emails at once in Fastmail by providing an array of email IDs and a pinned flag. Simplify inbox organization by applying pin status to many messages simultaneously.
Instructions
Pin or unpin multiple emails
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| emailIds | Yes | Array of email IDs to pin/unpin | |
| pinned | No | true to pin, false to unpin |
Implementation Reference
- src/index.ts:865-883 (schema)Schema/registration for the 'bulk_pin' tool: defines input schema with emailIds array and pinned boolean.
name: 'bulk_pin', description: 'Pin or unpin multiple emails', inputSchema: { type: 'object', properties: { emailIds: { type: 'array', items: { type: 'string' }, description: 'Array of email IDs to pin/unpin', }, pinned: { type: 'boolean', description: 'true to pin, false to unpin', default: true, }, }, required: ['emailIds'], }, }, - src/index.ts:864-883 (registration)Tool registration in ListToolsRequestSchema: declares the 'bulk_pin' tool name, description, and inputSchema.
{ name: 'bulk_pin', description: 'Pin or unpin multiple emails', inputSchema: { type: 'object', properties: { emailIds: { type: 'array', items: { type: 'string' }, description: 'Array of email IDs to pin/unpin', }, pinned: { type: 'boolean', description: 'true to pin, false to unpin', default: true, }, }, required: ['emailIds'], }, }, - src/index.ts:1653-1668 (handler)Handler for 'bulk_pin' in CallToolRequestSchema switch statement: validates emailIds, calls client.bulkPinEmails(), returns success message.
case 'bulk_pin': { const { emailIds, pinned = 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.bulkPinEmails(emailIds, pinned); return { content: [ { type: 'text', text: `${emailIds.length} emails ${pinned ? 'pinned' : 'unpinned'} successfully`, }, ], }; } - src/jmap-client.ts:1415-1441 (helper)Actual implementation of bulkPinEmails() in JmapClient: builds Email/set update with $flagged keyword for each emailId, sends JMAP request.
async bulkPinEmails(emailIds: string[], pinned: boolean = true): Promise<void> { const session = await this.getSession(); const updates: Record<string, any> = {}; emailIds.forEach(id => { updates[id] = pinned ? { 'keywords/$flagged': true } : { 'keywords/$flagged': null }; }); const request: JmapRequest = { using: ['urn:ietf:params:jmap:core', 'urn:ietf:params:jmap:mail'], methodCalls: [ ['Email/set', { accountId: session.accountId, update: updates }, 'bulkFlag'] ] }; 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 pin/unpin some emails.'); } }