delete_cell
Remove a specific cell from a Jupyter notebook file by specifying its index to clean up or reorganize notebook content.
Instructions
Delete a cell by index
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| notebook_path | Yes | Absolute path to the Jupyter notebook file | |
| cell_index | Yes | Zero-based index of the cell to delete |
Implementation Reference
- src/jupyter-handler.js:226-245 (handler)The core handler function that reads the Jupyter notebook, validates the cell index, deletes the specified cell (preventing deletion of the last cell), persists the changes, and returns a success message.async deleteCell(notebookPath, cellIndex) { const notebook = await this.readNotebook(notebookPath); this.validateCellIndex(notebook.cells, cellIndex); if (notebook.cells.length === 1) { throw new Error("Cannot delete the last remaining cell in the notebook"); } notebook.cells.splice(cellIndex, 1); await this.writeNotebook(notebookPath, notebook); return { content: [ { type: "text", text: `Successfully deleted cell ${cellIndex}` } ] }; }
- src/index.js:122-138 (schema)The input schema definition for the delete_cell tool, specifying required parameters notebook_path (string) and cell_index (integer).{ name: "delete_cell", description: "Delete a cell by index", inputSchema: { type: "object", properties: { notebook_path: { type: "string", description: "Absolute path to the Jupyter notebook file" }, cell_index: { type: "integer", description: "Zero-based index of the cell to delete" } }, required: ["notebook_path", "cell_index"] }
- src/index.js:352-354 (registration)The dispatch registration in the MCP server's CallToolRequestSchema handler that routes delete_cell calls to the JupyterHandler's deleteCell method.case "delete_cell": return await this.jupyterHandler.deleteCell(args.notebook_path, args.cell_index);