create_label
Create a new Gmail label by providing a label name. This tool adds the label to your Gmail account for organizing and categorizing emails.
Instructions
Create a new Gmail label
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Label name |
Implementation Reference
- src/gmail-service.ts:85-91 (handler)The actual Gmail API call to create a label via the Google Gmail API. Uses gmail.users.labels.create with messageListVisibility:'show' and labelListVisibility:'labelShow'.
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; } - src/tools.ts:102-106 (handler)The case handler in handleToolCall() that validates input and dispatches to gmailService.createLabel(), then formats the success response with label 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 definition for create_label tool. Requires a single string parameter 'name' for the label name.
create_label: z.object({ name: z.string().describe("Label name") }), - src/tools.ts:41-41 (registration)Tool description registration for create_label used in getToolDefinitions().
create_label: "Create a new Gmail label", - src/lib.ts:48-48 (registration)MCP server registration: the ListToolsRequestSchema handler calls getToolDefinitions() which includes create_label, and the CallToolRequestSchema handler dispatches to handleToolCall().
server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: getToolDefinitions() }));