edit_file
Modify text files line-by-line with defined edits using the MCP Filesystem Server. Specify path, text changes, and encoding, and optionally preview changes with dry-run mode. Returns a Git-style diff of modifications.
Instructions
Make line-based edits to a text file.
Args:
path: Path to the file
edits: List of {oldText, newText} dictionaries
encoding: Text encoding (default: utf-8)
dry_run: If True, return diff but don't modify file
ctx: MCP context
Returns:
Git-style diff showing changes
Input Schema
Name | Required | Description | Default |
---|---|---|---|
dry_run | No | ||
edits | Yes | ||
encoding | No | utf-8 | |
path | Yes |
Input Schema (JSON Schema)
{
"properties": {
"dry_run": {
"default": false,
"title": "Dry Run",
"type": "boolean"
},
"edits": {
"items": {
"additionalProperties": {
"type": "string"
},
"type": "object"
},
"title": "Edits",
"type": "array"
},
"encoding": {
"default": "utf-8",
"title": "Encoding",
"type": "string"
},
"path": {
"title": "Path",
"type": "string"
}
},
"required": [
"path",
"edits"
],
"title": "edit_fileArguments",
"type": "object"
}