Skip to main content
Glama
rishipradeep-think41

Google Workspace MCP Server

modify_email

Manage email labels in Gmail using the Google Workspace MCP Server. Add, remove, archive, trash, or mark emails as read/unread programmatically.

Instructions

Modify email labels (archive, trash, mark read/unread)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
addLabelsNoLabels to add
idYesEmail ID
removeLabelsNoLabels to remove

Implementation Reference

  • The main handler function that executes the modify_email tool logic by calling the Gmail API to add or remove labels from an email.
    private async handleModifyEmail(args: any) {
      try {
        const { id, addLabels = [], removeLabels = [] } = args;
    
        const response = await this.gmail.users.messages.modify({
          userId: "me",
          id,
          requestBody: {
            addLabelIds: addLabels,
            removeLabelIds: removeLabels,
          },
        });
    
        return {
          content: [
            {
              type: "text",
              text: `Email modified successfully. Updated labels for message ID: ${response.data.id}`,
            },
          ],
        };
      } catch (error: any) {
        return {
          content: [
            {
              type: "text",
              text: `Error modifying email: ${error.message}`,
            },
          ],
          isError: true,
        };
      }
    }
  • src/index.ts:136-159 (registration)
    Registers the 'modify_email' tool in the ListTools response, including its name, description, and input schema.
    {
      name: "modify_email",
      description: "Modify email labels (archive, trash, mark read/unread)",
      inputSchema: {
        type: "object",
        properties: {
          id: {
            type: "string",
            description: "Email ID",
          },
          addLabels: {
            type: "array",
            items: { type: "string" },
            description: "Labels to add",
          },
          removeLabels: {
            type: "array",
            items: { type: "string" },
            description: "Labels to remove",
          },
        },
        required: ["id"],
      },
    },
  • src/index.ts:280-281 (registration)
    Dispatches CallTool requests for 'modify_email' to the handleModifyEmail handler function.
    case "modify_email":
      return await this.handleModifyEmail(request.params.arguments);
  • Defines the input schema for the 'modify_email' tool, specifying required 'id' and optional label arrays.
    inputSchema: {
      type: "object",
      properties: {
        id: {
          type: "string",
          description: "Email ID",
        },
        addLabels: {
          type: "array",
          items: { type: "string" },
          description: "Labels to add",
        },
        removeLabels: {
          type: "array",
          items: { type: "string" },
          description: "Labels to remove",
        },
      },
      required: ["id"],
    },

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

A3.6/5.0
Behavior2/5

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

With no annotations, the description carries full burden but only states 'Modify email labels' without disclosing side effects, idempotency, exact label behavior (e.g., archive meaning removing INBOX), or required permissions.

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?

Extremely concise single sentence, front-loaded with the action, no wasted words.

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

Completeness4/5

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

Adequate for a simple mutation tool with 3 params and no output schema; covers the main purpose but lacks detail on error handling or return behavior.

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

Parameters4/5

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

Schema coverage is 100%, and the description adds value by giving concrete label examples (archive, trash, mark read/unread) beyond the generic schema descriptions, though exact label names are not specified.

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

Purpose5/5

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

The description clearly states the tool modifies email labels, with concrete examples (archive, trash, mark read/unread), distinguishing it from sibling tools like list_emails or send_email.

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?

No guidance on when to use this tool versus siblings (e.g., list_emails or search_emails) or any prerequisites, leaving the agent to infer usage context without support.

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

Deploy Server

Other Tools

Related Tools