Browse documentation

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

NameTypeRequiredDescription
filePathstringYesWorkspace-relative or absolute file path.
textstringYesFull replacement text for the target file.
applyChangesbooleanNoApply the full-file write to disk and live workspace state instead of returning preview only. Default: false
includeDiffbooleanNoInclude a unified diff in the response. Default: true
maxDiffCharsnumberNoMaximum diff characters to return before truncating. Default: 50000
expectedVersionnumberNoRequired live-document version guard when the target file is open.
expectedDiskFingerprintstringNoRequired 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.