read_notebook_with_outputs
Read Jupyter notebooks with cell outputs to review code execution results and analysis data from .ipynb files.
Instructions
Read a Jupyter notebook including cell outputs
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| notebook_path | Yes | Absolute path to the Jupyter notebook file |
Implementation Reference
- src/jupyter-handler.js:401-445 (handler)The main handler function that reads the Jupyter notebook file, processes each cell to include source code and any outputs (handling streams, results, images, errors), formats into readable text separated by cells, and returns as MCP tool response content.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') } ] }; }
- src/index.js:224-237 (schema)The tool schema definition specifying the name, description, and input schema requiring 'notebook_path' as a string.{ 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)The registration case in the main tool request handler switch statement that routes calls to this tool to the jupyterHandler's readNotebookWithOutputs method.case "read_notebook_with_outputs": return await this.jupyterHandler.readNotebookWithOutputs(args.notebook_path);