Skip to main content
Glama

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

Implementation Reference

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

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