apply_theme
Apply a theme dict to a Google Doc by updating named style defaults for text and tables. Optionally overwrite existing paragraph styles to restyle all current content.
Instructions
Apply a theme dict to a Google Doc by updating its named style definitions.
By default (overwrite=False), theme entries are applied as document-level named style defaults via updateNamedStyle. Paragraphs that have explicit individual style overrides are unaffected — their styles take precedence over the named style defaults. This preserves intentional per-paragraph variations (e.g. a section deliberately styled in a different colour). One exception: a NORMAL_TEXT entry with space_above or space_below replaces the 10pt space below a paragraph that a Markdown or HTML write leaves between paragraphs, so the theme's spacing shows.
For AI-generated docs where all content uses explicit paragraph/run styles, the default mode updates the named style definitions but does not visually change existing content. New paragraphs added without explicit styles will inherit the updated named style defaults.
Set overwrite=True to also apply the theme directly to all existing paragraphs, overwriting their current styles including any individual overrides.
Theme entry keys (NORMAL_TEXT, HEADING_1-6, TITLE, SUBTITLE). Each entry can include (all optional): font_family (str), font_size (float, points), bold (bool), italic (bool), color (dict {"red": 0-1, "green": 0-1, "blue": 0-1}), line_spacing (float, 100=single, 115=1.15x, 150=1.5x), space_above (float, points), space_below (float, points)
An optional "table" key applies styling to every table currently in the document: border_color (dict), border_width (float, points), border_dash_style (str, default "SOLID"), border_top, border_right, border_bottom, border_left (dict): optional per-edge override, each {"color": {...}, "width": float, "dash_style": str}. Any field omitted from a per-edge dict falls back to the uniform border_color/border_width/border_dash_style above, if given (the Docs API rejects a border with non-zero width and no color as "transparent", so a width-only override needs a color from somewhere). An edge with no border_ key falls back entirely to the uniform border_color/ border_width/border_dash_style, if given. cell_padding (float, points — all four sides), header_background (dict) — first row only
Args: doc_id: The Google Doc file ID. theme: Theme dict. See above for schema. overwrite: If True, also apply styles directly to existing paragraphs, overwriting individual per-paragraph style overrides.
Returns: Confirmation with docId and count of batchUpdate requests sent.
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>",
"theme": "<theme>"
},
"name": "apply_theme"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| theme | Yes | ||
| doc_id | Yes | ||
| overwrite | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||