get_doc_as_markdown
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
| Name | Required | Description | Default |
|---|---|---|---|
| doc_id | Yes | ||
| local_path | No | ||
| include_comments | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||