Skip to main content
Glama

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
NameRequiredDescriptionDefault
nameYesLabel name

Implementation Reference

  • 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}` }] }; }
  • 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) }));
  • 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; }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/muammar-yacoob/GMail-Manager-MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server