modify_thread
Add or remove labels from a specific email thread to organize your inbox.
Instructions
Modify the labels applied to a thread
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | The ID of the thread to modify | |
| addLabelIds | No | A list of label IDs to add to the thread | |
| removeLabelIds | No | A list of label IDs to remove from the thread |
Implementation Reference
- src/index.ts:789-803 (registration)Registration of the 'modify_thread' tool on the MCP server using server.tool() with the name 'modify_thread', description 'Modify the labels applied to a thread', and schema defining 'id' (required string), 'addLabelIds' (optional array of strings), 'removeLabelIds' (optional array of strings).
server.tool("modify_thread", "Modify the labels applied to a thread", { id: z.string().describe("The ID of the thread to modify"), addLabelIds: z.array(z.string()).optional().describe("A list of label IDs to add to the thread"), removeLabelIds: z.array(z.string()).optional().describe("A list of label IDs to remove from the thread") }, async (params) => { const { id, ...threadData } = params return handleTool(config, async (gmail: gmail_v1.Gmail) => { const { data } = await gmail.users.threads.modify({ userId: 'me', id, requestBody: threadData }) return formatResponse(data) }) } ) - src/index.ts:791-795 (schema)Input schema for the modify_thread tool defined via Zod: 'id' (required string), 'addLabelIds' (optional string array), 'removeLabelIds' (optional string array).
{ id: z.string().describe("The ID of the thread to modify"), addLabelIds: z.array(z.string()).optional().describe("A list of label IDs to add to the thread"), removeLabelIds: z.array(z.string()).optional().describe("A list of label IDs to remove from the thread") }, - src/index.ts:796-803 (handler)Handler function for modify_thread. Destructures 'id' from params, passes the rest as 'threadData', then calls gmail.users.threads.modify() with userId 'me', the thread id, and the label modification request body.
async (params) => { const { id, ...threadData } = params return handleTool(config, async (gmail: gmail_v1.Gmail) => { const { data } = await gmail.users.threads.modify({ userId: 'me', id, requestBody: threadData }) return formatResponse(data) }) } )