Skip to main content
Glama

update_doc_from_file

Destructive

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 "alt" 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

NameRequiredDescriptionDefault
doc_idYes
folder_idNo
local_pathYes
autolink_urlsNo
auto_downscaleNo
content_formatNo
revoke_sharingNo
allow_no_backupNo

Output Schema

NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv0.9.6

TDQS

A4.9/5.0
Behavior5/5

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

The destructiveHint annotation is consistent with replacing a doc's content, and the description adds substantial behavior beyond annotations: backup-copy creation and cleanup, allow_no_backup exceptions, image embedding rules, permission constraints, and partial-write recovery details. This is unusually transparent for a destructive in-place update.

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?

The description is front-loaded and organized, with clear sections for behavior, Args, and Returns. However, it is very long and repeats backup/return details that are already available in the output schema, and it defers some image-specific conventions to create_doc's docstring rather than keeping everything self-contained.

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?

For an eight-parameter destructive file-to-doc replacement with backup and image semantics, the definition is complete enough to call correctly. Annotations cover the destructive profile, the output schema covers return structure, and the description fills in the operational edge cases an agent needs.

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 must carry parameter meaning, and it does. It documents every parameter, including content_format inference, autolink_urls behavior, revoke_sharing, auto_downscale, allow_no_backup, and folder_id fallback rules.

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?

The description states a specific verb and resource: replace an existing Google Doc's content in place from a local .md or .html file. It explicitly distinguishes this operation from create_doc_from_file and write_doc_content, so an agent can tell exactly what this tool does and why it exists.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

It gives explicit routing guidance against alternatives: use this instead of create_doc_from_file to avoid a duplicate Doc, and instead of write_doc_content to avoid reading the file into the caller's context. It also names a clear precondition, LOCAL_FILE_ACCESS=off, which prevents misinvocation.

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