Skip to main content
Glama

marimo-inspect

Structured tooling for co-working on a live marimo notebook: read cells, variables and outputs, edit source, run cells, drive widgets, and verify what happened — over the wire, or from inside another notebook. Two surfaces over one implementation: a Python client (MarimoClient, discover_servers) that drives a live marimo session from any notebook or script, and a FastMCP server (create_server, and the marimo-inspect console script) that exposes the same tooling to AI agents over the Model Context Protocol.

Why not just use upstream marimo pair?

marimo now ships live-kernel code mode, a core marimo pair CLI and a vendor Agent Skill. That stack and this package drive the same live-kernel / code-mode machinery: they are not different execution engines, and official code mode can already perform many of the operations these tools expose. Our own two-arm comparison has not established an overall winner.

What this package adds is shape — a structured, inspectable tool vocabulary:

Dimension

Official marimo pair

marimo-inspect

Agent interface

CLI + agent skill

structured MCP tools

Access model

execute Python in the live kernel

named read, write, widget and verification operations

Flexibility

general Python and code-mode operations

narrower, predefined tool vocabulary

Python integration

native kernel/code-mode workflow

separately importable MarimoClient

Error contract

native CLI and kernel feedback

structured tool responses with explicit refusal reasons

Concurrency protection

depends on the underlying server behaviour

read-before-edit guard and notebook-path-anchored binding — detection, not atomic prevention

Version evaluated

marimo 0.25.1

marimo 0.24.x (pinned)

Two scope notes: the table compares interfaces, not feature counts — official marimo also ships built-in AI tools over its own MCP server endpoint, so structured MCP tooling is not unique to this project (source-inspected in the now-historical docs/marimo-inspection-tools-comparison.md); and the "concurrency protection" row is not a safety claim.

Reach for this package for an agent framework that already speaks MCP, for refusals as structured payloads rather than tracebacks, for driving a live session from Python, or for the read-before-edit guard and notebook-path-anchored binding on the MCP path. Reach for upstream for arbitrary code-mode operations, in-kernel helpers, or a shell-driven workflow. Neither is a lock: the guards here are detection on a captured snapshot, and MarimoClient used directly carries no notebook-identity precondition. Evidence: docs/interface-positioning.md.

Related MCP server: jupyter-notebook-mcp

Quick start

1. As a Python client

Install it into any project and co-work on a running marimo session:

import asyncio
from marimo_inspection import MarimoClient, discover_servers


async def main():
    servers = await discover_servers()
    async with MarimoClient(servers[0].url) as client:
        sessions = await client.list_sessions()
        result = await client.execute(sessions[0].session_id, "1 + 1")
        print(result.status, result.stdout)


asyncio.run(main())

Importing marimo_inspection does not import fastmcp — the server is reached through a lazy __getattr__, and only create_server() loads it. fastmcp is still an install-time dependency of the package.

2. As an MCP server

from marimo_inspection import create_server

server = create_server()
server.run(transport="stdio")

marimo-inspect --transport stdio runs that same server directly. Add a pinned, non-editable release to the notebook project's own environment:

uv add "marimo-inspect @ git+https://github.com/ajegorovs/marimo-mcp-cowork@v0.3.3"
uv sync

Then configure the harness to execute that environment's console script — <project-root>/.venv/bin/marimo-inspect --transport stdio — not uv run and not a provider checkout (verify it with .venv/bin/marimo-inspect --help). Per-harness configuration blocks: docs/harness-integration/README.md; local, explicit-remote and Tailnet topologies: docs/deployment-topologies.md. Start a notebook with --no-token, open it in a browser to materialize a session, call list_active_notebooks, then read the packaged resources for the co-work loop and safety rules. An editable sibling checkout is a provider-contributor override only, never a committed dependency source.

Release and development boundary

Released v0.3.3 (newest tag)

main, documented here

Tools

14 — no restart_kernel

15, including restart_kernel

Binding

process/connection-scoped

