Skip to Content

fs_write

Create a file or replace it whole, atomically (a half-written file is never seen). Text or base64, up to 8 MiB. Replacing an existing file needs expect_sha256, its SHA-256 from fs_stat with hash=true or the sha256 the last fs_write or fs_edit of it returned: without it the answer is hash_required and nothing is written, and a file changed since is refused. create_only refuses an existing file. An existing file keeps its permissions. Paths holding keys and credentials are refused.

Arguments

Over MCP every tool also takes machine: the machine’s name or id, optional when only one machine is online.

NameTypeRequiredMeaning
create_onlybooleannoRefuse when the file already exists. Default: false.
datastringyesThe whole new content.
encoding`“utf8”“base64”`no
expect_sha256stringnoThe file’s SHA-256 from fs_stat with hash=true, or as the last fs_write or fs_edit of it returned. Required to replace an existing file; the write is refused when the file changed since or does not exist.
mkdirsbooleannoCreate missing parent folders. Default: false.
pathstringyesFile on the machine. Absolute, or relative to the user’s home folder.

Result

NameTypeRequiredMeaning
createdbooleanyesThe file did not exist before.
pathstringyesThe file, as an absolute path.
sha256stringyesSHA-256 of the new content.
sizeintegeryesBytes written.

Examples

{ "name": "fs_write", "arguments": { "machine": "<machine>", "path": "<path>", "data": "<data>" } }

Limits

The call times out after 60 s (timed_out). Available since version 0.0.1. A refused or failed call returns one of the error codes.