Skip to main content
Glama

sync_folder

Destructive

Synchronize files between a Google Drive folder and a local directory with bidirectional, upload, or download direction, plus conflict detection and dry-run previews.

Instructions

Sync files between a Google Drive folder and a local directory. Not available when the server runs with LOCAL_FILE_ACCESS=off.

Sync logic

Files are matched by name. For Google Workspace files (Docs, Sheets, Slides), the export extension is appended to form the local name — e.g. a Doc called 'Notes' with export_format='docx' matches the local file 'Notes.docx'. Workspace files with no export_format are skipped entirely — except a Doc produced by convert_markdown, which keeps its '.md' name and matches its local .md file directly regardless of export_format (see convert_markdown below).

For each matched name the action is decided as follows:

Drive only + direction includes download → download Drive only + direction is 'upload' → skip Local only + direction includes upload → upload Local only + direction is 'download' → skip Both sides, mtimes within 5 s tolerance → skip (already in sync) Both sides, mtimes match but byte sizes differ → conflict (content diverged; recency unknown — any direction) Both sides, mtimes and sizes match but md5 differs → conflict (use_checksum=True only; recency unknown — any direction) Both sides, local newer by > 5 s → upload (if direction includes upload) Both sides, Drive newer by > 5 s → download (if direction includes download) Both sides, conflict (direction mismatch) → skip, listed under 'conflicts'

A name that isn't a single ordinary filename (it contains '/' or '', is '.' or '..', etc.), for a file or a subfolder on either side, is never synced: it's listed under 'failed' (action 'unsafe_name' in a dry_run), unless it exists only on the side this direction wouldn't act on, where it's skipped as usual.

Modified times are compared in UTC. When a file is uploaded, its Drive modifiedTime is set to the local file's mtime so future syncs stay accurate. A convert_markdown Doc is the exception: its changes are tracked through properties and revision history instead (see convert_markdown below).

