create_paragraph_bullets
Convert Google Docs paragraph ranges into bulleted or numbered lists with explicit nesting depth, handling existing-list quirks so repeated calls keep levels stable.
Instructions
Turn one or more paragraph ranges into a bulleted or numbered list, with explicit nesting depth.
Wraps the Docs API's createParagraphBullets/deleteParagraphBullets requests, working around two confirmed-live API quirks:
createParagraphBullets is a no-op on a paragraph that's already part of a list — it neither changes the existing nesting level nor consumes any leading tab characters meant to signal a new one (they're left behind as literal text). Every paragraph this tool touches is deleteParagraphBullets'd first (harmless even if it wasn't previously a list item) so createParagraphBullets always applies to a clean, non-list paragraph. deleteParagraphBullets keeps a removed item's indent, which createParagraphBullets would read as extra depth, so the tool also zeroes each paragraph's indentation before bulleting it. nesting_level is therefore absolute: repeating the same call changes nothing.
createParagraphBullets has no nestingLevel field of its own — the API infers each paragraph's depth from its own leading tab characters, but only relative to whatever ELSE is included in that same call. A paragraph immediately adjacent to an existing list item that call doesn't also cover gets pulled back to that neighbor's level regardless of its own tabs (the same class of bug PR #432 fixed in this project's own markdown-to-Doc converter). To keep every requested paragraph's relative depth correct, this tool fetches the document, resolves each requested range to the paragraph(s) it covers, and — for any that are already part of a list — expands the affected span to include their full contiguous run of same-list neighbors (preserving each neighbor's own current nesting level unchanged). Contiguous spans sharing one bullet preset are then submitted as a single createParagraphBullets call each, applied in descending document-position order so no not-yet-processed span's indices are invalidated by an earlier span's tab insertions. A span in which every paragraph sits at nesting_level > 0 (no level-0 member to anchor the API's relative depth inference) is wrapped with a throwaway 0-tab anchor paragraph that is bulleted alongside the real items and then deleted, so the items land at their true nesting level instead of collapsing to 0 (issue #713; the same fix emitter.py carries for #439).
Use get_doc_structure to obtain start_index/end_index for each target range — typically one paragraph's own startIndex/endIndex, or a contiguous span covering several (all promoted to the same nesting_level/bullet_preset). For independent depths per paragraph, pass one range per paragraph.
Args:
doc_id: The Google Doc file ID.
ranges: List of range dicts, each with:
start_index (int), end_index (int): from get_doc_structure —
must overlap at least one existing paragraph.
bullet_preset (str, optional): "BULLET_DISC_CIRCLE_SQUARE"
(unordered) or "NUMBERED_DECIMAL_ALPHA_ROMAN" (ordered) —
the only two presets this codebase has confirmed live
(see emitter.py). The Docs API defines additional
glyph/numbering presets not exercised here; pass the
literal API enum string to use one anyway. If omitted,
an already-listed target paragraph keeps its existing
list's own style (read from the document's own lists
map) rather than silently being converted to a
different one; a paragraph with no existing list falls
back to "BULLET_DISC_CIRCLE_SQUARE".
nesting_level (int, optional): 0 = top-level (default), 1 =
one level indented, etc. Must be >= 0.
Returns: Confirmation with docId and count of batchUpdate requests sent. {"error": ...} if ranges is empty, a nesting_level is negative, a range doesn't overlap any paragraph, two explicitly-requested contiguous paragraphs specify conflicting presets, or the Docs API call fails.
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>",
"ranges": "<ranges>"
},
"name": "create_paragraph_bullets"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| doc_id | Yes | ||
| ranges | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||