Skip to main content
Glama

get_doc_structure

Read-only

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

NameRequiredDescriptionDefault
doc_idYes

Output Schema

NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.1/5.0
Behavior4/5

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

Annotations declare readOnlyHint=true and the description is fully consistent with a safe read. It adds real behavior beyond the annotations: headingId is null unless namedStyleType is HEADING_1..6, an inline image is a run with type inlineObject and empty text, and nestingLevel is normalized to 0 even though the raw API omits it — that last point is a genuine data-shape disclosure an agent could otherwise misread as missing data.

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-loads purpose, then Args/Returns/Note sections — a clean, scannable structure. However, the Returns block is long and largely restates the output schema, and the closing Note is really cross-tool advice (building a jump link with style_doc_range) that could be tightened; not every line earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a single-parameter read tool with an output schema and read-only annotations, the description covers purpose, motivation, and key field semantics thoroughly. The only shortfall is that the sole parameter gets no elaboration, but little more is needed for a document ID.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Only one parameter with 0% schema description coverage, and the description supplies just "The Google Doc file ID." That is enough to distinguish a file ID from a URL or title, but adds no format, sourcing, or validation detail beyond the field name. Adequate rather than compensating for the coverage gap.

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 ("Return the full structural map of a Google Doc body") plus the distinguishing payload: element startIndex/endIndex. The second sentence explains why this tool exists relative to plain content readers like get_doc_content — it exposes indices needed by batchUpdate — so an agent can tell it apart from content-fetching siblings 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 concrete when-to-use conditions (any insert/delete/style/table operation needing index targets) and names follow-on tools by name: create_paragraph_bullets for fixing flattened nested lists and style_doc_range for setting link_url. It does not state when NOT to use this tool (e.g. read prose instead of structure) or name get_doc_as_markdown/get_doc_content as the alternative for pure content reads, so it falls short of a full when/when-not/alternatives treatment.

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