Skip to main content
Glama

read_notebook_with_outputs

Extract content and execution results from Jupyter notebooks to review code, data, and visualizations for analysis or debugging purposes.

Instructions

Read a Jupyter notebook including cell outputs

Input Schema

NameRequiredDescriptionDefault
notebook_pathYesAbsolute 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

  • Handler function that reads a Jupyter notebook (.ipynb file), processes all cells to include their source code and any outputs (text, images noted, errors), formats into a single text response for MCP.
    async readNotebookWithOutputs(notebookPath) { const notebook = await this.readNotebook(notebookPath); const cellsContent = notebook.cells.map((cell, index) => { const source = Array.isArray(cell.source) ? cell.source.join('') : cell.source; let content = `Cell with ID: ${cell.id || index}\n${source}`; // Add outputs if it's a code cell with outputs if (cell.cell_type === 'code' && cell.outputs && cell.outputs.length > 0) { content += '\nOutput of cell ' + (cell.id || index) + ':'; for (const output of cell.outputs) { if (output.output_type === 'stream') { const text = Array.isArray(output.text) ? output.text.join('') : output.text; content += '\n' + text; } else if (output.output_type === 'execute_result' || output.output_type === 'display_data') { if (output.data) { if (output.data['text/plain']) { const text = Array.isArray(output.data['text/plain']) ? output.data['text/plain'].join('') : output.data['text/plain']; content += '\n' + text; } if (output.data['image/png']) { content += '\n[Image output available]'; } } } else if (output.output_type === 'error') { content += '\nError: ' + output.ename + ': ' + output.evalue; } } } return content; }); return { content: [ { type: "text", text: cellsContent.join('\n\n') } ] }; }
  • Tool schema definition in the ListTools response, specifying the tool name, description, and input parameters (notebook_path).
    name: "read_notebook_with_outputs", description: "Read a Jupyter notebook including cell outputs", inputSchema: { type: "object", properties: { notebook_path: { type: "string", description: "Absolute path to the Jupyter notebook file" } }, required: ["notebook_path"] } },
  • src/index.js:375-376 (registration)
    Registration and dispatch logic in the CallToolRequestSchema handler; routes tool calls to the appropriate JupyterHandler method.
    case "read_notebook_with_outputs": return await this.jupyterHandler.readNotebookWithOutputs(args.notebook_path);

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