Skip to main content
Glama

get_cell_source

Retrieve source code from a Jupyter notebook cell using its index to access and analyze specific code segments within notebook files.

Instructions

Get the source code of a specific cell by index

Input Schema

NameRequiredDescriptionDefault
notebook_pathYesAbsolute path to the Jupyter notebook file
cell_indexYesZero-based index of the cell

Input Schema (JSON Schema)

{ "properties": { "cell_index": { "description": "Zero-based index of the cell", "type": "integer" }, "notebook_path": { "description": "Absolute path to the Jupyter notebook file", "type": "string" } }, "required": [ "notebook_path", "cell_index" ], "type": "object" }

Implementation Reference

  • The core handler function that reads the Jupyter notebook file, validates the cell index, extracts and joins the cell source (handling array format), and returns it as MCP text content.
    async getCellSource(notebookPath, cellIndex) { const notebook = await this.readNotebook(notebookPath); this.validateCellIndex(notebook.cells, cellIndex); const cell = notebook.cells[cellIndex]; const source = Array.isArray(cell.source) ? cell.source.join('') : cell.source; return { content: [ { type: "text", text: source } ] }; }
  • JSON schema definition for the 'get_cell_source' tool in the ListTools response, specifying input parameters: notebook_path (string) and cell_index (integer).
    name: "get_cell_source", description: "Get the source code of a specific 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" } }, required: ["notebook_path", "cell_index"] } },
  • src/index.js:334-335 (registration)
    Tool dispatch/registration in the CallToolRequestSchema handler switch statement, which calls the jupyterHandler.getCellSource method with parsed arguments.
    case "get_cell_source": return await this.jupyterHandler.getCellSource(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