test_bulk_operations
Test recent emails by safely marking them as read or unread. Use dry run to preview changes before applying.
Instructions
Test bulk operations by finding recent emails and performing safe operations (mark read/unread)
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| dryRun | No | If true, only shows what would be done without making changes (default: true) | |
| limit | No | Number of emails to test with (default: 3, max: 10) |
Implementation Reference
- src/index.ts:966-984 (registration)Tool registration: 'test_bulk_operations' declared in the ListToolsRequestSchema handler with its description and input schema (dryRun, limit).
{ name: 'test_bulk_operations', description: 'Test bulk operations by finding recent emails and performing safe operations (mark read/unread)', inputSchema: { type: 'object', properties: { dryRun: { type: 'boolean', description: 'If true, only shows what would be done without making changes (default: true)', default: true, }, limit: { type: 'number', description: 'Number of emails to test with (default: 3, max: 10)', default: 3, }, }, }, }, - src/index.ts:1811-1903 (handler)Tool handler: 'test_bulk_operations' case in the CallToolRequestSchema switch. Fetches recent emails, performs test bulk operations (mark read/unread) with dry-run support.
case 'test_bulk_operations': { const { dryRun = true, limit = 3 } = args as any; const client = initializeClient(); // Get some recent emails to test with const testLimit = Math.min(Math.max(limit, 1), 10); const emails = await client.getRecentEmails(testLimit, 'inbox'); if (emails.length === 0) { return { content: [ { type: 'text', text: 'No emails found for bulk operation testing. Try sending yourself a test email first.', }, ], }; } const emailIds = emails.slice(0, testLimit).map(email => email.id); const operations = [ { name: 'bulk_mark_read', description: `Mark ${emailIds.length} emails as read`, parameters: { emailIds, read: true } }, { name: 'bulk_mark_read (undo)', description: `Mark ${emailIds.length} emails as unread (undo previous)`, parameters: { emailIds, read: false } } ]; const results = { testEmails: emails.map(email => ({ id: email.id, subject: email.subject, from: email.from?.[0]?.email || 'unknown', receivedAt: email.receivedAt })), operations: [] as any[] }; if (dryRun) { results.operations = operations.map(op => ({ ...op, status: 'DRY RUN - Would execute but not actually performed', executed: false })); return { content: [ { type: 'text', text: `BULK OPERATIONS TEST (DRY RUN)\n\n${JSON.stringify(results, null, 2)}\n\nTo actually execute the test, set dryRun: false`, }, ], }; } else { // Execute the test operations for (const operation of operations) { try { await client.bulkMarkRead(operation.parameters.emailIds, operation.parameters.read); results.operations.push({ ...operation, status: 'SUCCESS', executed: true, timestamp: new Date().toISOString() }); // Small delay between operations await new Promise(resolve => setTimeout(resolve, 500)); } catch (error) { results.operations.push({ ...operation, status: 'FAILED', executed: false, error: error instanceof Error ? error.message : String(error), timestamp: new Date().toISOString() }); } } return { content: [ { type: 'text', text: `BULK OPERATIONS TEST (EXECUTED)\n\n${JSON.stringify(results, null, 2)}`, }, ], }; } }