get_draft
Retrieve a specific email draft by its ID. Optionally include the full HTML body for detailed access.
Instructions
Get a specific draft by ID
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | The ID of the draft 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:311-331 (registration)The 'get_draft' tool is registered via server.tool(). It accepts an 'id' (required, string) and optional 'includeBodyHtml' (boolean). The handler calls gmail.users.drafts.get() with format 'full', processes the message payload (optionally including HTML), and returns the result.
server.tool("get_draft", "Get a specific draft by ID", { id: z.string().describe("The ID of the draft 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.drafts.get({ userId: 'me', id: params.id, format: 'full' }) if (data.message?.payload) { data.message.payload = processMessagePart( data.message.payload, params.includeBodyHtml ) } return formatResponse(data) }) } ) - src/index.ts:317-330 (handler)The handler function for 'get_draft'. It uses handleTool to authenticate and execute the call, calls the Gmail API drafts.get endpoint, processes the message part, and formats the response.
async (params) => { return handleTool(config, async (gmail: gmail_v1.Gmail) => { const { data } = await gmail.users.drafts.get({ userId: 'me', id: params.id, format: 'full' }) if (data.message?.payload) { data.message.payload = processMessagePart( data.message.payload, params.includeBodyHtml ) } return formatResponse(data) }) } - src/index.ts:314-316 (schema)Input schema for 'get_draft' using Zod: requires an 'id' string and optionally 'includeBodyHtml' boolean.
id: z.string().describe("The ID of the draft 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") },