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
| Name | Required | Description | Default |
|---|---|---|---|
| notebook_path | Yes | Absolute path to the Jupyter notebook file |
Input Schema (JSON Schema)
{
"properties": {
"notebook_path": {
"description": "Absolute path to the Jupyter notebook file",
"type": "string"
}
},
"required": [
"notebook_path"
],
"type": "object"
}
Implementation Reference
- src/jupyter-handler.js:95-120 (handler)The main handler function that executes the list_cells tool. It reads the Jupyter notebook file, extracts cell information (index, type, preview of source), formats it into a text response, and returns it.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:40-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 registration/dispatch point in the main CallToolRequestSchema handler where calls to list_cells are routed to the JupyterHandler's listCells method.case "list_cells": return await this.jupyterHandler.listCells(args.notebook_path);