write_file
Create or overwrite a file with specified text content, automatically creating parent directories. Supports custom encoding and optional confirmation for secure environments.
Instructions
Create or overwrite a file with the given content.
Creates parent directories automatically. Overwrites existing files
without warning — use file_exists() first if unsure.
Requires explicit confirmation when ``security.require_confirmation``
is enabled in config.
Args:
path: Path to write (absolute or relative to cwd).
content: The text content to write.
encoding: File encoding. Default: "utf-8".
confirm: Set to True to confirm when required by config.
Returns:
A dict with keys: status, data (path, size_bytes, lines).
Examples:
write_file("notes.txt", "Hello, World!")
write_file("src/config.py", "DEBUG = True
", confirm=True)
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": {
"path": "<path>",
"content": "<content>"
},
"name": "write_file"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | ||
| confirm | No | ||
| content | Yes | ||
| encoding | No | utf-8 |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||