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"], },

Other Tools

Related 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/rishipradeep-think41/gsuite-mcp'

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