Skip to main content
Glama

apply_label

Apply a Gmail label to organize specific emails using message and label identifiers for better inbox management.

Instructions

Apply a label to an email

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
labelIdYesLabel ID to apply
messageIdYesEmail message ID

Implementation Reference

  • Handler for the 'apply_label' tool within handleToolCall function. Validates input using Zod schema and delegates to GmailService.applyLabel.
    case "apply_label": { const v = validated as z.infer<typeof schemas.apply_label>; await gmailService.applyLabel(v.messageId, v.labelId); return { content: [{ type: "text", text: `Label ${v.labelId} applied to email ${v.messageId}.` }] }; }
  • Zod schema definition for the 'apply_label' tool input parameters: messageId and labelId.
    apply_label: z.object({ messageId: z.string().describe("Email message ID"), labelId: z.string().describe("Label ID to apply") }),
  • src/tools.ts:50-55 (registration)
    Tool registration via getToolDefinitions, which generates MCP tool definitions including 'apply_label' from schemas and descriptions.
    export const getToolDefinitions = () => Object.entries(schemas).map(([name, schema]) => ({ name, description: toolDescriptions[name], inputSchema: zodToJsonSchema(schema) }));
  • Core implementation of applying a label to an email message using Gmail API's modifyMessage with addLabelIds.
    async applyLabel(messageId: string, labelId: string): Promise<void> { await this.modifyMessage(messageId, { addLabelIds: [labelId] }); }

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