Skip to main content
Glama

apply_label

Apply a label to an email by providing the message ID and label ID. Organize your Gmail inbox by categorizing emails with labels directly from natural language.

Instructions

Apply a label to an email

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
messageIdYesEmail message ID
labelIdYesLabel ID to apply

Implementation Reference

  • Zod input schema for the 'apply_label' tool: validates messageId and labelId as strings.
    apply_label: z.object({
        messageId: z.string().describe("Email message ID"),
        labelId: z.string().describe("Label ID to apply")
    }),
  • Handler case for 'apply_label' in handleToolCall: validates input, calls gmailService.applyLabel(), and returns success text.
    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}.` }] };
    }
  • GmailService.applyLabel() method: calls modifyMessage() with addLabelIds containing the labelId, which uses the Gmail API users.messages.modify.
    async applyLabel(messageId: string, labelId: string): Promise<void> {
        await this.modifyMessage(messageId, { addLabelIds: [labelId] });
    }
  • Private modifyMessage helper used by applyLabel: makes the actual Gmail API users.messages.modify request.
    private async modifyMessage(id: string, requestBody: any): Promise<void> {
        await this.gmail.users.messages.modify({ userId: 'me', id, requestBody });
    }
  • src/tools.ts:43-43 (registration)
    Description registered for the 'apply_label' tool: 'Apply a label to an email'.
    apply_label: "Apply a label to an email",
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description must carry the burden of behavioral disclosure. It only says 'apply a label' without clarifying idempotency, error behavior, or required authentication, which is insufficient for a mutation tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Single sentence, no wasted words. Front-loaded with verb and resource. Ideal conciseness for a simple tool.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the simplicity of the tool (two required params, no output schema), the description is minimally adequate. However, it lacks details such as whether labels can be applied multiple times or if authentication is assumed, leaving gaps for the agent.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% and the description does not add any meaning beyond the field names and types. Baseline score of 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action (apply a label) and the resource (email). It distinguishes from sibling tools like batch_apply_labels by implication (single vs batch) and remove_label, but does not explicitly differentiate.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like batch_apply_labels. No prerequisites, context, or exclusions are mentioned.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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