nbclassic-mcp-bridge-mcp

v1.2.1
nbclassic-mcp-bridge-mcp Checked 2 days ago Published 1 month ago

MCP server that drives a classic Notebook through the nbclassic-mcp-bridge relay

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

list_notebooks

List the notebooks open on every Jupyter server this session has touched. Each record carries the notebook's path, kernel state, whether a browser tab and an assistant are connected, whether the bridge is ``attached`` to it, and whether it is the ``current`` notebook that commands target by default. ``jupyter_url`` appears only when more than one server is in play. A server that cannot be reached contributes one ``{jupyter_url, error}`` record instead of failing the whole listing, so the notebooks on the reachable servers stay visible.

use_notebook

Attach the bridge to a notebook open in the classic Notebook UI, and make it current. Notebooks already attached stay attached, so several can be held at once; this one becomes the notebook commands target by default. With no ``path``, attach to the only open notebook (preferring one with a connected browser tab); when several are open, list them instead of guessing. A ``path`` that does not exactly match an open notebook is resolved fuzzily (case-insensitive, basename, substring). The reply states whether the notebook's browser tab is connected -- commands only work once the human has the no…

ParameterTypeDescription
path

use_server

Point new attachments at a different Jupyter server. Notebooks already attached stay attached to the server they were attached against, so notebooks on two servers can be held at once; follow with use_notebook to attach one here.

ParameterTypeDescription
jupyter_url *string
token *string

use_project

Point new attachments at the Jupyter server launched for a project directory. Supports the convention where a project-local server's token is the sha256 hex digest of the project's resolved path. Notebooks already attached stay attached to their own server; follow with use_notebook to attach one here.

ParameterTypeDescription
path *string

create_notebook

Create a new notebook file on the Jupyter server, optionally seeded with cells. With ``open`` set, ask an attached browser tab to open the new notebook in a tab of its own and attach to it, leaving it the current notebook; the reply says plainly when that could not be done and what to open by hand. Otherwise the file is written and nothing else happens, so follow up by asking the human to open it and then calling use_notebook. ``path`` must end in .ipynb, is not created if anything is already there, and its parent directories must already exist. ``cells`` are ``{cell_type, source}`` mappings…

ParameterTypeDescription
path *string
cells
kernel_name
openboolean

detach_notebook

Stop tracking a notebook. Its browser tab and kernel are left untouched. Drops the bridge's connection only -- nothing is saved, closed, or reverted, and the human's tab keeps working. Detaching the current notebook leaves no current notebook, so call use_notebook to pick another.

ParameterTypeDescription
notebook *string

read_notebook

List every cell: id, index, type, source, metadata, and an output summary. Source longer than ~16k chars is truncated; outputs are summarized, not included -- call ``read_cell_source`` / ``read_cell_output`` for one cell. Act on the current notebook unless ``notebook`` names another attached one.

ParameterTypeDescription
notebook

read_cell_source

Return one cell's source and metadata (with its id, index, and type), not its outputs. Source longer than ~16k chars is truncated unless ``full`` is true. Act on the current notebook unless ``notebook`` names another attached one.

ParameterTypeDescription
cell_id *string
fullboolean
notebook

read_cell_output

Return one cell's outputs (with its id), not its source. Long text in each output is truncated unless ``full`` is true. Image payloads are stubbed out (unless ALLOW_IMG_OUTPUT is set); to look at one, call ``read_cell_image``. Act on the current notebook unless ``notebook`` names another attached one.

ParameterTypeDescription
cell_id *string
fullboolean
notebook

read_cell_image

Return one of a cell's image outputs as a viewable image. A cell can hold several images; ``image_index`` picks among them in document order. Default 0 (the first). Use this to actually look at a plot -- image payloads are stubbed out of every text-returning tool. Act on the current notebook unless ``notebook`` names another attached one.

ParameterTypeDescription
cell_id *string
image_indexinteger
notebook