MCP-session state plus a process-global fallback, anchored to the bound notebook path (an id-only rotation is repaired; a reused id refused notebook_mismatch)

main carries substantial unreleased changes beyond v0.3.3, and the package version in pyproject.toml has not yet been advanced — so there is no release for the newer surface yet: a consumer pinning v0.3.3 gets the older, smaller interface, which is a normal development gap rather than a defect in the tag. Read the tag, not the branch, when you need to know what a pin actually does.

The MCP tool surface

15 tools over the same live kernel:

  • Session — list_active_notebooks (discovers sessions and auto-binds the first, setting session_id and server_url), set_active_session.

  • Reads — get_cell_map, get_cell_data, get_cell_outputs, get_variables, get_dependency_graph, get_errors, lint_notebook.

  • Writes — create_cell, edit_cell, run_cell, delete_cell.

  • Widget interaction — set_ui_value.

  • Lifecycle — restart_kernel (closes the kernel and re-materializes a fresh one; the server process survives, and the confirmed session id is point-in-time, not durable).

edit_cell carries a read-before-edit staleness guard (check_fresh=True by default): a never-read cell answers needs_read, a changed-since-read cell conflict, and only get_cell_data records the read baseline. Every cell/session-targeting tool resolves its target through one shared step, so a target problem is a structured payload (status: error with target_resolved / operation_ran / state_changed all false) rather than an exception, and no mutation is dispatched on a refusal. The full contract, written for a reader who has not connected a client yet: docs/mcp-contract.md.

MCP resources

Three static, read-only documentation resources ship in the wheel (text/markdown, loaded via importlib.resources), readable on demand by a connected client with list_resources() / read_resource(uri):

URI

Content

workflow://marimo-inspect/co-work-loop

the MCP-first co-work loop, step by step

workflow://marimo-inspect/live-safety

read-before-edit and live-kernel safety rules

reference://marimo-inspect/fallbacks-and-limits

what MCP does not cover, and its intentional fallbacks

The same three documents are readable without a connected client: in this repository at src/marimo_inspection/resources/, or in-process with Client(transport=create_server()).

Requirements

  • Python 3.12+

  • A running marimo edit server (--no-token for registry-based discovery; a marimo run server registers but is not discoverable, because its session census requires edit scope).

  • marimo 0.24.x: private APIs are version-bound — see docs/marimo-version-support.md.

Documentation map

Read this

For

docs/mcp-contract.md

Orientation to the MCP contract, and which document owns which topic

docs/interface-positioning.md

The comparison with upstream marimo pair, with its evidence and limits

The packaged MCP resources

Authoritative runtime semantics for an agent that is already connected

docs/harness-integration/README.md

Consumer installation and per-harness configuration

docs/deployment-topologies.md

Local, remote and Tailnet deployment shapes, URL resolution and the operator boundary

examples/

Consumer-facing marimo usage patterns to copy, and how they are checked

docs/live-tests.md

Live-kernel test mechanics and the current counts

docs/project-status.md

Current work, effort issues and durable design trails

Development

uv sync --all-extras           # test deps are an optional extra; a bare sync prunes pytest
uv run ruff check .
uv run pytest -m "not live"   # unit tests (fast, no kernel)
uv run pytest -m live         # live kernel tests (boots its own headless server)

The live tier deselects by default; read docs/live-tests.md before changing or running it.

Agent skills

Repo-local agent skills live in .agents/skills/ — one Markdown SKILL.md per skill. Hermes Agent does not auto-load skills from a cloned repo, so they need an explicit opt-in, once per repo per machine: hermes skills trust, which takes effect in your next session. hermes skills list shows what is loaded.

Available Tools

14 tools
create_cellCreate CellB

Create a new cell in the notebook.

Created cells are visible in the UI by default (hide_code=False); pass hide_code=True explicitly for setup/implementation cells you want hidden.

Inputs: source (required), name, after, before, +3 more. Returns: object

delete_cellDelete CellC

