Skip to main content
Glama
azharlabs
by azharlabs

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
NameRequiredDescriptionDefault
notebook_pathYesAbsolute path to the Jupyter notebook file
cell_indexYesZero-based index of the cell to delete

Implementation Reference

  • 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}` } ] }; }
  • 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);

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