create_label
Define a new Gmail label, configuring its name, message visibility, label visibility, and color.
Instructions
Create a new label
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | The display name of the label | |
| messageListVisibility | No | The visibility of messages with this label in the message list | |
| labelListVisibility | No | The visibility of the label in the label list | |
| color | No | The color settings for the label |
Implementation Reference
- src/index.ts:436-453 (registration)Registration of the 'create_label' tool on the MCP server via server.tool(). Includes both the schema definition (name, messageListVisibility, labelListVisibility, color params) and the handler logic.
server.tool("create_label", "Create a new label", { name: z.string().describe("The display name of the label"), messageListVisibility: z.enum(['show', 'hide']).optional().describe("The visibility of messages with this label in the message list"), labelListVisibility: z.enum(['labelShow', 'labelShowIfUnread', 'labelHide']).optional().describe("The visibility of the label in the label list"), color: z.object({ textColor: z.string().describe("The text color of the label as hex string"), backgroundColor: z.string().describe("The background color of the label as hex string") }).optional().describe("The color settings for the label") }, async (params) => { return handleTool(config, async (gmail: gmail_v1.Gmail) => { const { data } = await gmail.users.labels.create({ userId: 'me', requestBody: params }) return formatResponse(data) }) } ) - src/index.ts:447-453 (handler)The handler function for create_label. It uses handleTool to authenticate, then calls the Gmail API users.labels.create with the params as the requestBody, and formats the response.
async (params) => { return handleTool(config, async (gmail: gmail_v1.Gmail) => { const { data } = await gmail.users.labels.create({ userId: 'me', requestBody: params }) return formatResponse(data) }) } ) - src/index.ts:438-446 (schema)Zod schema definitions for the create_label tool's input parameters: name (required string), messageListVisibility (optional enum), labelListVisibility (optional enum), and color (optional object with textColor and backgroundColor hex strings).
{ name: z.string().describe("The display name of the label"), messageListVisibility: z.enum(['show', 'hide']).optional().describe("The visibility of messages with this label in the message list"), labelListVisibility: z.enum(['labelShow', 'labelShowIfUnread', 'labelHide']).optional().describe("The visibility of the label in the label list"), color: z.object({ textColor: z.string().describe("The text color of the label as hex string"), backgroundColor: z.string().describe("The background color of the label as hex string") }).optional().describe("The color settings for the label") },