Skip to main content
Glama
MadLlama25

Fastmail MCP Server

by MadLlama25

bulk_move

Move multiple emails to a specified mailbox using their IDs and the target mailbox ID.

Instructions

Move multiple emails to a mailbox

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
emailIdsYesArray of email IDs to move
targetMailboxIdYesID of target mailbox

Implementation Reference

  • Schema registration for the 'bulk_move' tool. Defines input parameters: emailIds (array of strings, required) and targetMailboxId (string, required).
    name: 'bulk_move',
    description: 'Move multiple emails to a mailbox',
    inputSchema: {
      type: 'object',
      properties: {
        emailIds: {
          type: 'array',
          items: { type: 'string' },
          description: 'Array of email IDs to move',
        },
        targetMailboxId: {
          type: 'string',
          description: 'ID of target mailbox',
        },
      },
      required: ['emailIds', 'targetMailboxId'],
    },
  • Handler for the 'bulk_move' tool call. Validates arguments (emailIds array and targetMailboxId), then delegates to client.bulkMove(). Returns success message with count of moved emails.
    case 'bulk_move': {
      const { emailIds, targetMailboxId } = args as any;
      if (!emailIds || !Array.isArray(emailIds) || emailIds.length === 0) {
        throw new McpError(ErrorCode.InvalidParams, 'emailIds array is required and must not be empty');
      }
      if (!targetMailboxId) {
        throw new McpError(ErrorCode.InvalidParams, 'targetMailboxId is required');
      }
      const client = initializeClient();
      await client.bulkMove(emailIds, targetMailboxId);
      return {
        content: [
          {
            type: 'text',
            text: `${emailIds.length} emails moved successfully`,
          },
        ],
      };
    }
  • Core implementation of bulkMove() in JmapClient. Fetches current mailboxIds for all emails, builds JMAP patches to remove from current mailboxes and add to target, and sends a single Email/set JMAP request.
    async bulkMove(emailIds: string[], targetMailboxId: string): Promise<void> {
      const session = await this.getSession();
    
      // Fetch current mailboxIds for all emails to build proper JMAP patches
      const getRequest: JmapRequest = {
        using: ['urn:ietf:params:jmap:core', 'urn:ietf:params:jmap:mail'],
        methodCalls: [
          ['Email/get', {
            accountId: session.accountId,
            ids: emailIds,
            properties: ['id', 'mailboxIds']
          }, 'getEmails']
        ]
      };
      const getResponse = await this.makeRequest(getRequest);
      const emails: any[] = this.getListResult(getResponse, 0);
      const mailboxMap: Record<string, Record<string, boolean>> = {};
      emails.forEach((e: any) => { mailboxMap[e.id] = e.mailboxIds || {}; });
    
      // Build patch per email: remove all current mailboxes, add target
      const updates: Record<string, any> = {};
      emailIds.forEach(id => {
        const patch: Record<string, boolean | null> = {};
        for (const mbId of Object.keys(mailboxMap[id] || {})) {
          patch[`mailboxIds/${mbId}`] = null;
        }
        patch[`mailboxIds/${targetMailboxId}`] = true;
        updates[id] = patch;
      });
    
      const request: JmapRequest = {
        using: ['urn:ietf:params:jmap:core', 'urn:ietf:params:jmap:mail'],
        methodCalls: [
          ['Email/set', {
            accountId: session.accountId,
            update: updates
          }, 'bulkMove']
        ]
      };
    
      const response = await this.makeRequest(request);
      const result = this.getMethodResult(response, 0);
    
      if (result.notUpdated && Object.keys(result.notUpdated).length > 0) {
        throw new Error('Failed to move some emails.');
      }
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, and the description does not disclose potential behavioral traits like authentication needs, whether the operation is destructive, or error handling for batch operations (e.g., partial failures).

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, concise sentence that is front-loaded. While efficient, it lacks structural elements like prerequisites or return values, which could be added without increasing verbosity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple bulk operation with no output schema and no annotations, the description is minimally adequate. However, it fails to address batch-specific considerations such as atomicity limits or error handling, leaving gaps for an AI agent.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the schema already documents both parameters. The description adds no additional meaning beyond what is in the schema, meeting the baseline without extra value.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

Description clearly states action (move), object (multiple emails), and destination (a mailbox). However, it does not explicitly distinguish from sibling tools like 'move_email' or 'bulk_delete', relying on the name for differentiation.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use this tool versus alternatives such as 'move_email' for single moves or 'bulk_delete' for deletion. The description offers no context for appropriate use cases.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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