Skip to main content
Glama
owen-nash

Fastmail MCP Server

by owen-nash

add_labels

Append specified mailbox labels to an email without removing existing ones.

Instructions

Add labels (mailboxes) to an email without removing existing ones

Input Schema

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

Implementation Reference

  • The `addLabels` method on JmapClient: builds a JMAP patch to add specific mailboxIds to an email's mailboxIds field and sends an Email/set request. This is the core handler that executes the label-adding logic via the Fastmail JMAP API.
    async addLabels(emailId: 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 request: JmapRequest = {
        using: ['urn:ietf:params:jmap:core', 'urn:ietf:params:jmap:mail'],
        methodCalls: [
          ['Email/set', {
            accountId: session.accountId,
            update: {
              [emailId]: patch
            }
          }, 'addLabels']
        ]
      };
    
      const response = await this.makeRequest(request);
      const result = this.getMethodResult(response, 0);
    
      if (result.notUpdated && result.notUpdated[emailId]) {
        throw new Error('Failed to add labels to email.');
      }
    }
  • The tool handler for 'add_labels' in the MCP request router: extracts emailId and mailboxIds from args, validates inputs, calls client.addLabels(), and returns a success message.
    case 'add_labels': {
      const { emailId, mailboxIds } = args as any;
      if (!emailId) {
        throw new McpError(ErrorCode.InvalidParams, 'emailId is required');
      }
      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.addLabels(emailId, mailboxIds);
      return {
        content: [
          {
            type: 'text',
            text: `Labels added successfully to email`,
          },
        ],
      };
    }
  • The input schema registration for the 'add_labels' tool, defining the required emailId (string) and mailboxIds (array of strings) parameters.
    {
      name: 'add_labels',
      description: 'Add labels (mailboxes) to an email without removing existing ones',
      inputSchema: {
        type: 'object',
        properties: {
          emailId: {
            type: 'string',
            description: 'ID of the email to add labels to',
          },
          mailboxIds: {
            type: 'array',
            items: { type: 'string' },
            description: 'Array of mailbox IDs to add as labels',
          },
        },
        required: ['emailId', 'mailboxIds'],
      },
    },
  • src/index.ts:680-698 (registration)
    Registration of the 'add_labels' tool in the ListToolsRequestSchema handler, declaring its name, description, and input schema.
    {
      name: 'add_labels',
      description: 'Add labels (mailboxes) to an email without removing existing ones',
      inputSchema: {
        type: 'object',
        properties: {
          emailId: {
            type: 'string',
            description: 'ID of the email to add labels to',
          },
          mailboxIds: {
            type: 'array',
            items: { type: 'string' },
            description: 'Array of mailbox IDs to add as labels',
          },
        },
        required: ['emailId', 'mailboxIds'],
      },
    },
Behavior2/5

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

No annotations are provided, so the description must carry the full burden. It discloses an important behavioral trait (incremental labeling) but does not mention error conditions, return values, or permissions.

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?

The description is a single efficient sentence that conveys the essential purpose and key behavior with no wasted words.

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?

Given no output schema, no annotations, and two parameters, the description covers the main function but lacks details on error cases, return values, or prerequisites, leaving gaps for a fully informed 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?

Input schema has 100% description coverage, so description adds minimal value. The 'without removing existing ones' comment is not parameter-specific, resulting in baseline score.

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 that the tool adds labels to an email without removing existing ones, distinguishing it from related tools like 'remove_labels' 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 Guidelines3/5

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

The description mentions 'without removing existing ones' to indicate additive use, but lacks explicit guidance on when to use this tool versus alternatives like 'bulk_add_labels' 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