get_email_attachments
Retrieve a list of all attachments associated with an email using its unique ID.
Instructions
Get list of attachments for an email
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| emailId | Yes | ID of the email |
Implementation Reference
- src/jmap-client.ts:1006-1023 (handler)The handler that executes the 'get_email_attachments' tool logic. Makes a JMAP Email/get call requesting only the 'attachments' property for the given email ID and returns the attachments array.
async getEmailAttachments(emailId: 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: [emailId], properties: ['attachments'] }, 'getAttachments'] ] }; const response = await this.makeRequest(request); const email = this.getListResult(response, 0)[0]; return email?.attachments || []; } - src/index.ts:716-728 (registration)Tool registration with name, description, and input schema in the ListToolsRequestSchema handler.
name: 'get_email_attachments', description: 'Get list of attachments for an email', inputSchema: { type: 'object', properties: { emailId: { type: 'string', description: 'ID of the email', }, }, required: ['emailId'], }, }, - src/index.ts:1512-1527 (handler)The CallToolRequestSchema case handler that delegates to client.getEmailAttachments() and returns the result.
case 'get_email_attachments': { const { emailId } = args as any; if (!emailId) { throw new McpError(ErrorCode.InvalidParams, 'emailId is required'); } const client = initializeClient(); const attachments = await client.getEmailAttachments(emailId); return { content: [ { type: 'text', text: JSON.stringify(attachments, null, 2), }, ], }; }