Skip to main content
Glama

get_message

Read-only

Fetch a single Gmail message by ID to retrieve headers, body content, and attachment metadata, with optional local-file output or metadata-only retrieval.

Instructions

Fetch a single message by ID, including headers, body, and attachment metadata.

Args: message_id: The Gmail message ID (from list_messages or get_thread). local_path: Optional local filesystem path (file or directory) to write the message JSON to instead of returning it inline. Bypasses the response-size cap, for messages with very large bodies. A path ending in '/' is a directory, created if missing. A file in place of a parent directory, or at a path ending in '/', raises ValueError; an existing file at a plain file path is replaced. include_body: When False, fetch only metadata (Gmail's format='metadata'): no body is downloaded, and body_plain, body_html, and attachments are left out of the result.

Returns: Message with id, thread_id, snippet, label_ids, headers (from/to/cc/bcc/ subject/date/message_id), body_plain, body_html, and attachments metadata (filename, mime_type, size, attachment_id). A large body that Gmail delivers separately is fetched and returned in body_plain/body_html like any other. A text part whose data can't be decoded leaves its body null and is listed in body_decode_errors; a separately delivered body that can't be fetched leaves its body null and is listed in body_fetch_errors (both: part_id, mime_type, error, plus attachment_id for a separately delivered part; present only when non-empty). Raises an error naming the size if the message is over the response-size cap and local_path is not set; a separately delivered body already over the cap raises before being downloaded. If local_path is set, returns {local_path, message_id, bytes_written} instead, plus body_fetch_errors / body_decode_errors (each entry with message_id) when present. With include_body=False, only id, thread_id, snippet, label_ids, internal_date, size_estimate, and headers. On API failure, {"error": "..."}.

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": {
      "message_id": "<message_id>"
    },
    "name": "get_message"
  }
}

Input Schema

NameRequiredDescriptionDefault
local_pathNo
message_idYes
include_bodyNo

Output Schema

NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv0.9.6

TDQS

A4.7/5.0
Behavior5/5

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

Goes far beyond readOnlyHint=true: it documents the response-size cap and that an over-cap message raises unless local_path is set, that a path ending in '/' is treated as a directory and created if missing, that a file at a directory path or trailing-slash path raises ValueError, and that an existing file at a plain file path is replaced. It also discloses failure modes (body_decode_errors, body_fetch_errors with part_id/mime_type/error) and the changed return shape when local_path is used.

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?

Well front-loaded with a one-line summary followed by Args and Returns sections, and nearly every sentence carries operational meaning. The Returns section is long and partly restates fields already captured by the output schema, and the two parallel error-list paragraphs are dense enough to slow scanning.

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?

For a read tool with three parameters, an output schema, and a size-cap workaround, the definition covers the tool call, the alternate file-output mode, the reduced-field mode, and both error channels. An agent has everything needed to invoke it correctly and interpret the compacted result form.

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

Parameters5/5

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

Schema description coverage is 0%, so the description carries the full burden, and it does: message_id is tied to its sources, local_path has full file-vs-directory and overwrite semantics, and include_body explains exactly what Gmail mode it maps to and which result fields disappear.

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 and resource ("Fetch a single message by ID") plus the payload scope (headers, body, attachment metadata), and orients the agent by naming where the ID comes from (list_messages or get_thread), which positions it against those siblings.

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 clear conditional guidance for the two optional parameters: use local_path to bypass the response-size cap for very large bodies, and include_body=False when only metadata is wanted. It stops short of an explicit "use get_thread instead when you want the whole conversation," so routing against siblings is implied rather than stated.

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