remove_label
Remove a specific label from an email message in Gmail to help organize your inbox and categorize messages more effectively.
Instructions
Remove a label from an email
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| labelId | Yes | Label ID to remove | |
| messageId | Yes | Email message ID |
Implementation Reference
- src/tools.ts:120-124 (handler)Tool handler for 'remove_label': validates arguments using Zod schema, calls GmailService.removeLabel, and 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 input schema definition for the 'remove_label' tool, specifying messageId and labelId parameters.remove_label: z.object({ messageId: z.string().describe("Email message ID"), labelId: z.string().describe("Label ID to remove") }),
- src/tools.ts:50-55 (registration)Function that generates tool definitions for all tools, including 'remove_label', by iterating over schemas and toolDescriptions for MCP registration.export const getToolDefinitions = () => Object.entries(schemas).map(([name, schema]) => ({ name, description: toolDescriptions[name], inputSchema: zodToJsonSchema(schema) }));
- src/gmail-service.ts:101-103 (helper)GmailService method implementing label removal by calling Gmail API's modifyMessage with removeLabelIds.async removeLabel(messageId: string, labelId: string): Promise<void> { await this.modifyMessage(messageId, { removeLabelIds: [labelId] }); }