Skip to main content
Glama
MadLlama25

Fastmail MCP Server

by MadLlama25

get_email_attachments

Retrieve a list of file attachments from a specific Fastmail email using its unique identifier.

Instructions

Get list of attachments for an email

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
emailIdYesID of the email

Implementation Reference

  • Core handler function that executes the tool logic by making a JMAP Email/get request to retrieve attachments for the specified email ID.
    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 = response.methodResponses[0][1].list[0];
      return email?.attachments || [];
    }
  • Defines the input schema and metadata for the MCP tool, specifying that it requires an 'emailId' string parameter.
    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:970-985 (registration)
    MCP server request handler case that dispatches the tool call, validates input, invokes the JmapClient handler, and formats the response.
    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),
          },
        ],
      };
    }
  • src/index.ts:452-465 (registration)
    Tool registration entry in the MCP server's tools list, including name, description, and schema.
    {
      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'],
      },
    },

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/MadLlama25/fastmail-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server