get_attachment
Retrieve email attachments from Gmail by specifying the message ID and attachment ID to access files sent in emails.
Instructions
Get a message attachment
Input Schema
TableJSON 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:694-699 (handler)Handler function for the 'get_attachment' tool. It uses handleTool to authenticate and calls the Gmail API to fetch the attachment by messageId and id, then 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:690-693 (schema)Zod schema defining input parameters for the 'get_attachment' tool: messageId and id.{ messageId: z.string().describe("ID of the message containing the attachment"), id: z.string().describe("The ID of the attachment"), },
- src/index.ts:688-700 (registration)Registration of the 'get_attachment' tool on the MCP server with description, input schema, and handler function.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) }) } )