get_email
Retrieve a specific email from Fastmail using its ID. Access the full email content including headers, body, and attachments for review or processing.
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:164-177 (registration)Tool 'get_email' is registered in the ListToolsRequestSchema handler with its name, description, and inputSchema requiring an emailId string parameter.
{ 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:1023-1037 (handler)The CallToolRequestSchema handler for 'get_email' extracts the emailId from args, validates it, and calls client.getEmailById(emailId).
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 in JmapClient executes the actual JMAP Email/get request to fetch a single email by ID, requesting properties like subject, from, to, textBody, htmlBody, attachments, etc.
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; }