Skip to main content
Glama
MadLlama25

Fastmail MCP Server

by MadLlama25

bulk_add_labels

Add labels to multiple emails in one action by providing email IDs and mailbox IDs for efficient email categorization.

Instructions

Add labels to multiple emails simultaneously

Input Schema

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

Implementation Reference

  • src/index.ts:918-937 (registration)
    Tool registration for 'bulk_add_labels' in the ListTools handler, defining the name, description, and inputSchema (accepts emailIds and mailboxIds arrays).
    {
      name: 'bulk_add_labels',
      description: 'Add labels to multiple emails simultaneously',
      inputSchema: {
        type: 'object',
        properties: {
          emailIds: {
            type: 'array',
            items: { type: 'string' },
            description: 'Array of email IDs to add labels to',
          },
          mailboxIds: {
            type: 'array',
            items: { type: 'string' },
            description: 'Array of mailbox IDs to add as labels',
          },
        },
        required: ['emailIds', 'mailboxIds'],
      },
    },
  • Handler for 'bulk_add_labels' tool call. Validates emailIds and mailboxIds arrays, then delegates to client.bulkAddLabels(emailIds, mailboxIds). Returns success message with count.
    case 'bulk_add_labels': {
      const { emailIds, mailboxIds } = 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 (!mailboxIds || !Array.isArray(mailboxIds) || mailboxIds.length === 0) {
        throw new McpError(ErrorCode.InvalidParams, 'mailboxIds array is required and must not be empty');
      }
      const client = initializeClient();
      await client.bulkAddLabels(emailIds, mailboxIds);
      return {
        content: [
          {
            type: 'text',
            text: `Labels added successfully to ${emailIds.length} emails`,
          },
        ],
      };
    }
  • Core implementation of bulkAddLabels on JmapClient. Builds a JMAP patch to add mailboxId+ true, applies it to all emailIds in a single Email/set call. Throws if any updates fail.
    async bulkAddLabels(emailIds: string[], mailboxIds: string[]): Promise<void> {
      const session = await this.getSession();
    
      // Build patch object to add specific mailboxIds
      const patch: Record<string, any> = {};
      mailboxIds.forEach(mailboxId => {
        patch[`mailboxIds/${mailboxId}`] = true;
      });
    
      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
          }, 'bulkAddLabels']
        ]
      };
    
      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 add labels to some emails.');
      }
    }
Behavior2/5

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

No annotations are provided, and the description fails to disclose critical behavioral traits such as error handling, idempotency, or whether the operation is atomic. For a bulk mutation tool, this is insufficient.

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 with no waste, but could be expanded slightly to include key usage 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 the lack of output schema and annotations, the description is too sparse. It omits important details for a bulk operation, such as batch size limits, behavior on partial failures, or asynchronous nature.

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?

The input schema has 100% description coverage for both parameters, so the description adds no additional meaning beyond the schema. Baseline 3 applies.

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 verb (add), resource (labels), and scope (multiple emails simultaneously), distinguishing it from the singular 'add_labels' sibling.

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

Usage Guidelines3/5

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

The description implies usage for batch label additions but provides no explicit guidance on when to use this vs. alternatives like 'add_labels', nor any exclusions or prerequisites.

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