Skip to main content
Glama

get_doc_as_markdown

Read-only

Export a Google Doc's content as GitHub-flavored Markdown, including headings, lists, tables, and images. Optionally append open comments or write the Markdown to a local file.

Instructions

Export a Google Doc's content as GitHub-flavored Markdown.

The inverse of create_doc/write_doc_content's content_format='markdown' path — walks the Docs API structure into this project's own AST and serializes it to Markdown, rather than converting Docs' own HTML export. Supports headings, bold/italic/strikethrough/links, nested bullet and numbered lists, task-list checkboxes, blockquotes, inline code and code blocks, images, and tables (including nested tables, best-effort — see Known limitations below).

Args: doc_id: The Google Doc file ID. include_comments: When True, appends a "## Comments" section listing every open (non-resolved) comment's author, quoted anchor text, content, and replies, via the same Drive comments resource list_doc_comments uses. Default False. local_path: Optional local filesystem path to write the Markdown to instead of returning it inline. The file holds the raw Markdown text (UTF-8), byte-identical to the inline markdown field, including the comments section when include_comments is True. A directory path writes <doc_id>.md inside it; 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. Bypasses the response-size cap.

Returns: Dictionary with doc_id, title, and markdown (the full Markdown text) — or {local_path, doc_id, title, bytes_written} if local_path is set. Raises ValueError if the response exceeds a safety cap (see MAX_TOOL_RESPONSE_CHARS in docs/configuration.md) and local_path is not set.

Known limitations: - A table nested inside another table's cell has no Markdown table syntax to express it — that cell renders a placeholder note instead (the write side has the identical gap in reverse; see docs/design/markdown-support.md's "What this does NOT do"). - Inline images resolve to Drive's temporary contentUri, which expires (roughly 30 minutes) — re-export if the Markdown is consumed well after generation. - Only the document's default tab is read (matches get_doc_structure's existing scope) — multi-tab documents are out of scope. - namedStyleType TITLE/SUBTITLE map to H1/H2; Markdown has no equivalent to Docs' distinct Title/Subtitle paragraph styles. - Merged table cells (colspan/rowspan) render best-effort: GFM pipe tables have no merge concept, so a spanned cell's text lands in its first column and the rest render blank.

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": {
      "doc_id": "<doc_id>"
    },
    "name": "get_doc_as_markdown"
  }
}

Input Schema

NameRequiredDescriptionDefault
doc_idYes
local_pathNo
include_commentsNo

Output Schema

NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.7/5.0
Behavior5/5

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

Annotations only declare readOnlyHint, but the description adds substantial behavior: a response-size safety cap that raises ValueError, local_path semantics (directory creation, ValueError on bad paths, replacement of existing files), and the fact that it bypasses the cap. The Known limitations section discloses image contentUri expiry (~30 min), single-tab scope, and best-effort table handling — exactly the operational caveats an agent needs.

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-loaded with the one-line purpose, then cleanly sectioned into Args, Returns, and Known limitations, so an agent can skim. It is on the long side and a few clauses restate the same idea (byte-identical file contents described twice), but nearly every sentence carries actionable information rather than filler.

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 three-parameter read tool, the definition covers inputs, both return shapes, the error condition, and the real-world limitations of the conversion. An output schema exists, and the description still summarizes the two response variants, which makes the tool callable without further discovery.

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 does: doc_id is identified as the Drive file ID, include_comments explains the appended "## Comments" section with its fields and default False, and local_path documents directory-vs-file resolution, trailing-slash behavior, creation of missing directories, and error conditions. This adds meaning well beyond the bare anyOf/string types in the schema.

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 with output format: "Export a Google Doc's content as GitHub-flavored Markdown." It further distinguishes itself by naming the inverse path in create_doc/write_doc_content and by framing the walk of the Docs API structure rather than Drive's HTML export, so an agent can separate it from get_doc_content or get_doc_structure without opening a schema.

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 context for when this is the right call — round-tripping content authored through write_doc_content's markdown format — and explains the local_path route as the escape hatch when output is large. It stops short of explicitly stating when to prefer get_doc_content or get_doc_structure instead, so selection against those siblings is left partly to inference.

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