edit_cell_source
Replace an exact string in a Jupyter notebook cell with another, supporting single or multiple occurrences. Returns a diff of changes made.
Instructions
Perform a surgical find-and-replace within a cell's source (like an editor's Edit tool).
Finds old_string in the cell and replaces it with new_string. Matching is literal
(not regex) and may span multiple lines. By default, old_string must appear exactly once;
set replace_all=True for multiple occurrences. Returns a diff of the changes made.
Prefer this over overwrite_cell_source for small, targeted edits — it is safer because
unchanged parts of the cell are left untouched. Use read_cell first to see the current
source and construct an accurate old_string.Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cell_index | Yes | Index of the cell to edit (0-based) | |
| new_string | Yes | Replacement string | |
| old_string | Yes | Exact string to find in cell source | |
| replace_all | No | Replace all occurrences (default: first only) |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes | Success message with diff showing changes made |