The "mtimes match but byte sizes differ" row (#659) exists because equal mtimes don't guarantee equal content: a rename-in-place (mv keeps the mtime) leaves a name pointing at different bytes with an unchanged timestamp, which the plain equal-mtime skip would hide permanently. Drive's size is already in the folder listing, so this check is nearly free (one stat) and runs during dry_run too. It is always a 'conflict', never an auto-transfer: the mtimes agree, so which side is newer is unknown, and a directional sync already reports 'conflict' rather than overwrite a target it can tell is newer. It only applies to non-Workspace files (Workspace and convert_markdown files report no size). A same-size content edit that also preserves mtime is still reported as "in sync" unless use_checksum=True (below) — hashing every within-tolerance pair by default would make every sync read every file.

When use_checksum=True, every name present on both sides is checked for a content match (local md5 vs. Drive's md5Checksum) before the direction decision above runs — a match is always treated as in sync regardless of how far apart the modifiedTimes are. This includes a pair whose mtimes are within tolerance and whose sizes match: a checksum mismatch there means a same-size, mtime-preserving content change, reported as a 'conflict' for every direction (recency unknown, same as the byte-size row above). A within-tolerance pair whose sizes already differ is reported by the byte-size row without being read. Every such file is read, so this costs a full read of the folder's matched content on every sync (run concurrently, a few files at a time). Skipped during dry_run, so this never turns a cheap preview into a full read of every file — an affected step's reason then ends in "(checksum not verified in dry_run)", since the real run may decide differently. This catches the cases mtime alone gets wrong. A local overwrite that preserves mtime hides a real change. A local regeneration that rewrites the same bytes reads as "local newer." A file created by upload_file (inline content, no local mtime to stamp) carries its upload time as modifiedTime, so a same-content local copy reads as changed. A local read failure for one file (deleted, permission-denied, etc.) reports that name under 'failed' rather than aborting the whole call. Only applies to files with a real md5Checksum — Google Workspace files (Docs, Sheets, Slides) and convert_markdown Docs have none and always fall back to the mtime comparison. A checksum mismatch doesn't change anything by itself when the mtimes disagree; it just falls through to the same mtime-based direction decision used when use_checksum=False.

direction values

'bidirectional' (default) — newer side wins; Drive-only files are downloaded, local-only files are uploaded. 'upload' — only push local changes to Drive; Drive-only files and Drive-newer files are left alone. 'download' — only pull Drive changes locally; local-only files and local-newer files are left alone.

recursive

By default (recursive=False) only files directly inside folder_id / local_path are considered — subfolders are ignored entirely, on either side.

When recursive=True, subfolders matched by name (same rules as files) are walked to any depth. A subfolder present on only one side is only descended into — and created on the missing side — when direction would actually create it there:

  • a Drive-only subfolder is downloaded (local dir created) when direction includes download; left alone under 'upload' direction.

  • a local-only subfolder is uploaded (Drive folder created) when direction includes upload; left alone under 'download' direction. Subfolders left alone this way are listed under 'folders_skipped' (relative path, trailing '/') instead of being silently ignored.

dry_run

When dry_run=True no files or folders are created/transferred, local_path included: a local_path that doesn't exist yet is planned as empty. 'uploaded', 'downloaded', 'skipped', 'conflicts', and 'failed' are always empty in this mode (nothing was materialized to report there) — the response instead includes an 'actions' list with {name, action, reason} for every file considered at every level visited; this is the complete, non-redundant picture of what a real run would do and why, without duplicating each name into a second, action-labelless list alongside it (#512).

Progress

File transfers within each level run concurrently rather than one at a time. If the caller supplied a progressToken, a notifications/progress update is sent as each individual upload/download completes (skips and conflicts don't emit updates — they're free, not transfers). No update is sent during dry_run, since nothing is transferred. progress stays a running file-transfer count with no total (recursive descent means the overall file count isn't known upfront) — the message text adds a running total of bytes transferred so far as supplementary context (#352), e.g. "notes.txt: upload_ok, 40231 bytes so far".

Args: folder_id: Google Drive folder ID to sync against. local_path: Local directory path to sync against. A missing one plans as empty, and is created only at the first local write (a download, or a Drive-only subfolder), so a dry_run or an upload-only sync never creates it. direction: 'bidirectional', 'upload', or 'download'. export_format: Required to include Workspace files in the sync. They are exported/compared using this format (e.g. 'pdf', 'docx', 'csv'). convert_markdown: If True, local .md files are uploaded via Drive's native import conversion, landing as Google Docs (still named '.md') instead of raw text files — same mechanism as upload_local_file's convert param (#188), and a Doc created either way is recognized by this matching. Drive's importer renders the Markdown, not this server's converter: '-' bullets at every level, fenced code in a gray monospace box with a language label ('None' when it has no recognized language), at the page margin even inside a list item, quotes without a border, nested numbering '1.' rather than 'a.' (full list: docs/known-limitations.md). Leading YAML front matter is left out of the Doc. The converted Doc is matched back to its local .md file directly on later syncs (independent of export_format, and independent of whether a later sync passes convert_markdown=True again), so edits round-trip normally instead of re-uploading a duplicate every run. Matching is scoped to Docs carrying an internal Drive property this tool sets on conversion — a pre-existing Doc a human happened to name '.md' is never mistaken for one and never has its content overwritten. There is no reverse conversion: if the Doc is edited in Drive, or has no local counterpart at all, that entry is reported under 'conflicts' instead of downloaded. A converted Doc's changes aren't judged from modifiedTime, which Drive updates minutes behind a Docs edit: the local .md is compared with the mtime recorded at its last upload, and a Drive edit is detected from the Doc's revision history (one extra metadata call per converted Doc per sync). A Doc edited in Drive is a conflict even when the local .md changed too, rather than being overwritten by the upload; clear it with resolve (below). A local change made within seconds of the previous upload waits for a later sync. A Doc converted by an older version of this tool keeps the modifiedTime comparison until it's next re-uploaded. A .md previously synced with convert_markdown=False can't be promoted to a Doc in place — that entry is reported under 'failed' with an explanatory message; delete it in Drive and re-sync to convert it. use_checksum: If True, treat a name present on both sides as in sync whenever its local md5 hash matches Drive's md5Checksum, regardless of modifiedTime drift, and report a within-tolerance pair whose hashes differ as a conflict (see above). Reads every both-sides file with a Drive md5Checksum. Default False (mtime + size comparison). skip_system_files: Skip .DS_Store and similar OS metadata files (default True). dry_run: If True, plan the sync but transfer nothing. recursive: If True, also sync matching subfolders at any depth (see above). Defaults to False — a single call only covers the top-level folder. result_local_path: If set, write the result to this file/directory path instead of returning it inline, unconditionally bypassing the response-size safety cap below — useful for a large recursive sync (dry_run or real) whose result would otherwise exceed it. Returns a manifest ({local_path, bytes_written, folder_id, dry_run}) instead of the sync result itself. Must not be local_path or a path inside it — local_path is scanned as sync input on every call, so a result manifest written there would show up as a new local-only file on the next sync (and get uploaded to Drive on a real run); raises ValueError if it resolves inside local_path. A path ending in '/' is a directory, created if missing. A file in place of a parent directory, or at a path ending in '/', raises ValueError; an existing file at a plain file path is replaced. Both checks run before any transfer or local write. resolve: Clears convert_markdown conflicts one Doc at a time, keeping its file ID (and so its sharing, comments, and links). Maps a name exactly as 'conflicts' reports it ('sub/notes.md' under recursive) to one of: 'keep_drive' — accept the Doc's current Drive version as the new baseline. Nothing in Drive changes, and the local .md is recorded as matching it, so use this only once the local file holds exactly the Doc's content (carry the Drive edits in first). If the local file has edits of its own, merge and use 'keep_local' instead, or those edits never reach Drive. From then on, a local change uploads as usual. Also moves a Doc converted by an older version of this tool onto the revision-history check. 'keep_local' — re-upload the local .md over the Drive version, in place. The Drive edits are overwritten (they stay in the Doc's version history). Not allowed with direction='download'. Every name must be a convert_markdown Doc with a matching local .md that this sync would report under 'conflicts'; otherwise the call returns an error listing each bad name and changes nothing (there's no folder-wide form). With dry_run=True, 'actions' previews each one as a 'keep_drive' or 'keep_local' action. If the Doc is edited in Drive again between the plan and the write, it stays under 'conflicts' instead. Checking the names costs one read-only planning pass before a real run.

Returns: uploaded, downloaded, skipped, conflicts, failed lists (relative paths — just the filename at the top level, 'subdir/name' for nested matches when recursive descends; always empty when dry_run=True, see the dry_run section above), 'folders_skipped' (relative subfolder paths not entered — always empty when recursive=False), 'resolved' (names resolve was applied to; a 'keep_local' name is also under 'uploaded'), size_bytes transferred (uploaded plus downloaded), dry_run flag, and — when dry_run=True — an 'actions' list with {name, action, reason} for every file considered at every level visited. A '.gee-sweet-partial-*' temp file an interrupted download left locally is never synced; it's listed under 'skipped' (a 'skip' action under dry_run). Each 'failed' entry is {name, error} plus a 'fileId' in the narrow convert_markdown case where create() actually succeeded in Drive but a follow-up metadata call then failed (#420) — that fileId names a real, already-created Drive file, not something the next sync will retry creating from scratch. Raises ValueError if the response exceeds a safety cap (see MAX_TOOL_RESPONSE_CHARS in docs/configuration.md for the configured default, or pass result_local_path to bypass it and write to disk instead) — a recursive sync/preview over many files is the most likely way to hit this.

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": {
      "folder_id": "<folder_id>",
      "local_path": "<local_path>"
    },
    "name": "sync_folder"
  }
}

Input Schema

NameRequiredDescriptionDefault
dry_runNo
resolveNo
directionNobidirectional
folder_idYes
recursiveNo
local_pathYes
use_checksumNo
export_formatNo
convert_markdownNo
result_local_pathNo
skip_system_filesNo

Output Schema

NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv0.9.6

TDQS

A4.4/5.0
Behavior5/5

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

The description goes far beyond the destructiveHint annotation, disclosing conflict handling, overwrite behavior, checksum costs, progress notification behavior, dry-run guarantees, and failure modes with fileId. It explains what gets changed or left alone in each scenario, including that keep_local overwrites Drive edits while preserving version history.

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 description is front-loaded and uses headings, but it is extremely long and repeats the same concepts across the sync logic table, parameter docs, and returns section. For example, checksum behavior is explained at length in the main body and again under use_checksum, and dry_run behavior is covered in multiple places, so not every sentence earns its place.

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 the tool's complexity, 11 parameters, no schema descriptions, and destructive behavior, the description is exceptionally complete. It covers matching rules, recursive descent, conflicts, checksums, conversion behavior, result size limits, and return value structure, so an agent has everything needed to invoke it correctly.

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%, but the description thoroughly documents all 11 parameters, including defaults, allowed values, constraints, and edge cases such as result_local_path being disallowed inside local_path and resolve accepting only convert_markdown conflict names. This fully compensates for the schema's lack of descriptions.

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?

The description clearly states the specific action: syncing files between a Google Drive folder and a local directory, with direction and matching rules explained. It distinguishes its behavior from simple upload/download tools implicitly through the sync logic, but it does not explicitly name siblings like upload_local_folder or download_folder as alternatives.

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?

It provides extensive context: the LOCAL_FILE_ACCESS=off unavailability constraint, exact semantics of direction values, when recursive is needed, and when dry_run is appropriate. However, it does not explicitly compare sync_folder to sibling tools for one-way transfers, leaving the agent to infer that sync_folder is for synchronization rather than a directed upload or download.

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