insert_cell

Insert a new cell at ``index``. Act on the current notebook unless ``notebook`` names another attached one.

ParameterTypeDescription
cell_type *string
index *integer
source *string
notebook

set_cell_source

Replace a cell's source. Returns ``{"cell_id": ..., "status": "written"}`` on success. If the human currently has the target cell focused, the bridge skips the write to avoid clobbering an in-progress edit and returns ``{"cell_id": ..., "status": "skipped", "reason": "focused"}``, so check ``status`` before assuming the write took effect. Act on the current notebook unless ``notebook`` names another attached one.

ParameterTypeDescription
cell_id *string
source *string
notebook

set_cell_metadata

Change a cell's metadata by applying ``patch`` as a JSON merge patch (RFC 7386). Nested objects merge key by key, a ``null`` value deletes that key, and any other value (lists included) replaces what was there, so changing ``tags`` means sending the whole new list. Keys the patch does not name are left alone. Keys listed by ``metadata_choices`` (such as ``{"slideshow": {"slide_type": "fragment"}}`` for RISE) are checked against their valid values before anything is written, and other keys pass through. Returns ``{"cell_id": ..., "metadata": ...}`` with the cell's full metadata after the chang…

ParameterTypeDescription
cell_id *string
patch *object
notebook

set_notebook_metadata

Change the notebook's own metadata by applying ``patch`` as a JSON merge patch (RFC 7386). Merges like ``set_cell_metadata`` and is validated against the notebook keys that ``metadata_choices`` lists. RISE settings go under ``rise`` and apply the next time the slideshow opens. ``title``, ``authors``, and ``date`` feed the LaTeX export. Avoid ``kernelspec`` and ``language_info``, which Jupyter maintains. Returns ``{"metadata": ...}`` with the full notebook metadata after the change. Undoable with ``undo_last_change``. Act on the current notebook unless ``notebook`` names another attached one.

ParameterTypeDescription
patch *object
notebook

metadata_choices

List the cell and notebook metadata keys that nbclassic, RISE, and the LaTeX export act on. Keys are dotted paths into the metadata (``slideshow.slide_type`` is ``{"slideshow": {"slide_type": ...}}``). Each entry gives the value's type, ``choices`` when only certain values are accepted (with what each one does), ``suggested`` values when others are allowed too, the programs that read the key, and what they do with it. Any other key is stored but ignored by these programs.

slide_outline

Show where each cell lands in the RISE slideshow, without opening it. Each cell gets ``slide`` (counting across), ``subslide`` (counting down within a slide), and ``fragment`` (reveal steps within a subslide, where 0 shows with the subslide), all from 0, plus the ``slide_type`` RISE applies and a one-line ``preview`` of the source. Notes and skip cells keep the position of the cell before them. Use it after changing slide types to check the deck has the intended shape. Act on the current notebook unless ``notebook`` names another attached one.

ParameterTypeDescription
notebook

execute_cell

Execute a cell in the live UI and return its outputs (long text truncated). Raise a timeout error if the cell is still running after ``timeout_s`` seconds (the cell itself keeps running). Default 120. Act on the current notebook unless ``notebook`` names another attached one.

ParameterTypeDescription
cell_id *string
notebook
timeout_snumber

run_cells

Execute several cells with one call, returning per-cell outputs in the requested order. Executions queue in the kernel like the notebook's Run All, so an error in one cell aborts the ones after it. On timeout, finished cells keep their outputs and unfinished ones are marked "timed out" (they keep running in the kernel). Long text is truncated. Default timeout 600. Act on the current notebook unless ``notebook`` names another attached one.

ParameterTypeDescription
cell_ids *array
notebook
timeout_snumber

inspect_kernel

