mark_email_read
Mark an email as read or unread by its ID, updating its read status in your inbox to manage notifications and unread counts.
Instructions
Mark an email as read or unread
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| emailId | Yes | ID of the email to mark | |
| read | No | true to mark as read, false to mark as unread |
Implementation Reference
- src/jmap-client.ts:750-774 (handler)The actual implementation of mark_email_read logic on the JmapClient class. Sends an Email/set JMAP call with keywords/$seen set to true (to mark read) or null (to mark unread).
async markEmailRead(emailId: string, read: boolean = true): Promise<void> { const session = await this.getSession(); const update: Record<string, any> = {}; update[emailId] = 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 }, 'updateEmail'] ] }; const response = await this.makeRequest(request); const result = this.getMethodResult(response, 0); if (result.notUpdated && result.notUpdated[emailId]) { throw new Error(`Failed to mark email as ${read ? 'read' : 'unread'}.`); } } - src/index.ts:607-625 (registration)Tool registration/schema definition for 'mark_email_read' in the MCP ListTools handler. Defines input schema with emailId (required) and read (optional boolean, default true).
{ name: 'mark_email_read', description: 'Mark an email as read or unread', inputSchema: { type: 'object', properties: { emailId: { type: 'string', description: 'ID of the email to mark', }, read: { type: 'boolean', description: 'true to mark as read, false to mark as unread', default: true, }, }, required: ['emailId'], }, }, - src/index.ts:1404-1419 (handler)MCP CallTool request handler for 'mark_email_read'. Extracts emailId and read args, validates emailId is present, calls client.markEmailRead(), and returns a success message.
case 'mark_email_read': { const { emailId, read = true } = args as any; if (!emailId) { throw new McpError(ErrorCode.InvalidParams, 'emailId is required'); } const client = initializeClient(); await client.markEmailRead(emailId, read); return { content: [ { type: 'text', text: `Email ${read ? 'marked as read' : 'marked as unread'} successfully`, }, ], }; }