Skip to main content
Glama

delete_cell

Remove a specific cell from a Jupyter notebook file by its index to clean up or reorganize notebook content.

Instructions

Delete a cell by index

Input Schema

NameRequiredDescriptionDefault
notebook_pathYesAbsolute path to the Jupyter notebook file
cell_indexYesZero-based index of the cell to delete

Input Schema (JSON Schema)

{ "properties": { "cell_index": { "description": "Zero-based index of the cell to delete", "type": "integer" }, "notebook_path": { "description": "Absolute path to the Jupyter notebook file", "type": "string" } }, "required": [ "notebook_path", "cell_index" ], "type": "object" }

Implementation Reference

  • The core handler function that implements the delete_cell tool logic: reads the notebook JSON, validates the cell index, splices out the cell, writes the updated notebook back to disk, and returns a success response.
    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}` } ] }; }
  • The input schema definition for the delete_cell tool, including 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)
    Registration in the CallToolRequest handler switch statement that maps the 'delete_cell' tool name to the jupyterHandler.deleteCell method.
    case "delete_cell": return await this.jupyterHandler.deleteCell(args.notebook_path, args.cell_index);

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/azharlabs/mcp-jupyter-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server