Delete an existing cell from the notebook.

Inputs: cell_id (required), server_url, session_id. Returns: object

edit_cellEdit CellA

Edit an existing cell's source code.

Includes a staleness guard: unless check_fresh=False, refuses to edit a cell that has no full-source read baseline (needs_read) or whose source changed since that read (conflict). get_cell_data records the baseline; a get_cell_map preview does not. This prevents silently overwriting a concurrent edit.

Inputs: source (required), cell_id (required), name, hide_code, +3 more. Returns: object

get_cell_dataGet Cell DataA

Get full runtime data for one or more cells.

Includes source code, errors, and variable information. If cell_ids is empty, returns data for all cells.

A requested id that resolves to nothing (deleted or mistyped) is reported in missing_cell_ids rather than silently omitted — the write tools refuse an absent id, so an unqualified empty payload here would hide the same mistake.

Inputs: cell_ids, server_url, session_id. Returns: object

get_cell_mapGet Cell MapA

Get a lightweight map of cells showing previews.

Returns cell IDs, names, code previews, and runtime state. This is the starting point for navigating a notebook.

A preview does NOT record the edit_cell read baseline — it updates only this tool's own change-detection snapshot. Read a cell's full source with get_cell_data before editing it.

Inputs: server_url, session_id, preview_lines. Returns: object

get_cell_outputsGet Cell OutputsB

Get cell execution outputs including visual display and console streams.

A requested id that resolves to nothing (deleted or mistyped) is reported in missing_cell_ids rather than silently omitted — a cell with no output and a cell that does not exist must not look alike.

Inputs: cell_ids, server_url, session_id. Returns: object

get_dependency_graphGet Dependency GraphB

Get the cell dependency graph showing variable relationships.

Reveals which variables each cell defines and references, parent/child relationships between cells, variable ownership, and dependency issues like multiply-defined variables or cycles. The graph is always the FULL notebook graph.

Inputs: depth, cell_id, server_url, session_id. Returns: object

get_errorsGet ErrorsA

Get all errors in the notebook session, organized by cell.

Two channels are reported and never conflated:

  • structured_errors: marimo's structured CellError records (kind graph|runtime, msg, exception).

  • console_stderr: serialized stderr console events (same shape as get_cell_outputs), so UI-handler exception tracebacks are visible even when the structured channel is empty.

has_errors / total_errors / total_cells_with_errors are the STRUCTURED-only counts (backward-compatible); has_console_exception / total_console_exception_cells cover the console channel.

Inputs: server_url, session_id. Returns: object

get_variablesGet VariablesA

Get tables and variables information in the session.

Returns information about kernel variables and DataFrames. If variable_names is empty, returns all variables — meaning the notebook's own session names, with the inspection template's scaffolding (its imports and helpers) excluded, since the scratchpad shares the kernel namespace.

Inputs: server_url, session_id, variable_names. Returns: object

lint_notebookLint NotebookB

Lint a marimo notebook to check for issues.

Uses marimo's internal linting engine (the same one behind marimo check) to check for:

  • Breaking issues: Problems that prevent the notebook from running

  • Runtime issues: Problems that may cause unexpected behavior

  • Formatting issues: Code style and formatting problems

Inputs: server_url, session_id. Returns: object

list_active_notebooksList Active NotebooksA

List currently active marimo notebooks.

Returns all active sessions with their file paths and session IDs. The first discovered session is automatically bound as the active session, so later calls that share this MCP session can omit both session_id and server_url.

The binding is server-side state keyed by the MCP session identity the client negotiates, so it reaches the next call only when the client keeps one MCP session for the connection — an mcp-SDK-based client does, fastmcp's own Client does not on the pinned fastmcp 4.0.3 (it starts a new session per request). Where that is the case, pass session_id and server_url explicitly on every call.

Inputs: server_url. Returns: object

run_cellRun CellC

Run (execute) an existing cell.

Inputs: cell_id (required), server_url, session_id. Returns: object

