Skip to main content
Glama

write_doc_content

Destructive

Replaces an existing Google Doc's full content with HTML or Markdown, including headings, lists, tables, links, code blocks, and images. Creates a backup before clearing the doc when possible.

Instructions

Replace the full content of an existing Google Doc.

Content is interpreted as HTML by default. Pass content_format='markdown' to supply Markdown instead. Headings, paragraphs, lists, links, tables, fenced code blocks, task list items, and images are all supported. Each table is inserted where it appears in the content. In HTML, a line break inside a tag's text is a space, as a browser shows it: use or (or Markdown) for line structure. Plain text with no tags at all keeps each line as its own paragraph. Use this to populate a doc created manually in Drive (bypassing service account storage quota limits).

Images are embedded inline the same way create_doc's own content_format='markdown' path handles them — see that tool's docstring for the src conventions, the revoke_sharing tradeoff, the auto_downscale size-limit behavior, and the alt-text fallback. A local-path image is uploaded to folder_id, else the server's default folder, else the doc's own folder. If the content has a local-path image this server can read and none of those is known (or the doc's folder can't be looked up), the call returns an error and leaves the doc unchanged. A local-path image it can't read (a missing file, or one LOCAL_FILE_ACCESS refuses) doesn't stop the call: it's written as its alt text, like any image that can't be embedded. A relative path that doesn't exist as written is also tried percent-decoded ("my%20pic.png").

Args: doc_id: The Google Doc file ID. content: Content to write into the document body. content_format: 'html' (default) or 'markdown' autolink_urls: When content_format='markdown', whether a bare http(s):// URL, www. address or email address becomes a real hyperlink (default True). Set False to leave them as plain text; to suppress just one, wrap it in backticks instead. revoke_sharing: Whether a local-path/drive: image's temporary anyone:reader share is revoked again after it's embedded (default True). An image file that was already link-shared before the call keeps its link and is reported with already_shared: true. auto_downscale: Resize an oversized local-path/drive: image instead of failing it (default False) — see create_doc's own docstring. allow_no_backup: Replace the content even when Drive refuses the backup copy (below) because the doc's sharing settings don't allow this account to copy it, or the account is at its item-creation limit (default False: the call refuses and leaves the doc unchanged). It has no effect when the account can't edit the doc. folder_id: Optional Google Drive folder ID to upload local-path images into. Defaults to the server's default folder, else the doc's own folder.

Returns: Confirmation with the document ID and web link. Includes "images" (per-image outcomes) when content contained any images. Includes "dropped_links" when a link was written as plain text instead (see create_doc). Includes "warning" if the backup copy (below) couldn't be removed, or if the content was replaced without one. Before clearing a doc that has content, a full copy of it is made in Drive, next to the doc, and deleted again once the new content is in. If the copy fails, nothing is changed and an error is returned, except when Drive refuses it for storage quota, because the account can't add a file to the doc's folder, or because the folder or Shared Drive is at its item limit: the replace then goes ahead without a backup. When sharing settings don't allow copying or the account is at its item-creation limit, it goes ahead without a backup only with allow_no_backup=True. If writing the new content fails, returns {"error", "docId", "backupId", "images", "dropped_links"} instead, with any temporary image share already revoked: the doc may be empty or partly written, and backupId is the kept copy of its previous content. When the replace went ahead without a backup there's no backupId, and the error says the previous content couldn't be backed up: it can't be recovered. The content is converted before any of this, so if it can't be converted, the doc is left unchanged and {"error", "docId"} is returned.

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>",
      "content": "<content>"
    },
    "name": "write_doc_content"
  }
}

Input Schema

NameRequiredDescriptionDefault
doc_idYes
contentYes
folder_idNo
autolink_urlsNo
auto_downscaleNo
content_formatNohtml
revoke_sharingNo
allow_no_backupNo

Output Schema

NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.4/5.0
Behavior5/5

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

Far exceeds the destructiveHint=true annotation: it discloses the full-copy backup made before clearing, the conditions under which the backup is skipped (quota, folder item limits, sharing restrictions, allow_no_backup), and the precise failure semantics including which keys are returned and whether the previous content is recoverable. Image handling, temporary share revocation, and the local-path error path are all disclosed. No behavioral surprises remain for a destructive operation.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The opening line is correctly front-loaded and the Args/Returns structure aids scanning, but the backup behavior is described essentially twice — once under allow_no_backup and again at length in Returns — and two parameters punt to create_doc's docstring. For a destructive 8-parameter tool the length is defensible, yet a tighter version would lose no actionable information.

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

Completeness5/5

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

Given a destructive overwrite, eight parameters with zero schema coverage, and an output schema, the description still covers rollback guarantees, error payload shapes, partial-write states, and image outcomes. An agent has everything needed to decide whether to call it and how to interpret both success and failure.

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

Parameters5/5

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

Schema description coverage is 0%, so the description carries the entire burden and does: all eight parameters are documented in an Args block, including defaults, interactions with content_format (autolink_urls), and non-obvious semantics (allow_no_backup has no effect when the account can't edit; folder_id falls back to default folder then the doc's own folder). The only weakness is deferring image src conventions and auto_downscale details to create_doc's docstring, which the parameter meaning itself still summarizes.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

Opens with a specific verb and resource plus scope: "Replace the full content of an existing Google Doc," which is materially different from an insert or range-edit operation. It also states the ancillary use case of populating a manually-created doc to bypass service-account storage quota. It does not name a sibling alternative (e.g. insert_doc_text) to contrast with, so it stops short of a 5.

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 a concrete when-to-use: populate a doc created manually in Drive, bypassing service account storage quota limits, and clarifies the default HTML interpretation versus content_format='markdown'. There are no explicit exclusions or named alternatives for partial edits or appends, leaving the agent to infer that this tool always overwrites the whole body.

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