jupyter_mcp

jupyter_mcp

Kernel-attached MCP server for Jupyter notebooks, enabling agents to manage cells, track dependencies, and execute code with minimal re-execution and condensed outputs.

Category
访问服务器

README

jupyter-mcp

Kernel-attached MCP server for Jupyter EDA workflows. Built for coding agents that iterate on notebooks: named cells, a dependency DAG, minimal re-execution, condensed outputs, and cheap LLM summaries for navigation.

Why

Editing notebooks through generic file tools is painful for agents:

  • cells have no stable, human-meaningful addresses
  • every change means re-executing the whole notebook from scratch
  • raw outputs (box-drawn tables, base64 charts, ANSI noise) flood context
  • nothing tells you which cells a change invalidates

This server fixes each of those with an opinionated data model.

Concepts

Concept What it means
Cell names Every cell has a unique kebab-case name stored in cell.metadata.jupyter_mcp.name. Unnamed cells get auto-names from their first comment/heading.
Revisions Each cell has a short content hash (rev). Every mutation requires the expected_rev from your latest read — optimistic locking that makes wrong-target and stale edits structurally impossible. No confirmation round-trips.
Dependency DAG A static AST pass (not runtime tracing) extracts per-cell defines/uses/mutations and builds last-writer-wins edges. Works on unexecuted cells, which is the whole point: edit first, then run_stale.
Staleness A cell is fresh only if its current source ran on the currently live kernel (freshness is stamped with a per-kernel epoch). Source edits make a cell and its dependents stale; a new or restarted kernel makes everything stale — persisted metadata can never claim freshness against empty kernel state. run_stale executes exactly the stale set, in document order.
Condensed outputs Streams merged, ANSI stripped, long text truncated head+tail with explicit markers. Duplicate table reprs collapse to one: uniform → CSV, ragged → JSON. Charts return as real MCP images (downscaled), so the agent sees them.
Summaries Lazy, batched claude-haiku-4-5 summaries (tldr + description + output summary) cached in cell metadata keyed by content hash. Unchanged cells are never re-summarized. Degrades to deterministic fallbacks (marked *) without API credentials.
Snapshots / undo Every mutation snapshots the file first (under ~/.cache/jupyter_mcp/); undo_last restores it.

Tools

Tool Purpose
create_notebook New empty notebook
notebook_overview Index: names, revs, staleness, tldrs, edges, lint
read_cells Full cells (code + condensed outputs + images), by names/slice
add_cell / update_cell / remove_cell / move_cell Mutations; all take expected_rev
execute_cells Run named cells on the persistent kernel
run_stale Minimal re-execution after edits
restart_kernel Fresh kernel; marks everything stale
inspect_variable Type/shape/schema/head of a live variable, no cell needed
undo_last Restore pre-mutation snapshot
summarize_cells Detailed LLM summaries incl. outputs
search_cells Search source + names + summaries

Setup

uv sync

Register with Claude Code (.mcp.json in any project, or globally):

{
  "mcpServers": {
    "jupyter": {
      "command": "uv",
      "args": ["run", "--project", "/path/to/jupyter_mcp", "jupyter-mcp"]
    }
  }
}

The server is multi-notebook: every tool takes a notebook path, one kernel per notebook, started lazily in the notebook's directory (so relative data paths behave like in your editor). Kernelspec comes from the notebook's metadata, falling back to python3.

Summaries & credentials

Summaries use the plain anthropic SDK: credentials resolve from ANTHROPIC_API_KEY or an ant auth login profile automatically. Cost is negligible (Haiku, batched, hash-cached). To disable entirely set JUPYTER_MCP_DISABLE_SUMMARIES=1 — everything else works unchanged.

Development

uv run pytest              # full suite
uv run pytest -m "not kernel"   # skip real-kernel integration tests

Layout: src/jupyter_mcp/ is a plain library (model, dag, condense, kernel, summaries, session) with the MCP surface isolated in server.py; everything below the server is unit-testable without MCP.

Known limitations (v1)

  • The DAG is static: dynamic patterns (globals()[name] = ..., exec, attribute mutation through aliases) are invisible. Method calls only count as mutations for a known allowlist (append, fit, ...) — pure-functional chains (polars) intentionally create no false forward edges.
  • The undo stack is per-server-process (snapshots persist on disk, but a restarted server won't offer them for undo).
  • %%bash / %%sql style cells are treated as opaque (no dependencies).
  • Concurrent edits from a live Jupyter editor are detected (the server reloads and rejects the mutation) but not merged.

See docs/ROADMAP.md for what's deliberately deferred — including the phase-2 OKF knowledge base.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选