Edit File
editApply targeted exact text replacement to a file while retaining its inode and metadata, then return a unified diff. Pass the SHA from read to reject stale edits from concurrent sessions.
Instructions
Apply a targeted exact text replacement while retaining the existing file inode and metadata. Returns a unified diff; pass the SHA from read to reject stale multi-session edits.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | File path relative to workspace root. | |
| new_text | Yes | Replacement text. | |
| old_text | Yes | Exact text to replace. Must match once unless replace_all=true. | |
| replace_all | No | Replace all occurrences. Default: false. | |
| workspace_id | No | Workspace id from open_workspace. Omit to use the workspace selected for this MCP session. | |
| expected_sha256 | No | Optional SHA-256 from read. Fails if another session changed the file. | |
| expected_replacements | No | Fail if actual replacement count differs. |