Skip to main content
Glama

move_cell

Reposition cells within Jupyter notebooks by specifying source and destination indices to reorganize content structure.

Instructions

Move a cell from one position to another

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
notebook_pathYesAbsolute path to the Jupyter notebook file
from_indexYesCurrent index of the cell
to_indexYesTarget index for the cell

Implementation Reference

  • The main handler function for the 'move_cell' tool. It reads the Jupyter notebook JSON, validates indices, moves the cell by splicing the cells array, writes the updated notebook back to disk, and returns a success message.
    async moveCell(notebookPath, fromIndex, toIndex) { const notebook = await this.readNotebook(notebookPath); this.validateCellIndex(notebook.cells, fromIndex); if (toIndex < 0 || toIndex >= notebook.cells.length) { throw new Error(`Invalid target index ${toIndex}. Must be between 0 and ${notebook.cells.length - 1}`); } const [movedCell] = notebook.cells.splice(fromIndex, 1); notebook.cells.splice(toIndex, 0, movedCell); await this.writeNotebook(notebookPath, notebook); return { content: [ { type: "text", text: `Successfully moved cell from index ${fromIndex} to ${toIndex}` } ] }; }
  • JSON Schema defining the input parameters for the 'move_cell' tool: notebook_path (string), from_index (integer), to_index (integer). Returned by the ListTools handler.
    { name: "move_cell", description: "Move a cell from one position to another", inputSchema: { type: "object", properties: { notebook_path: { type: "string", description: "Absolute path to the Jupyter notebook file" }, from_index: { type: "integer", description: "Current index of the cell" }, to_index: { type: "integer", description: "Target index for the cell" } }, required: ["notebook_path", "from_index", "to_index"] } },
  • src/index.js:355-360 (registration)
    Tool call dispatching/registration in the CallToolRequestSchema handler's switch statement, which routes 'move_cell' calls to JupyterHandler.prototype.moveCell.
    case "move_cell": return await this.jupyterHandler.moveCell( args.notebook_path, args.from_index, args.to_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