modify_message
Add or remove labels on Gmail messages to organize your inbox. Specify message ID and label IDs to modify.
Instructions
Modify the labels on a message
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | The ID of the message to modify | |
| addLabelIds | No | A list of label IDs to add to the message | |
| removeLabelIds | No | A list of label IDs to remove from the message |
Implementation Reference
- src/index.ts:618-623 (handler)The handler function for the 'modify_message' tool. It uses handleTool to call the Gmail API's users.messages.modify method to update labels on a specific message.async (params) => { return handleTool(config, async (gmail: gmail_v1.Gmail) => { const { data } = await gmail.users.messages.modify({ userId: 'me', id: params.id, requestBody: { addLabelIds: params.addLabelIds, removeLabelIds: params.removeLabelIds } }) return formatResponse(data) }) }
- src/index.ts:614-617 (schema)Input schema definition for the 'modify_message' tool using Zod, specifying message ID and optional label IDs to add or remove.id: z.string().describe("The ID of the message to modify"), addLabelIds: z.array(z.string()).optional().describe("A list of label IDs to add to the message"), removeLabelIds: z.array(z.string()).optional().describe("A list of label IDs to remove from the message") },
- src/index.ts:611-624 (registration)Registration of the 'modify_message' tool on the MCP server, including description, input schema, and handler function.server.tool("modify_message", "Modify the labels on a message", { id: z.string().describe("The ID of the message to modify"), addLabelIds: z.array(z.string()).optional().describe("A list of label IDs to add to the message"), removeLabelIds: z.array(z.string()).optional().describe("A list of label IDs to remove from the message") }, async (params) => { return handleTool(config, async (gmail: gmail_v1.Gmail) => { const { data } = await gmail.users.messages.modify({ userId: 'me', id: params.id, requestBody: { addLabelIds: params.addLabelIds, removeLabelIds: params.removeLabelIds } }) return formatResponse(data) }) } )