Skip to main content
Glama

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
NameRequiredDescriptionDefault
messageIdYesID of the message containing the attachment
idYesThe ID of the attachment

Implementation Reference

  • 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) }) }
  • 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) }) } )

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/nk900600/gmail-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server