Skip to main content
Glama
MadLlama25

Fastmail MCP Server

by MadLlama25

remove_labels

Remove specified labels from an email by providing the email ID and mailbox IDs to detach those labels.

Instructions

Remove specific labels (mailboxes) from an email

Input Schema

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

Implementation Reference

  • The actual handler method on JmapClient that removes labels from an email by building a JMAP patch object that sets each specified mailboxId to null (removing the label), then sending an Email/set request.
    async removeLabels(emailId: 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 request: JmapRequest = {
        using: ['urn:ietf:params:jmap:core', 'urn:ietf:params:jmap:mail'],
        methodCalls: [
          ['Email/set', {
            accountId: session.accountId,
            update: {
              [emailId]: patch
            }
          }, 'removeLabels']
        ]
      };
    
      const response = await this.makeRequest(request);
      const result = this.getMethodResult(response, 0);
    
      if (result.notUpdated && result.notUpdated[emailId]) {
        throw new Error('Failed to remove labels from email.');
      }
    }
  • src/index.ts:696-714 (registration)
    Schema registration for the 'remove_labels' tool in the ListTools handler (lines 696-714) and the call handler (lines 1492-1510) that reads args and calls client.removeLabels(emailId, mailboxIds).
    {
      name: 'remove_labels',
      description: 'Remove specific labels (mailboxes) from an email',
      inputSchema: {
        type: 'object',
        properties: {
          emailId: {
            type: 'string',
            description: 'ID of the email to remove labels from',
          },
          mailboxIds: {
            type: 'array',
            items: { type: 'string' },
            description: 'Array of mailbox IDs to remove as labels',
          },
        },
        required: ['emailId', 'mailboxIds'],
      },
    },
  • Input schema definition for the 'remove_labels' tool, specifying required emailId (string) and mailboxIds (array of strings).
    {
      name: 'remove_labels',
      description: 'Remove specific labels (mailboxes) from an email',
      inputSchema: {
        type: 'object',
        properties: {
          emailId: {
            type: 'string',
            description: 'ID of the email to remove labels from',
          },
          mailboxIds: {
            type: 'array',
            items: { type: 'string' },
            description: 'Array of mailbox IDs to remove as labels',
          },
        },
        required: ['emailId', 'mailboxIds'],
      },
    },
  • Call handler for 'remove_labels' tool — validates emailId and mailboxIds, then delegates to JmapClient.removeLabels().
    case 'remove_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.removeLabels(emailId, mailboxIds);
      return {
        content: [
          {
            type: 'text',
            text: `Labels removed successfully from email`,
          },
        ],
      };
    }
Behavior2/5

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

No annotations provided; description lacks details on effects, reversibility, or permissions of the removal 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?

Extremely concise, but the single phrase could be considered under-specified; however, it is not verbose.

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?

Tool is simple and no output schema, but lacks differentiation from bulk_remove_labels and does not explain 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 100% of parameters, and description adds no extra meaning beyond what the schema provides.

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 'remove' and the resource 'labels (mailboxes) from an email', distinguishing it from sibling '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 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 'bulk_remove_labels' 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