Skip to main content
Glama

insert_local_images

Destructive

Upload local image files to Drive and replace plain-text markers in a Google Doc with those images in one call. Use this to insert multiple local images without manual upload, find, insert, and delete steps.

Instructions

Upload local image files to Drive and swap each into a Google Doc at a plain-text marker, in one call. Not available when the server runs with LOCAL_FILE_ACCESS=off.

Typical flow: write doc content with a unique plain-text placeholder per image (e.g. "IMGMARKERONE") via create_doc/write_doc_content/insert_doc_text, then call this tool once with the marker → local file mapping. Collapses the N manual upload/find/insert/delete round trips a multi-image doc would otherwise need into a single call.

For each image: uploads the local file to Drive, shares it as anyone-with-link/reader (required — the Docs backend fetches inline images as an anonymous HTTP request, so a private file fails with "There was a problem retrieving the image"; confirmed live 2026-07-18), locates its marker's current position, inserts the image immediately before the marker text, then deletes the marker text. Once the image is actually embedded, that temporary share is revoked again by default (revoke_sharing=True) — revoking any earlier would break the embed, since Docs fetches the image at insertion time, not upload time. The revoke also runs if the document edit fails or the call is cancelled; a cancelled call returns nothing, so the uploaded file IDs are logged as a warning instead.

All markers are located in a single pass over the document's current text before any edits are applied — markers are matched longest-first at each position, so one marker that's a substring of another (e.g. "IMG1" vs "IMG10") can't produce a false match or a false "occurs twice" collision. Uploads and shares run in parallel; the document edit is one batchUpdate applied highest-index-first so replacing one marker never invalidates another marker's already-computed position — same convention as insert_doc_text/delete_doc_range. Uploading and sharing happen before any document edit, so a failed upload never leaves the doc partially edited.

Args: doc_id: The Google Doc file ID. images: List of image dicts, each with: marker (str): exact literal text already present in the doc body, marking where this image goes. Matched as a whole token — not immediately preceded or followed by another letter, digit, or underscore — so a marker like "IMG1" can't falsely match inside unrelated text like "IMG10". Must occur exactly once in the document (searched case-sensitively) — an ambiguous or missing marker fails just that image, not the whole call. local_path: absolute path to the local image file. width, height (float, optional): image size in points. folder_id: Drive folder to upload images into. Defaults to the server's configured default folder. revoke_sharing: Whether each image's temporary anyone:reader share is revoked again after it's embedded (default True). Set False to leave images shared instead — matches this tool's original behavior. A file that was already link-shared before the call (e.g. inherited from its folder) keeps its link and is reported with already_shared: true. auto_downscale: Google Docs rejects any inline image over ~25 megapixels or ~50MB. Each image's local file is checked against both limits before it's ever uploaded. The default (False) fails just that image with a clear error naming the limit and its actual size — other images in the same call are unaffected. Set True to instead resize an oversized image and upload the resized copy (the local file on disk is never modified); that outcome's entry gets downscaled: true.

Returns: Dictionary with docId and results — a list of per-image outcomes in the same order as the images argument, each echoing marker and local_path plus either fileId + index + shared (+ revoke_error if a revoke attempt failed, + downscaled: true if auto_downscale resized it, + already_shared: true if the file was link-shared before this call) on success, or error on failure (marker not found, marker not unique, local file missing, oversized with auto_downscale off, upload failure, sharing failure, or — rare, since uploads happen first — a failed document edit; that last case keeps fileId and shared, with no index, since the upload and share happened even though the image was never placed). A sharing failure after the underlying Drive file was already created also carries fileId (#649) — the upload itself succeeded even though the share didn't.

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>",
      "images": "<images>"
    },
    "name": "insert_local_images"
  }
}

Input Schema

NameRequiredDescriptionDefault
doc_idYes
imagesYes
folder_idNo
auto_downscaleNo
revoke_sharingNo

Output Schema

NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv0.9.6

TDQS

A4.7/5.0
Behavior5/5

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

Annotations only declare destructiveHint=true; the description adds far more: temporary anyone:reader sharing is required for the Docs backend to fetch, revocation happens after embed by default and also on failure/cancel, uploads run parallel and precede all edits so a failed upload never half-edits the doc, and edits are a single highest-index-first batchUpdate. It also discloses marker tokenization and uniqueness rules and that a bad marker fails only that image.

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?

Front-loaded with the one-line purpose, then availability, then flow, then per-image mechanics and args. Dense but largely earned; some parentheticals (e.g. 'confirmed live 2026-07-18', '#649') and a very long Returns block restating the output schema add bulk.

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 a high-complexity composite operation with side effects, the description covers prerequisites, ordering guarantees, failure modes per image, sharing lifecycle and partial-failure outcomes. Even though an output schema exists, the per-image error enumeration makes the tool safely callable without further inference.

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 coverage is 0% and the images array is an untyped object, so the description carries the full burden — it defines marker, local_path, optional width/height, plus folder_id defaults, revoke_sharing semantics (including already_shared inheritance) and auto_downscale behavior against Docs' ~25MP/~50MB limits. This is meaning the schema cannot convey.

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?

Opens with a specific compound verb and resource: upload local image files to Drive and swap each into a Google Doc at a plain-text marker in one call. It is clearly distinct from insert_doc_text, insert_inline_image and upload_local_file because it fuses upload, share, insert and marker deletion into one operation.

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 an explicit when-to-use flow (write placeholders via create_doc/write_doc_content/insert_doc_text, then call once with the marker→file mapping) and a hard availability condition (unavailable with LOCAL_FILE_ACCESS=off). It does not explicitly say when to prefer insert_inline_image or upload_local_file instead, so a sibling-comparison gap remains.

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