Transactionally write a large UTF-8 file
write_fileCreate or replace large workspace files in chunked transactions (begin, append, commit) to avoid oversized MCP messages and verify size/SHA-256 before atomic replacement.
Instructions
Host-owned five-action transaction for large whole-file creates or replacements without requiring one giant MCP message. Use begin, then one or more append calls with the exact next UTF-8 byte offset, optionally status, then commit with the complete expected size and SHA-256; abort discards staging. Staging stays outside the workspace, replace mode rechecks the original target SHA at commit, and successful commit uses a same-directory fsync + atomic replace.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| mode | No | Required only for begin. | |
| path | No | Required only for begin. | |
| chunk | No | Required for append; runtime-enforced maximum is 4 MiB of UTF-8 bytes so even worst-case JSON escaping stays below the MCP message ceiling. | |
| action | Yes | ||
| offset | No | Required for append; exact next UTF-8 byte offset, making retries non-duplicating. | |
| workspace_id | No | Required when server_info lists multiple workspaces. | |
| expected_size | No | Required for commit; complete UTF-8 byte length. | |
| transaction_id | No | Returned by begin; required by append/status/commit/abort. | |
| expected_sha256 | No | Required for commit; SHA-256 of complete new UTF-8 bytes. | |
| expected_target_sha256 | No | Required for begin in replace mode; obtain with file_info. |