get_thread
Retrieve a specific email thread by its ID. Optionally include the parsed HTML body for detailed inspection.
Instructions
Get a specific thread by ID
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | The ID of the thread to retrieve | |
| includeBodyHtml | No | Whether to include the parsed HTML in the return for each body, excluded by default because they can be excessively large |
Implementation Reference
- src/index.ts:729-751 (handler)The 'get_thread' tool handler function. It takes 'id' (required) and 'includeBodyHtml' (optional) parameters, calls gmail.users.threads.get with format='full', then processes each message's payload via processMessagePart() and returns the formatted response.
server.tool("get_thread", "Get a specific thread by ID", { id: z.string().describe("The ID of the thread to retrieve"), includeBodyHtml: z.boolean().optional().describe("Whether to include the parsed HTML in the return for each body, excluded by default because they can be excessively large") }, async (params) => { return handleTool(config, async (gmail: gmail_v1.Gmail) => { const { data } = await gmail.users.threads.get({ userId: 'me', id: params.id, format: 'full' }) if (data.messages) { data.messages = data.messages.map(message => { if (message.payload) { message.payload = processMessagePart(message.payload, params.includeBodyHtml) } return message }) } return formatResponse(data) }) } ) - src/index.ts:729-734 (schema)The input schema for 'get_thread' tool: requires 'id' (string, the thread ID), and optional 'includeBodyHtml' (boolean) to control whether HTML body content is included in the response.
server.tool("get_thread", "Get a specific thread by ID", { id: z.string().describe("The ID of the thread to retrieve"), includeBodyHtml: z.boolean().optional().describe("Whether to include the parsed HTML in the return for each body, excluded by default because they can be excessively large") }, - src/index.ts:729-751 (registration)The tool is registered on the MCP server via server.tool('get_thread', ...) at line 729. It's registered within the createServer function that sets up all Gmail MCP tools.
server.tool("get_thread", "Get a specific thread by ID", { id: z.string().describe("The ID of the thread to retrieve"), includeBodyHtml: z.boolean().optional().describe("Whether to include the parsed HTML in the return for each body, excluded by default because they can be excessively large") }, async (params) => { return handleTool(config, async (gmail: gmail_v1.Gmail) => { const { data } = await gmail.users.threads.get({ userId: 'me', id: params.id, format: 'full' }) if (data.messages) { data.messages = data.messages.map(message => { if (message.payload) { message.payload = processMessagePart(message.payload, params.includeBodyHtml) } return message }) } return formatResponse(data) }) } )