Skip to main content
Glama

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

Implementation Reference

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

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