str_replace
Replace one exact, unique occurrence of old text with new text in a file; returns an error with match counts if the old text is missing or ambiguous.
Instructions
Edit a file by replacing one exact occurrence of old_str with new_str. old_str must match the file exactly (including indentation and whitespace) and must occur exactly once; otherwise the tool returns an error with the number of matches, and you should include more surrounding lines to make it unique. On success it shows the edited region. Test files are read-only and cannot be edited.
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>",
"old_str": "<old_str>",
"new_str": "<new_str>"
},
"name": "str_replace"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | ||
| new_str | Yes | ||
| old_str | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |