modify_email
Adjust email labels such as archive, trash, and read/unread status. Manage email organization by adding or removing labels using a specified email ID.
Instructions
Modify email labels (archive, trash, mark read/unread)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| addLabels | No | Labels to add | |
| id | Yes | Email ID | |
| removeLabels | No | Labels to remove |
Implementation Reference
- src/index.ts:413-445 (handler)The main handler function that modifies an email's labels by adding or removing specified labels using the Gmail API.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:131-150 (schema)Defines the input schema for the modify_email tool, specifying parameters like id (required), addLabels, and removeLabels.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:128-151 (registration)Registers the modify_email tool in the list of available tools returned by ListToolsRequest.{ 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:236-237 (registration)Registers the handler for the modify_email tool in the CallToolRequest switch statement.case 'modify_email': return await this.handleModifyEmail(request.params.arguments);