update_doc_from_file
Replace an existing Google Doc's content in place from a local Markdown or HTML file, preserving its ID, URL, permissions, and Drive location without creating a duplicate.
Instructions
Replace an existing Google Doc's content in place from a local .md or .html file. Not available when the server runs with LOCAL_FILE_ACCESS=off.
Reads local_path server-side the same way create_doc_from_file does (file format inferred from extension, or pass content_format to override), then replaces the doc's content the same way write_doc_content does — preserving the doc's ID, URL, permissions, and Drive location. Unlike calling create_doc_from_file again, this never mints a duplicate Doc, and unlike write_doc_content, the caller never has to read the file into its own context — the server reads it directly.
Images referenced from the file (markdown "" or HTML )
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 relative local image path is relative to the file's own
folder, as in a README. A local-path image is uploaded to folder_id, else the
server's default folder, else the doc's own folder. If the file 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 to update in place. local_path: Absolute or relative path to the local file. content_format: 'markdown' or 'html'. Defaults to inferring from local_path's extension (.md -> markdown, .html/.htm -> html); pass explicitly to override the extension-based guess. autolink_urls: For markdown content, 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. No effect on HTML content. 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 the file 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>",
"local_path": "<local_path>"
},
"name": "update_doc_from_file"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| doc_id | Yes | ||
| folder_id | No | ||
| local_path | Yes | ||
| autolink_urls | No | ||
| auto_downscale | No | ||
| content_format | No | ||
| revoke_sharing | No | ||
| allow_no_backup | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||