apply_label
Apply a label to an email by providing the message ID and label ID. Organize your Gmail inbox by categorizing emails with labels directly from natural language.
Instructions
Apply a label to an email
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| messageId | Yes | Email message ID | |
| labelId | Yes | Label ID to apply |
Implementation Reference
- src/tools.ts:16-19 (schema)Zod input schema for the 'apply_label' tool: validates messageId and labelId as strings.
apply_label: z.object({ messageId: z.string().describe("Email message ID"), labelId: z.string().describe("Label ID to apply") }), - src/tools.ts:114-118 (handler)Handler case for 'apply_label' in handleToolCall: validates input, calls gmailService.applyLabel(), and returns success text.
case "apply_label": { const v = validated as z.infer<typeof schemas.apply_label>; await gmailService.applyLabel(v.messageId, v.labelId); return { content: [{ type: "text", text: `Label ${v.labelId} applied to email ${v.messageId}.` }] }; } - src/gmail-service.ts:97-99 (helper)GmailService.applyLabel() method: calls modifyMessage() with addLabelIds containing the labelId, which uses the Gmail API users.messages.modify.
async applyLabel(messageId: string, labelId: string): Promise<void> { await this.modifyMessage(messageId, { addLabelIds: [labelId] }); } - src/gmail-service.ts:109-111 (helper)Private modifyMessage helper used by applyLabel: makes the actual Gmail API users.messages.modify request.
private async modifyMessage(id: string, requestBody: any): Promise<void> { await this.gmail.users.messages.modify({ userId: 'me', id, requestBody }); } - src/tools.ts:43-43 (registration)Description registered for the 'apply_label' tool: 'Apply a label to an email'.
apply_label: "Apply a label to an email",