set_active_sessionSet Active SessionA

Set the active notebook session for subsequent tool calls.

Binds a session_id (and optionally its server_url) so later calls can omit both session_id and server_url. The binding is written to two places: this call's MCP-session state (visible to a client that keeps one MCP session across calls — an mcp-SDK-based client does) and a process-global fallback consulted only when the MCP-session state has nothing bound. Over stdio one process serves exactly one client, so the fallback carries the binding to every later call, fastmcp's own Client (a fresh MCP session per request on the pinned fastmcp 4.0.3) included. Over HTTP/SSE one process serves many clients, so the fallback is served only while the process has seen a single client session; once a second distinct client session appears, argument-less calls are refused with reason: binding_ambiguous rather than risk handing one client another client's notebook — pass both arguments explicitly there. Use list_active_notebooks first to discover available sessions and their IDs.

Inputs: session_id (required), server_url. Returns: object

set_ui_valueSet Ui ValueA
Destructive

Set the value of a live marimo UI element, by its variable name.

The kernel global named by variable_name must resolve to a marimo UI element (e.g. mo.ui.slider, mo.ui.dropdown, mo.ui.text). Its value is replaced with value, triggering reactive re-execution the same way a user interaction would.

Value shape is per widget and is NEVER coerced: a slider/text takes a scalar, a dropdown takes its option key inside a one-element list (for example ["beta"]), a multiselect takes the list of selected keys, a range_slider takes a two-element list, a checkbox takes a bool. The element's own declaration decides; a shape mismatch is refused before anything is applied and the response carries the corrected payload in did_you_mean.

This tool accepts NO source code: it exists for widget interaction only, not for arbitrary code execution. The update is flushed on code-mode context exit, the kernel then re-runs dependent cells, and the element's value is read back before returning — status: ok with verified: true means the element's own value was observed to move (or was already equal), not merely that the update was queued. A value marimo rejected is reported as an error, never as success.

Inputs: value (required), variable_name (required), server_url, session_id. Returns: object

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.7/5.0

    Scored across 14 tools

    Disambiguation4/5

    The 14 tools generally have distinct purposes, but get_cell_map, get_cell_data, and get_cell_outputs all involve retrieving cell information and could be confused by an agent unfamiliar with the subtle differences. The descriptions do clarify the differences (preview vs full data vs outputs), so it's mostly distinct.

    Naming Consistency5/5

    All tool names follow a consistent snake_case verb_noun pattern (get_*, list_*, create_*, edit_*, run_*, delete_*, set_*), with no deviations. The naming is predictable and readable.

    Tool Count5/5

    The server has 14 tools, which is well within the typical 3-15 range for a well-scoped MCP server. Each tool appears to earn its place by covering a specific operation in notebook inspection and manipulation.

    Completeness4/5

    The toolset covers a broad range of notebook operations (cell CRUD, execution, outputs, errors, linting, variables, dependency graph, UI interaction, session management), but some potential gaps exist, such as creating or deleting notebooks, managing files, or deeper kernel operations. It is largely complete for inspection and basic editing.

    Maintenance

    ActivityNo data
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      A
      quality
      D
      maintenance
      Auto-discovers running marimo notebooks and exposes tools for reading, editing, and running cells via MCP, supporting both HTTP and VS Code backends.
      10
      -
    • F
      license
      B
      quality
      D
      maintenance
      A FastMCP server for loading, editing, searching, and saving Jupyter notebooks (.ipynb) through MCP tools. It maintains a single active notebook session with live cell indices that update as cells are inserted or removed.
      10
      -
    • F
      license
      A
      quality
      C
      maintenance
      MCP server for structural editing of Jupyter notebook cells (list, read, insert, edit, patch, delete, move) without kernel execution.
      10
      -
    • F
      license
      Not graded
      quality
      D
      maintenance
      Enables live runtime inspection of any Python application, allowing MCP clients to query state, evaluate expressions, inspect objects, and read source code while the app runs.
      -