create_label
Create new Gmail labels to organize emails and categorize messages in your inbox 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)Handler logic for the 'create_label' tool. Validates the input using the defined schema, calls GmailService.createLabel with the label name, and returns a success message with the created label's name and ID.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 defining the input for 'create_label': an object with a required 'name' string field.create_label: z.object({ name: z.string().describe("Label name") }),
- src/tools.ts:50-55 (registration)Registration of all tools, including 'create_label', by exporting tool definitions with name, description from toolDescriptions, and inputSchema derived from Zod schema.export const getToolDefinitions = () => Object.entries(schemas).map(([name, schema]) => ({ name, description: toolDescriptions[name], inputSchema: zodToJsonSchema(schema) }));
- src/gmail-service.ts:85-91 (helper)Core implementation of label creation using Google Gmail API: calls users.labels.create with the label name and visibility settings, returns the created Label object.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; }