Skip to main content
Glama
as-j

Fastmail MCP Server

by as-j

bulk_remove_labels

Idempotent

Remove labels from multiple emails at once by specifying email IDs and mailbox IDs. Batch untag messages without deleting or moving them.

Instructions

Remove labels from multiple emails in one call. Use when the user wants to untag a batch of specific messages together. Do not use to delete or move email.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
emailIdsYesArray of email IDs to remove labels from
mailboxIdsYesArray of mailbox IDs to remove as labels

Implementation Reference

  • The actual implementation of bulk_remove_labels. Sends a JMAP Email/set request with patch objects that null out the mailboxIds for each emailId to remove labels. Throws if some emails were not updated.
    async bulkRemoveLabels(emailIds: string[], mailboxIds: string[]): Promise<void> {
      const session = await this.getSession();
    
      // Build patch object to remove specific mailboxIds
      const patch: Record<string, any> = {};
      mailboxIds.forEach(mailboxId => {
        patch[`mailboxIds/${mailboxId}`] = null;
      });
    
      const updates: Record<string, any> = {};
      emailIds.forEach(id => {
        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
          }, 'bulkRemoveLabels']
        ]
      };
    
      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 remove labels from some emails.');
      }
    }
  • The tool handler registration in the MCP server. Receives args, validates them (emailIds and mailboxIds must be non-empty arrays), then delegates to client.bulkRemoveLabels().
    case 'bulk_remove_labels': {
      const { emailIds: rawEmailIdsBRL, mailboxIds: rawMailboxIdsBRL } = args as any;
      const emailIds = normalizeStringArray(rawEmailIdsBRL);
      const mailboxIds = normalizeStringArray(rawMailboxIdsBRL);
      if (emailIds.length === 0) throw new McpError(ErrorCode.InvalidParams, 'emailIds array is required and must not be empty');
      if (mailboxIds.length === 0) throw new McpError(ErrorCode.InvalidParams, 'mailboxIds array is required and must not be empty');
      await client.bulkRemoveLabels(emailIds, mailboxIds);
      return { content: [{ type: 'text', text: `Labels removed successfully from ${emailIds.length} emails` }] };
    }
  • The tool definition/schema for bulk_remove_labels. Describes the tool name 'bulk_remove_labels', its description, input properties (emailIds and mailboxIds arrays), and required fields.
    writeTool(
      'bulk_remove_labels',
      'Bulk Remove Labels',
      description(
        'Remove labels from multiple emails in one call.',
        'Use when the user wants to untag a batch of specific messages together.',
        'Do not use to delete or move email.',
      ),
      {
        type: 'object',
        properties: {
          emailIds: {
            ...stringArraySchema,
            description: 'Array of email IDs to remove labels from',
          },
          mailboxIds: {
            ...stringArraySchema,
            description: 'Array of mailbox IDs to remove as labels',
          },
        },
        required: ['emailIds', 'mailboxIds'],
      },
      { idempotentHint: true },
    ),
Behavior4/5

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

Annotations already indicate idempotent and non-destructive behavior; description confirms the operation without contradicting annotations, though it doesn't elaborate on edge cases (e.g., non-existent labels).

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

Conciseness5/5

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

Three concise sentences, each with a distinct purpose: action, usage, and exclusion. No unnecessary words.

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

Completeness4/5

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

Covers core purpose and usage constraints. For a simple operation with 2 parameters and annotations, it is adequate, though could mention return behavior.

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 covers both parameters completely (100% description coverage), so the description adds no new semantic value beyond reinforcing that it operates on multiple emails.

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

Purpose5/5

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

The description clearly states the action ('remove labels') and scope ('multiple emails'), distinguishing it from siblings like 'remove_labels' (single) and 'bulk_add_labels'.

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

Usage Guidelines5/5

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

Explicitly states when to use ('untag a batch') and when not to use ('do not use to delete or move email'), providing clear direction.

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/as-j/fastmail-mcp'

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