NotebookEdit

A built-in definition supplied to the request when the tools option was omitted.

Captured description

Replaces, inserts, or deletes a single cell in a Jupyter notebook (.ipynb file).

Usage:

  • You must use the Read tool on the notebook in this conversation before editing — this tool will fail otherwise.
  • notebook_path must be an absolute path.
  • cell_id is the id attribute shown in the Read tool’s <cell id="..."> output. It is required for replace and delete.
  • edit_mode defaults to replace. Use insert to add a new cell after the cell with the given cell_id (or at the beginning of the notebook if cell_id is omitted) — cell_type is required when inserting. Use delete to remove the cell.

Input schema

JSON
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "notebook_path": {
      "description": "The absolute path to the Jupyter notebook file to edit (must be absolute, not relative)",
      "type": "string"
    },
    "cell_id": {
      "description": "The ID of the cell to edit. When inserting a new cell, the new cell will be inserted after the cell with this ID, or at the beginning if not specified.",
      "type": "string"
    },
    "new_source": {
      "description": "The new source for the cell",
      "type": "string"
    },
    "cell_type": {
      "description": "The type of the cell (code or markdown). If not specified, it defaults to the current cell type. If using edit_mode=insert, this is required.",
      "type": "string",
      "enum": [
        "code",
        "markdown"
      ]
    },
    "edit_mode": {
      "description": "The type of edit to make (replace, insert, delete). Defaults to replace.",
      "type": "string",
      "enum": [
        "replace",
        "insert",
        "delete"
      ]
    }
  },
  "required": [
    "notebook_path",
    "new_source"
  ],
  "additionalProperties": false
}

Independent estimate

~607 tokens

The captured tool object was counted against the common baseline. This value supports comparison and is not additive.