marimo-inspect
Drive a live marimo notebook session over MCP: discover and bind sessions, read cells/variables/outputs/errors, edit and run cells, and set widget values.
Session management —
list_active_notebooksdiscovers sessions (auto-binding the first, settingsession_id+server_url);set_active_sessionbinds one explicitly. Binding is MCP-session state plus a process-global fallback, and argument-less calls are refused withbinding_ambiguousonce a second distinct client session appears (HTTP/SSE).Reads —
get_cell_map(lightweight previews),get_cell_data(full source, errors, variables; the only tool that records the edit read baseline),get_cell_outputs(display + console streams),get_variables,get_dependency_graph(always the full notebook graph),get_errors(structured CellErrors and console stderr, never conflated),lint_notebook(marimo's ownmarimo checkengine).Writes —
create_cell(with name/before/after/hide_code),edit_cell(guarded by read-before-edit: refusesneeds_readorconflictunlesscheck_fresh=False),run_cell,delete_cell.Widget interaction —
set_ui_valuesets a live UI element by kernel variable name, shape-checked per widget type (mismatch refused withdid_you_mean), never executes source code, and reads the value back soverified: truemeans the value actually moved.Refusals over exceptions — bad targets, missing cell ids, and unsupported args (e.g.
get_dependency_graph'sdepth/cell_id) come back as structured payloads with no mutation dispatched.Not available here — no
restart_kernel; this schema exposes 14 tools, matching the released v0.3.3 surface rather thanmain's 15.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@marimo-inspect show me the current cells and variables in my active marimo notebook"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
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-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 |
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 syncThen 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 |
| |
Tools | 14 — no | 15, including |
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 |
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, settingsession_idandserver_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 |
| the MCP-first co-work loop, step by step |
| read-before-edit and live-kernel safety rules |
| 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-tokenfor registry-based discovery; amarimo runserver 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 |
Orientation to the MCP contract, and which document owns which topic | |
The comparison with upstream | |
The packaged MCP resources | Authoritative runtime semantics for an agent that is already connected |
Consumer installation and per-harness configuration | |
Local, remote and Tailnet deployment shapes, URL resolution and the operator boundary | |
Consumer-facing marimo usage patterns to copy, and how they are checked | |
Live-kernel test mechanics and the current counts | |
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 toolscreate_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 ValueADestructive
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
Scored across 14 tools
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.
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.
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.
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
Related MCP Connectors
Live browser debugging for AI assistants — DOM, console, network via MCP.
Create, edit, preview, and deploy full-stack web apps to a live URL from any MCP client.
Remote MCP server exposing your Node Command fleet (files, shell, processes, browser) to AI hosts.
Build your own tools from chat: design, test and host them on a shareable MCP server URL.
Related MCP Servers
- FlicenseAqualityDmaintenanceAuto-discovers running marimo notebooks and exposes tools for reading, editing, and running cells via MCP, supporting both HTTP and VS Code backends.10-
- FlicenseBqualityDmaintenanceA 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-
- FlicenseAqualityCmaintenanceMCP server for structural editing of Jupyter notebook cells (list, read, insert, edit, patch, delete, move) without kernel execution.10-
- FlicenseNot gradedqualityDmaintenanceEnables 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.-