get_attachment
Retrieve email attachments from Gmail messages by specifying the message ID and attachment ID to access files directly from your inbox.
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-700 (handler)The handler function for the 'get_attachment' tool. It uses the shared handleTool to authenticate and call the Gmail API's users.messages.attachments.get method with the provided messageId and attachment 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:691-693 (schema)Zod schema defining the input parameters for the get_attachment tool: 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"), },
- src/index.ts:688-700 (registration)Registration of the 'get_attachment' tool on the MCP server, including name, 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) }) } )