create_label
Create a new Gmail label to organize your inbox by categorizing emails with custom tags for better email management.
Instructions
Create a new Gmail label
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Label name |
Implementation Reference
- src/tools.ts:102-106 (handler)The handler function for the 'create_label' tool. It validates the input using the schema, calls the Gmail service to create the label, and returns a success message with the new label's details.case "create_label": { const v = validated as z.infer<typeof schemas.create_label>; const label = await gmailService.createLabel(v.name); return { content: [{ type: "text", text: `Label created successfully:\nName: ${label.name}\nID: ${label.id}` }] }; }
- src/tools.ts:14-14 (schema)Zod schema definition for the 'create_label' tool input: requires a 'name' string.create_label: z.object({ name: z.string().describe("Label name") }),
- src/tools.ts:50-55 (registration)The getToolDefinitions function registers all tools, including 'create_label', by generating JSON schemas from Zod schemas and descriptions.export const getToolDefinitions = () => Object.entries(schemas).map(([name, schema]) => ({ name, description: toolDescriptions[name], inputSchema: zodToJsonSchema(schema) }));
- src/gmail-service.ts:85-91 (helper)The core helper method in GmailService that performs the actual Gmail API call to create a new label.async createLabel(name: string): Promise<Label> { const { data } = await this.gmail.users.labels.create({ userId: 'me', requestBody: { name, messageListVisibility: 'show', labelListVisibility: 'labelShow' } }); return data as Label; }