Skip to main content
Glama

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
NameRequiredDescriptionDefault
notebook_pathYesAbsolute path to the Jupyter notebook file

Implementation Reference

  • 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') } ] }; }
  • 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);

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