Skip to main content
Glama

Get email attachment

google_gmail_get_attachment

Download a Gmail attachment by message ID and attachment ID, returning text decoded or binary as base64; save large files to a local path to avoid inline size limits.

Instructions

Download a single attachment by message ID and attachment ID. Text-like files are returned decoded as text; binary files as base64. Attachments that would produce an inline result over 6 MB are rejected — pass saveToPath to write the raw bytes to a local file instead. The limit is measured on the JSON-RPC frame, not the raw bytes.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "id": "<id>",
      "attachmentId": "<attachmentId>"
    },
    "name": "google_gmail_get_attachment"
  }
}

Input Schema

NameRequiredDescriptionDefault
idYesMessage ID.
sizeNoSize in bytes from list_attachments; narrows the filename match.
partIdNoStable part ID (from list_attachments); preferred over attachmentId for lookup. Pass "" for an attachment on the message root part.
accountNoAccount nickname to use.
filenameNoFilename from list_attachments; disambiguates when Gmail has rotated attachmentId.
maxBytesNoInline size limit in bytes (default 6 MB), measured on the JSON-RPC frame the client receives. Escaping can inflate a payload (base64 ~1.33x, NUL-heavy text ~7x). Ignored when saving to disk.
mimeTypeNoMIME type from list_attachments; narrows the filename match.
saveToPathNoLocal path to write the raw bytes to (returns savedTo and kind "saved" instead of an inline payload). Must be inside the save root: GOOGLE_MCP_SAVE_ROOT, default ~/Downloads.
attachmentIdYesAttachment ID (from list_attachments). Gmail rotates it on every fetch, so pass partId when you can.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed5 schema fields changedv0.1.102
    • changedInput schema / properties / attachmentId / description
      Previous value: -"Attachment ID (from list_attachments)."New value: +"Attachment ID (from list_attachments). Gmail rotates it on every fetch, so pass partId when you can."
    • addedInput schema / properties / filename
      Added value: +{
      +  "description": "Filename from list_attachments; disambiguates when Gmail has rotated attachmentId.",
      +  "type": "string"
      +}
    • addedInput schema / properties / mimeType
      Added value: +{
      +  "description": "MIME type from list_attachments; narrows the filename match.",
      +  "type": "string"
      +}
    • changedInput schema / properties / partId / description
      Previous value: -"Stable part ID (from list_attachments); preferred over attachmentId for lookup."New value: +"Stable part ID (from list_attachments); preferred over attachmentId for lookup. Pass \"\" for an attachment on the message root part."
    • addedInput schema / properties / size
      Added value: +{
      +  "description": "Size in bytes from list_attachments; narrows the filename match.",
      +  "maximum": 9007199254740991,
      +  "minimum": 0,
      +  "type": "integer"
      +}
  2. Changed2 schema fields changedv0.1.95
    • addedInput schema / properties / maxBytes
      Added value: +{
      +  "description": "Inline size limit in bytes (default 6 MB), measured on the JSON-RPC frame the client receives. Escaping can inflate a payload (base64 ~1.33x, NUL-heavy text ~7x). Ignored when saving to disk.",
      +  "exclusiveMinimum": 0,
      +  "maximum": 9007199254740991,
      +  "type": "integer"
      +}
    • addedInput schema / properties / saveToPath
      Added value: +{
      +  "description": "Local path to write the raw bytes to (returns savedTo and kind \"saved\" instead of an inline payload). Must be inside the save root: GOOGLE_MCP_SAVE_ROOT, default ~/Downloads.",
      +  "type": "string"
      +}
  3. Addedv0.1.30

TDQS

A3.8/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations exist, so the description carries the full burden, and it does disclose real behavior: text-like files come back decoded, binary as base64, oversized inline payloads are rejected with the limit measured on the JSON-RPC frame (~1.33x base64 inflation). It still says nothing about auth/account requirements, side effects on the message, or error shapes beyond the size rejection.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Four tight sentences, front-loaded with the core action, then escalation threshold, then fallback, then the measurement caveat. No filler or repetition.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

With 9 parameters, no annotations, and no output schema, the description covers the essential return-shape distinction (decoded text vs base64 vs saved-to-disk) and the size guardrail. Auth/account behavior and failure modes remain undocumented, so it is strong but not complete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the baseline is 3; the parameters are fully documented upstream, including partId versus rotating attachmentId and saveToPath's save-root constraint. The description reinforces saveToPath's role and the maxBytes semantics but introduces no parameter meaning the schema lacks.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource: "Download a single attachment by message ID and attachment ID." The scope is immediately clear, though it never names google_gmail_list_attachments as the prerequisite for obtaining those IDs, leaving sibling differentiation implicit.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Gives concrete conditional guidance: if the inline result would exceed 6 MB, the call is rejected, so pass saveToPath instead. What is missing is the upstream step (use list_attachments to get partId/attachmentId) and any statement of when to prefer a different retrieval tool.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Deploy Server

Other Tools