Skip to main content
Glama
cybersmurf
by cybersmurf

Open an attachment

mail_get_attachment
Idempotent

Download an email attachment, save it to disk, and return extracted text or image content; OCR handles scans and photos, other file types return the saved path.

Instructions

Downloads an attachment of a received message, saves it to disk and returns its content: text for text files, the text of every page for PDFs, the picture for images. Scans (PDF pages without a text layer) and photos of documents are read through OCR, tables included; pages that came from OCR are marked “(OCR)” — treat numbers from them with some caution and ask for a preview when a figure matters. Other types (docx, xlsx, zip…) only return the path of the saved file. Pick the attachment by name or by its number from the list in mail_get_email; a message with a single attachment needs neither. The message itself is not changed.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesMessage id (from mail_search_emails / mail_get_email).
ocrNofalse = do not send scans and photos to the OCR provider, return the image only.
accountNoWhich account: leave empty for the signed-in mailbox, or name a shared mailbox / group you have access to (the part before @ is enough; a full address works too). mail_list_mailboxes shows what exists.
page_toNoPDF: last page to return (default: the last one).
previewNoPDF: also attach an image of page 1 (chart, stamp, signature, checking the OCR).
save_dirNoFolder to save the file to; default /root/Downloads/Mail-Attachments.
page_fromNoPDF: first page to return (default 1).
attachmentNoAttachment name (a part is enough, e.g. “invoice”) or its number starting at 1.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv2.3.0

TDQS

A4.6/5.0
Behavior5/5

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

Annotations only give a coarse profile (readOnlyHint=false because it writes to disk, destructiveHint=false, idempotentHint=true). The description adds substantive behavior: OCR is applied to scans/photos, OCR pages are marked '(OCR)' with a caution about their numbers, other types return only a saved path, and the source message is not modified.

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

Conciseness4/5

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

Front-loads the return format, then the OCR caveat, then selection guidance — a logical order. Sentences are dense with parentheticals but each carries actionable content; slightly longer than strictly necessary.

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

Completeness5/5

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

With no output schema, the description carries the return-value burden and does so thoroughly (text/PDF/image/OCR/other types). Combined with 100% schema coverage and annotations covering the safety profile, an agent has everything needed to call and interpret this tool.

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

Parameters4/5

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

Schema coverage is 100%, so the baseline is 3, but the description adds real meaning beyond the schema: the 'attachment' parameter can be a partial name or a 1-based number, and OCR marking/preview behavior is tied to how results should be interpreted. It does not restate the page/save_dir/account parameters, which the schema already documents well.

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

Purpose5/5

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

States a specific verb+resource with clear scope: downloads an attachment of a received message, saves it to disk, and returns its content. It also specifies the per-type return behavior (text/PDF/image), which lets an agent distinguish it from mail_get_email at a glance.

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?

Tells the agent how to select the attachment (by name or number from mail_get_email, unnecessary for single-attachment messages) and routes to mail_get_email as the source of the list. It also advises asking for a preview when a figure matters. It stops short of stating explicit when-not-to-use conditions (e.g. attachments that cannot be retrieved).

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