get_attachment
Retrieve a specific attachment from a Gmail message by providing the message ID and attachment ID.
Instructions
Get a message attachment
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| messageId | Yes | ID of the message containing the attachment | |
| id | Yes | The ID of the attachment |
Implementation Reference
- src/index.ts:702-714 (registration)Registration of the 'get_attachment' tool via server.tool() with its name, description, Zod schema for inputs (messageId and id), and the handler function that calls the Gmail API to get an attachment.
server.tool("get_attachment", "Get a message attachment", { messageId: z.string().describe("ID of the message containing the attachment"), id: z.string().describe("The ID of the attachment"), }, async (params) => { return handleTool(config, async (gmail: gmail_v1.Gmail) => { const { data } = await gmail.users.messages.attachments.get({ userId: 'me', messageId: params.messageId, id: params.id }) return formatResponse(data) }) } ) - src/index.ts:708-713 (handler)The handler function for get_attachment. It receives params (messageId and id), wraps the call in handleTool which manages OAuth2 and error handling, then calls Gmail API's messages.attachments.get and formats the response.
async (params) => { return handleTool(config, async (gmail: gmail_v1.Gmail) => { const { data } = await gmail.users.messages.attachments.get({ userId: 'me', messageId: params.messageId, id: params.id }) return formatResponse(data) }) } - src/index.ts:704-707 (schema)Zod schema defining the input parameters for get_attachment: messageId (string) and id (string).
{ messageId: z.string().describe("ID of the message containing the attachment"), id: z.string().describe("The ID of the attachment"), },