list_cells
Retrieve all cells from a Jupyter notebook with their indices and types to inspect notebook structure and content organization.
Instructions
List all cells in a Jupyter notebook with their indices and types
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| notebook_path | Yes | Absolute path to the Jupyter notebook file |
Implementation Reference
- src/jupyter-handler.js:95-120 (handler)The handler function that reads a Jupyter notebook file, extracts information about each cell (index, type, and preview of source), and returns a formatted text list of all cells.async listCells(notebookPath) { const notebook = await this.readNotebook(notebookPath); const cellsInfo = notebook.cells.map((cell, index) => { const source = Array.isArray(cell.source) ? cell.source.join('') : cell.source; const preview = source.length > 100 ? source.substring(0, 100) + '...' : source; return { index, type: cell.cell_type, preview: preview.replace(/\\n/g, ' ') }; }); return { content: [ { type: "text", text: `Notebook: ${notebookPath}\nTotal cells: ${cellsInfo.length}\n\n${ cellsInfo.map(cell => `[${cell.index}] ${cell.type}: ${cell.preview}` ).join('\n') }` } ] }; }
- src/index.js:39-52 (schema)The input schema definition for the 'list_cells' tool, specifying the required 'notebook_path' parameter.{ name: "list_cells", description: "List all cells in a Jupyter notebook with their indices and types", inputSchema: { type: "object", properties: { notebook_path: { type: "string", description: "Absolute path to the Jupyter notebook file" } }, required: ["notebook_path"] } },
- src/index.js:331-333 (registration)The dispatch case in the CallToolRequestSchema handler that routes 'list_cells' calls to the JupyterHandler's listCells method.case "list_cells": return await this.jupyterHandler.listCells(args.notebook_path);