get_email
Retrieve the full details of an email using its unique identifier.
Instructions
Get a specific email by ID
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| emailId | Yes | ID of the email to retrieve |
Implementation Reference
- src/index.ts:167-180 (registration)Tool registration for 'get_email' in the ListToolsRequestSchema handler, defining name, description, and input schema requiring emailId.
{ name: 'get_email', description: 'Get a specific email by ID', inputSchema: { type: 'object', properties: { emailId: { type: 'string', description: 'ID of the email to retrieve', }, }, required: ['emailId'], }, }, - src/index.ts:168-179 (schema)Input schema for get_email: requires 'emailId' string property.
name: 'get_email', description: 'Get a specific email by ID', inputSchema: { type: 'object', properties: { emailId: { type: 'string', description: 'ID of the email to retrieve', }, }, required: ['emailId'], }, - src/index.ts:1026-1040 (handler)MCP tool handler for 'get_email'. Extracts emailId from args, validates it's present, calls client.getEmailById(emailId), and returns the result as JSON text.
case 'get_email': { const { emailId } = args as any; if (!emailId) { throw new McpError(ErrorCode.InvalidParams, 'emailId is required'); } const email = await client.getEmailById(emailId); return { content: [ { type: 'text', text: JSON.stringify(email, null, 2), }, ], }; } - src/jmap-client.ts:182-212 (helper)The getEmailById method on JmapClient. Sends a JMAP Email/get request with the given ID and requested properties (subject, from, to, cc, textBody, htmlBody, attachments, etc.), then returns the email object. Throws if not found.
async getEmailById(id: string): Promise<any> { const session = await this.getSession(); const request: JmapRequest = { using: ['urn:ietf:params:jmap:core', 'urn:ietf:params:jmap:mail'], methodCalls: [ ['Email/get', { accountId: session.accountId, ids: [id], properties: ['id', 'subject', 'from', 'to', 'cc', 'bcc', 'replyTo', 'receivedAt', 'textBody', 'htmlBody', 'attachments', 'bodyValues', 'messageId', 'threadId', 'inReplyTo', 'references', 'keywords', 'header:List-Unsubscribe:asURLs'], bodyProperties: ['partId', 'blobId', 'type', 'size'], fetchTextBodyValues: true, fetchHTMLBodyValues: true, }, 'email'] ] }; const response = await this.makeRequest(request); const result = this.getMethodResult(response, 0); if (result.notFound && result.notFound.includes(id)) { throw new Error(`Email with ID '${id}' not found`); } const email = result.list?.[0]; if (!email) { throw new Error(`Email with ID '${id}' not found or not accessible`); } return email; }