create-label
Create a new Gmail label to organize emails, with options to control visibility in label and message lists.
Instructions
Create a new Gmail label
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | The name of the label to create | |
| labelListVisibility | No | Visibility of the label in the label list | |
| messageListVisibility | No | Visibility of the label in the message list |
Implementation Reference
- src/tools.ts:407-441 (handler)The handler function that implements the core logic for the 'create-label' tool. It uses the Composio toolset to execute the 'GMAIL_CREATE_LABEL' action with the provided arguments.}, async (args, extra) => { try { const userAddress = "default-user"; const result = await toolset.executeAction({ action: "GMAIL_CREATE_LABEL", entityId: userAddress, params: args }); if (result.successful) { return { content: [{ type: "text", text: `✅ Label created successfully!\n\nLabel: ${args.name}\nID: ${(result.data?.response_data as any)?.id}` }], }; } else { return { content: [{ type: "text", text: `❌ Failed to create label: ${result.error || 'Unknown error'}` }], }; } } catch (error) { console.error('Error creating label:', error); return { content: [{ type: "text", text: `Error creating label: ${error instanceof Error ? error.message : String(error)}` }], }; } });
- src/tools.ts:404-407 (schema)Zod schema defining the input parameters for the 'create-label' tool: required 'name' and optional visibility fields.name: z.string().describe("The name of the label to create"), labelListVisibility: z.string().optional().describe("Visibility of the label in the label list"), messageListVisibility: z.string().optional().describe("Visibility of the label in the message list"), }, async (args, extra) => {
- src/tools.ts:403-441 (registration)The server.tool registration call that registers the 'create-label' tool with its schema and handler.server.tool("create-label", "Create a new Gmail label", { name: z.string().describe("The name of the label to create"), labelListVisibility: z.string().optional().describe("Visibility of the label in the label list"), messageListVisibility: z.string().optional().describe("Visibility of the label in the message list"), }, async (args, extra) => { try { const userAddress = "default-user"; const result = await toolset.executeAction({ action: "GMAIL_CREATE_LABEL", entityId: userAddress, params: args }); if (result.successful) { return { content: [{ type: "text", text: `✅ Label created successfully!\n\nLabel: ${args.name}\nID: ${(result.data?.response_data as any)?.id}` }], }; } else { return { content: [{ type: "text", text: `❌ Failed to create label: ${result.error || 'Unknown error'}` }], }; } } catch (error) { console.error('Error creating label:', error); return { content: [{ type: "text", text: `Error creating label: ${error instanceof Error ? error.message : String(error)}` }], }; } });