get_doc_structure
Return a Google Doc body's structural map with element, paragraph, and table cell indices so you can target insert, delete, style, and table operations precisely.
Instructions
Return the full structural map of a Google Doc body with element indices.
Every batchUpdate operation (insert, delete, style, table) requires knowing the startIndex and endIndex of the target element. This tool exposes those indices alongside paragraph styles, text run formatting, and table cell positions.
Args: doc_id: The Google Doc file ID.
Returns: Dictionary with docId, title, and an elements list. Each element has: - type: "paragraph" | "table" | "sectionBreak" | "tableOfContents" - startIndex, endIndex Paragraphs also include namedStyleType, text, headingId (Google's internal ID for this heading, present only when namedStyleType is HEADING_1..6 — e.g. "h.abc123"; null otherwise), a runs list (each run has text, bold, italic, underline, strikethrough, font_size, link_url; an inline image is a run with type "inlineObject", its inlineObjectId, and its own startIndex/endIndex, and empty text), and bullet (null for a non-list paragraph; otherwise {listId, nestingLevel} — nestingLevel is 0 for a top-level list item, absent from the raw API response in that case, normalized to 0 here so every list paragraph reports a level). Use this to detect a markdown-to-Doc conversion that flattened an intended nested list — sibling paragraphs that should differ in depth but share the same nestingLevel — then fix it with create_paragraph_bullets. Tables include rows, columns, and a cells list (each cell has row, col, startIndex, endIndex, paragraphStartIndex, text).
Note: headingId is the piece needed to build a working in-doc jump link: set link_url via style_doc_range to f"https://docs.google.com/document/d/{doc_id}/edit?tab=t.0#heading={heading_id}" — an ordinary URL, no special Link-object field required. Confirmed live 2026-07-24 (issue #409).
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_structure"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| doc_id | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||