Skip to main content
Glama

readDocument

Reads Google Docs content as markdown, plain text, structural index, or raw JSON, and saves a local working copy for reviewable edits before replacing document content.

Instructions

Reads the content of a Google Document. Returns markdown by default (formatted content suitable for editing and re-uploading with replaceDocumentWithMarkdown) and saves it to a local working-copy file (path included in the response). PREFERRED EDITING WORKFLOW for large edits: (1) readDocument to get the local file path, (2) edit that file locally, (3) call replaceDocumentWithMarkdown with filePath pointing to it. This avoids inline content truncation and gives you a reviewable working copy before pushing changes. If the document contains content markdown cannot represent (images, footnotes), a warning is appended listing what replaceDocumentWithMarkdown would permanently remove — prefer modifyText or appendMarkdown for those documents. Use format='text' for plain text, or format='index' to get a compact structural map (headings, list items and nesting, tables with per-cell indices) with the exact startIndex/endIndex every index-addressed tool needs. format='index' is the cheap way to find indices: it fetches a narrow field mask instead of the whole document, so it stays affordable even for tabbed documents. format='json' returns the raw, unpruned API structure and is only for callers that genuinely need suggestions or style provenance. Set diffFromLastRead=true (markdown only) to get a unified diff from your previous read in this session instead of the full content.

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": {
      "documentId": "<documentId>"
    },
    "name": "readDocument"
  }
}

Input Schema

NameRequiredDescriptionDefault
tabIdNoThe ID of the specific tab to read. If not specified, reads the first tab (or legacy document.body for documents without tabs).
formatNoOutput format: 'markdown' (formatted content), 'text' (plain text), 'index' (compact structural map with character indices — use this to find indices for modifyText/deleteRange/insertTable), 'json' (raw API structure, large and unpruned).markdown
fromIndexNoformat='index' only. Resume point: elements ending at or before this document index are dropped. Pass the nextFromIndex from a truncated index response to get the next page. The Docs API has no start-index cursor, so each page costs another (narrow) fetch.
maxLengthNoMaximum character limit for the returned content. Applies to text, markdown, and json output (not to index, which uses maxResponseChars and truncates at element boundaries). Must be a positive integer; omit it for the full document.
documentIdYesThe document ID — the long string between /d/ and /edit in a Google Docs URL.
plainMarkdownNoFor Google Docs markdown output only. If true, suppresses rich HTML-style formatting extensions and returns cleaner portable markdown. The local working-copy file and diff/conflict tracking always keep the rich version — for lossless editing, edit the working-copy file, not this plain text. Ignored (with a note) when diffFromLastRead is true.
writeLocalFileNoFor Google Docs markdown output only (format='markdown'). If false, this read does not touch the on-disk local mirror file at all — no overwrite, no backup, response text is unaffected. Use this to run a diffFromLastRead staleness check (or any read you do not intend to edit locally) without risking the mirror. When true (the default) and the SDK v2 runtime's per-handle capability system is not in play, this read overwrites the shared mirror at the path from a previous read of this document/tab; if that file's on-disk content is newer than this process's own last write to it (a local edit readDocument told you to make, still unpushed), it is backed up to '<path>.bak' first and the result says so — the overwrite still proceeds, so recover from the .bak file, not from a re-read.
diffFromLastReadNoIf true and this document has already been read in this session (with format=markdown), returns a unified diff from the previous read to the current document instead of the full content. Ignored on first read or when format is not markdown.
maxResponseCharsNoformat='index' only. Character budget for the serialized index. Truncation lands on element boundaries so the JSON is always valid. 0 disables the budget. Defaults to 100000.
stripInheritedStylesNoformat='json' only. If true, drops inherited textStyle/documentStyle/namedStyles and every suggested* map from the raw document. Every startIndex/endIndex is preserved. Off by default: format='json' means a faithful raw document.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv4.0.0-rc.1

TDQS

A4.5/5.0
Behavior4/5

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

With no annotations, the description carries the full burden and does substantial work: it discloses the on-disk side effect, the .bak backup on newer-content detection, that the overwrite still proceeds, and that unrepresentable content produces a removal warning. It stops short of stating auth/permission requirements or rate-limit behavior, and the writeLocalFile/SDK-v2 capability clause is dense enough that the practical default behavior takes effort to parse.

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

Conciseness3/5

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

Front-loaded with purpose and the preferred workflow, and most sentences carry unique information. However it is a single dense wall of text that mixes workflow guidance, per-format advice, and an intricate mirror-overwrite/backup caveat; bullet separation of the format choices and the side-effect warning would materially improve scannability.

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 10-parameter read tool with no output schema and no annotations, the description covers return shapes (markdown/text/index/json), where the working-copy path appears in the response, truncation and pagination cursors, and the warning appended for unrepresentable content. Nothing an agent needs to call it safely and interpret the result is missing.

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; the description still adds real meaning beyond the schema by framing 'index' as the cheap index-discovery path (narrow field mask), tying diffFromLastRead to session history, and cautioning that plainMarkdown's local mirror stays rich. It largely restates the format enum semantics that the schema already documents, which keeps it below a 5.

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?

Opens with a specific verb+resource ("Reads the content of a Google Document") and immediately enumerates the four output formats, so the agent knows exactly what it gets back. It explicitly contrasts itself with replaceDocumentWithMarkdown, modifyText, and appendMarkdown, so siblings are distinguishable without opening schemas.

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

Usage Guidelines5/5

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

Gives an explicit ordered workflow (read → edit local file → replaceDocumentWithMarkdown) plus conditions for each format: 'index' to find indices for modifyText/deleteRange/insertTable, 'text' for plain text, 'json' only for suggestions/style provenance. It also names when to avoid this path (images/footnotes → prefer modifyText or appendMarkdown), which is genuine when-not guidance.

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