Skip to main content
Glama
owen-nash

Fastmail MCP Server

by owen-nash

remove_labels

Remove one or more labels from an email by specifying the email ID and mailbox IDs to detach.

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 `removeLabels()` method on `JmapClient` which executes the core JMAP API call to remove labels (mailboxIds) from an email by building a patch setting each target mailboxId to `null`.
    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:699-717 (registration)
    Tool registration in the ListToolsRequestSchema handler: defines the `remove_labels` tool with its name, description, and input schema (emailId + mailboxIds array).
    {
      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'],
      },
    },
  • The CallToolRequestSchema handler for `remove_labels`: validates `emailId` and `mailboxIds`, then delegates to `client.removeLabels(emailId, mailboxIds)`.
    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 does not disclose side effects (e.g., if labels must exist, impact of removing nonexistent labels, or return value).

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?

Extremely concise single sentence with no redundancy, efficiently conveying the tool's function.

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?

Lacks details on return value, error conditions, or prerequisites; adequate for a simple operation but could be more comprehensive.

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 coverage is 100% and description adds minimal value beyond schema definitions, providing only the parenthetical clarification '(mailboxes)'.

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?

Description clearly states the action 'Remove specific labels' and the target 'email', distinguishing it from sibling tools like '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?

No explicit guidance on when to use this tool over alternatives like 'bulk_remove_labels', but the purpose is straightforward and implied.

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