Skip to main content
Glama
owen-nash

Fastmail MCP Server

by owen-nash

bulk_move

Move multiple emails to a specified mailbox in one operation. Provide an array of email 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

  • The `bulkMove` method in `JmapClient` class that implements the core logic: fetches current mailboxIds for all emails, builds JMAP patches to remove all current mailboxes and add the target, then sends a single Email/set request to move all emails atomically.
    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.');
      }
    }
  • src/index.ts:887-905 (registration)
    The tool registration in the `ListToolsRequestSchema` handler: defines the 'bulk_move' tool with its name, description, and inputSchema (emailIds array + targetMailboxId string).
    {
      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'],
      },
    },
  • The tool call handler in the `CallToolRequestSchema` handler: extracts emailIds and targetMailboxId from args, validates them, and calls `client.bulkMove(emailIds, targetMailboxId)`.
    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`,
          },
        ],
      };
    }
Behavior2/5

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

No annotations provided, so description must bear full burden. It only states the action but does not disclose behavioral traits such as atomicity, error handling, permissions required, or side effects. The description is insufficient for a bulk operation.

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 short sentence, directly stating the function. It is concise and front-loaded without unnecessary words, though it could provide more context without losing conciseness.

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

Completeness2/5

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

Given two parameters with schema descriptions and no output schema, the description is minimal. For a bulk operation, it lacks details on return values, limits, error behavior, or any post-conditions. More context is needed for effective use.

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?

Input schema has 100% coverage with descriptions for both parameters, so baseline is 3. The description adds no additional meaning beyond the schema, hence score remains at 3.

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?

The description clearly states the action (move) and resources (multiple emails) and target (mailbox). It distinguishes from sibling bulk operations like bulk_delete and from singular move_email, though the bulk aspect is already implied by the name.

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 like move_email or bulk_delete. It does not mention suitable contexts, prerequisites, or when not to use it.

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/owen-nash/fastmail-mcp'

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