A Python package providing atomic tools for langchain-based AI agents to manipulate Jupyter notebooks. Built on nbclient/nbformat, it enables programmatic notebook creation, loading, and manipulation.
You can install from this repo in development mode with pip install -e ./src/
The system maintains notebook sessions using tokens. Each operation requires a valid token obtained from either:
create_notebook(): Creates new empty notebookload_notebook(url): Loads notebook from URL or file path
With a valid token, the following operations are supported:
list_cells(token): Get ordered list of cell IDscreate_cell(token, source, cell_type, position): Add new cellupdate_cell(token, id, source): Modify cell contentexecute_cell(token, id): Run code cell and get outputdelete_cell(token, id): Remove cell from notebookget_notebook(token): Retrieve current notebook state
The system provides specific error types for common failure cases:
InvalidTokenErrorCellNotFoundErrorCellTypeErrorNotebookLoadErrorKernelError
See docs/example.ipynb for an example of how to use the package.