Evaluate code in the notebook's live kernel without touching cells, outputs, or history. Nothing appears in the notebook and the In[]/Out[] counters are unchanged, so use this to look at state -- ``df.shape``, ``data.columns``, ``locals().keys()`` -- rather than to do work the human should see. Returns ``{status, outputs}``; long text is truncated unless ``full`` is true. Default timeout 30. Act on the current notebook unless ``notebook`` names another attached one.

ParameterTypeDescription
code *string
fullboolean
notebook
timeout_snumber

interrupt_kernel

Send a KeyboardInterrupt to the notebook's kernel. Stops whatever is currently running -- including a cell the human started -- so use it to stop a runaway execution you triggered. Act on the current notebook unless ``notebook`` names another attached one.

ParameterTypeDescription
notebook

restart_kernel

Restart the notebook's kernel and wait until it can run code again. Every variable, import, and definition is destroyed -- use this to clear wedged state or pick up an edited module, not to stop a single runaway cell, which ``interrupt_kernel`` does without losing the session. Existing outputs stay on screen but are now stale, so re-run the cells whose results you still need. Returns once the new kernel is ready, so the next ``execute_cell`` will not fail with "kernel is not connected". Default timeout 60. Act on the current notebook unless ``notebook`` names another attached one.

ParameterTypeDescription
notebook
timeout_snumber

kernel_status

Report the kernel's last known lifecycle state, connectivity, and name. ``execute_cell`` and ``inspect_kernel`` fail immediately with "kernel is not connected" while the kernel is dead or restarting; poll here (or watch kernel_status events) before retrying. The result names the notebook it describes. Act on the current notebook unless ``notebook`` names another attached one.

ParameterTypeDescription
notebook

delete_cell

Delete a cell by id. Act on the current notebook unless ``notebook`` names another attached one.

ParameterTypeDescription
cell_id *string
notebook

move_cell

Move a cell to a new index in the notebook. Act on the current notebook unless ``notebook`` names another attached one.

ParameterTypeDescription
cell_id *string
index *integer
notebook

undo_last_change

Undo your most recent notebook mutation (source, metadata, insert, delete, move; not executions). An entry is skipped rather than applied when the human has touched that cell (or, for a notebook metadata change, the notebook metadata) since, so undo can never destroy human work; skipped or not, the entry is consumed. Returns what was undone or why it was skipped. The undo stack is per notebook. Act on the current notebook unless ``notebook`` names another attached one.

ParameterTypeDescription
notebook

undo_all_changes

Undo every recorded mutation of yours, newest first, with per-entry results. Entries the human has since touched are skipped, not applied (and consumed either way); executions are not undoable. Undoes one notebook's stack: act on the current notebook unless ``notebook`` names another attached one.

ParameterTypeDescription
notebook

checkpoint_notebook

Checkpoint a notebook's saved file as a restore point. Uses Jupyter's single default checkpoint slot -- the same one the human's "Save and Checkpoint" writes -- so create one deliberately, not routinely. Act on the current notebook unless ``notebook`` names another attached one.

ParameterTypeDescription
notebook

restore_notebook_checkpoint

Revert a notebook to its checkpoint and reload it in the browser. DESTRUCTIVE: the file on disk reverts to the checkpoint and the browser tab reloads from disk, discarding any unsaved edits (the human's included). Confirm with the human first. Act on the current notebook unless ``notebook`` names another attached one.

ParameterTypeDescription
notebook

poll_events

Return the human's notebook edits since ``cursor``, across every attached notebook. Pass 0 on the first call, then feed the returned ``cursor`` back to get only newer events. Each event is ``{notebook, name, data}`` -- one of cell_created, cell_deleted, cell_moved, cell_executed, source_changed, focus_changed, bridge_paused, bridge_resumed, kernel_status -- and reflects the human's actions (never an echo of your own commands) plus kernel failures and recoveries. One stream carries every attached notebook in the order things happened, so watching several costs one call; ``notebook`` narrows wh…

ParameterTypeDescription
cursorinteger
notebook