get_mailbox_stats
Retrieve unread count and total email statistics for a specific mailbox or all mailboxes.
Instructions
Get statistics for a mailbox (unread count, total emails, etc.)
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| mailboxId | No | ID of the mailbox (optional, defaults to all mailboxes) |
Implementation Reference
- src/jmap-client.ts:1326-1357 (handler)The `getMailboxStats` method on JmapClient that executes the tool logic. If a mailboxId is provided, it fetches stats for that specific mailbox via JMAP Mailbox/get; otherwise, it calls getMailboxes() and returns stats for all mailboxes (id, name, role, totalEmails, unreadEmails, totalThreads, unreadThreads).
async getMailboxStats(mailboxId?: string): Promise<any> { const session = await this.getSession(); if (mailboxId) { // Get stats for specific mailbox const request: JmapRequest = { using: ['urn:ietf:params:jmap:core', 'urn:ietf:params:jmap:mail'], methodCalls: [ ['Mailbox/get', { accountId: session.accountId, ids: [mailboxId], properties: ['id', 'name', 'role', 'totalEmails', 'unreadEmails', 'totalThreads', 'unreadThreads'] }, 'mailbox'] ] }; const response = await this.makeRequest(request); return this.getListResult(response, 0)[0]; } else { // Get stats for all mailboxes const mailboxes = await this.getMailboxes(); return mailboxes.map(mb => ({ id: mb.id, name: mb.name, role: mb.role, totalEmails: mb.totalEmails || 0, unreadEmails: mb.unreadEmails || 0, totalThreads: mb.totalThreads || 0, unreadThreads: mb.unreadThreads || 0 })); } } - src/index.ts:823-835 (schema)Input schema registration for the 'get_mailbox_stats' tool, defining its description and optional mailboxId parameter.
{ name: 'get_mailbox_stats', description: 'Get statistics for a mailbox (unread count, total emails, etc.)', inputSchema: { type: 'object', properties: { mailboxId: { type: 'string', description: 'ID of the mailbox (optional, defaults to all mailboxes)', }, }, }, }, - src/index.ts:1609-1621 (handler)The call handler dispatch for 'get_mailbox_stats'. Extracts mailboxId from args, calls client.getMailboxStats(mailboxId), and returns the result as JSON.
case 'get_mailbox_stats': { const { mailboxId } = args as any; const client = initializeClient(); const stats = await client.getMailboxStats(mailboxId); return { content: [ { type: 'text', text: JSON.stringify(stats, null, 2), }, ], }; } - src/index.ts:1758-1759 (registration)References 'get_mailbox_stats' in the check_function_availability listing to confirm it is a registered tool name.
'get_mailbox_stats', 'get_account_summary', 'bulk_mark_read', 'bulk_pin', 'bulk_move', 'bulk_delete', 'add_labels', 'remove_labels', 'bulk_add_labels', 'bulk_remove_labels'