Get Doc Content
get_doc_contentRetrieve text and document content from Google Docs or Drive files by ID. Works with native docs and Office files, preserving index alignment for precise editing or providing readable context with semantic annotations.
Instructions
Retrieves content of a Google Doc or a Drive file (like .docx) identified by document_id.
Native Google Docs: Fetches content via Docs API.
Office files (.docx, etc.) stored in Drive: Downloads via Drive API and extracts text.
By default, native Google Docs text is index-aligned with the document: empty paragraphs are preserved and every non-text element that occupies an index (inline object, page break, footnote reference, ...) is rendered as one U+FFFC placeholder per index. The document body starts at index 1, so an offset n into the text that follows "--- CONTENT ---" is document index n + 1, and that index can be passed straight to format_text or delete_text. Tables and multi-tab documents interleave separators, so alignment holds up to the first table or tab header.
Set preserve_context=True for readable link destinations, internal targets, smart-chip values, table boundaries, headers, footers, footnotes, and object context exposed by the Docs API. This output is plain text, not Markdown, and its offsets must not be used as document editing indices. Comments, revision history, exact visual layout, and chip details hidden by the API are not included. Use get_doc_as_markdown for formatting or comments.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| tab_id | No | Optional ID of a single tab to read (from inspect_doc_structure). When given, only that tab's content is returned with no tab separator, so the default output stays index-aligned with that tab. When omitted, every tab is returned with "--- TAB: ... ---" markers. | |
| document_id | Yes | ID of the Google Doc (or full URL) | |
| preserve_context | No | Include readable semantic annotations for native Docs. Defaults to False to retain index alignment. Office extraction is unaffected. With tab_id, only the selected tab is rendered. | |
| user_google_email | Yes | User's Google email address | |
| suggestions_view_mode | No | How to render suggestions in the returned content: - "DEFAULT_FOR_CURRENT_ACCESS": Default based on user's access level - "SUGGESTIONS_INLINE": Suggested changes appear inline in the document - "PREVIEW_SUGGESTIONS_ACCEPTED": Preview as if all suggestions were accepted - "PREVIEW_WITHOUT_SUGGESTIONS": Preview as if all suggestions were rejected | DEFAULT_FOR_CURRENT_ACCESS |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |