bulk_pin
Pin or unpin multiple emails at once to organize your inbox efficiently.
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/jmap-client.ts:1415-1441 (handler)The `bulkPinEmails` method in JmapClient that executes the actual JMAP API call to pin/unpin multiple emails. It builds an `Email/set` request with keyword/$flagged updates for each email ID.
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.'); } } - src/index.ts:1656-1671 (handler)The 'bulk_pin' case in the CallToolRequestSchema handler. Extracts emailIds and pinned from args, validates, then calls client.bulkPinEmails().
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/index.ts:868-886 (schema)The tool registration with inputSchema for 'bulk_pin'. Defines emailIds (array of strings, required) and pinned (boolean, default true).
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:867-886 (registration)Registration of the 'bulk_pin' tool in the ListToolsRequestSchema handler.
{ 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'], }, },