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

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

Input Schema (JSON Schema)

{ "properties": { "from_index": { "description": "Current index of the cell", "type": "integer" }, "notebook_path": { "description": "Absolute path to the Jupyter notebook file", "type": "string" }, "to_index": { "description": "Target index for the cell", "type": "integer" } }, "required": [ "notebook_path", "from_index", "to_index" ], "type": "object" }

Implementation Reference

  • The core handler function that reads the Jupyter notebook, validates indices, moves the cell by splicing the cells array, writes the notebook back, 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}` } ] }; }
  • The tool schema definition for 'move_cell', including name, description, and input schema specifying notebook_path, from_index, and to_index parameters.
    { 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)
    The registration/dispatch logic in the CallToolRequestSchema handler that calls the jupyterHandler.moveCell method with the provided arguments.
    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