remove_label
Remove a label from a specific Gmail message to declutter your inbox and improve email organization.
Instructions
Remove a label from an email
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| messageId | Yes | Email message ID | |
| labelId | Yes | Label ID to remove |
Implementation Reference
- src/tools.ts:120-124 (handler)The main handler logic for the 'remove_label' tool. Validates input using the schema and calls GmailService.removeLabel, then returns success message.case "remove_label": { const v = validated as z.infer<typeof schemas.remove_label>; await gmailService.removeLabel(v.messageId, v.labelId); return { content: [{ type: "text", text: `Label ${v.labelId} removed from email ${v.messageId}.` }] }; }
- src/tools.ts:20-23 (schema)Zod schema defining input parameters for remove_label tool: messageId (string) and labelId (string).remove_label: z.object({ messageId: z.string().describe("Email message ID"), labelId: z.string().describe("Label ID to remove") }),
- src/tools.ts:44-44 (registration)Tool description for 'remove_label' used when registering the tool via getToolDefinitions().remove_label: "Remove a label from an email",
- src/gmail-service.ts:101-103 (helper)GmailService method implementing the label removal by calling modifyMessage with removeLabelIds.async removeLabel(messageId: string, labelId: string): Promise<void> { await this.modifyMessage(messageId, { removeLabelIds: [labelId] }); }
- src/gmail-service.ts:109-111 (helper)Private helper method in GmailService that performs the actual Gmail API call to modify message labels.private async modifyMessage(id: string, requestBody: any): Promise<void> { await this.gmail.users.messages.modify({ userId: 'me', id, requestBody }); }