write_file
[codefix]
Previews a full-file write for a JS, TS, JSON, or JSONC workspace file. Apply a disk change with its preview fingerprint.
Before you use this tool
Preview the write and pass its diskFingerprint as expectedDiskFingerprint for a disk change. Check each outcome before recovery because a failed refresh can follow a successful save.
Try it locally in the TGlider playground
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| filePath | string | Yes | Workspace-relative or absolute file path. |
| text | string | Yes | Full replacement text for the target file. |
| applyChanges | boolean | No | Apply the full-file write to disk and live workspace state instead of returning preview only. Default: false |
| includeDiff | boolean | No | Include a unified diff in the response. Default: true |
| maxDiffChars | number | No | Maximum diff characters to return before truncating. Default: 50000 |
| expectedVersion | number | No | Required live-document version guard when the target file is open. |
| expectedDiskFingerprint | string | No | Required for a disk change. Pass diskFingerprint from a fresh write_file preview. A mismatch rejects the save before mutation. Unreleased parameter. Available in development builds after TGlider 1.8.0. |
Examples
Replace sample paths and symbol keys with values from your workspace.
Preview a full-file write without mutating disk
Arguments
{
"filePath": "src/app.ts",
"text": "export const value = 2;\\n"
}Full MCP request
Full MCP request
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "write_file",
"arguments": {
"filePath": "src/app.ts",
"text": "export const value = 2;\\n"
}
}
}Response Notes
Returns diskFingerprint from the current disk existence and raw bytes. A disk conflict asks the caller to preview again. Applied results separate disk, live-document, and refresh outcomes.