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
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"emailId": "<emailId>",
"mailboxIds": "<mailboxIds>"
},
"name": "remove_labels"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| emailId | Yes | ID of the email to remove labels from | |
| mailboxIds | Yes | Array of mailbox IDs to remove as labels |
Implementation Reference
- src/jmap-client.ts:913-940 (handler)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'], }, }, - src/index.ts:1495-1513 (handler)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`, }, ], }; }