Skip to content

Commit 962d031

Browse files
authored
Merge pull request #7 from block/damien/notebook-bug
Damien/notebook bug
2 parents 3758b43 + 68ea91f commit 962d031

File tree

13 files changed

+411
-11386
lines changed

13 files changed

+411
-11386
lines changed

Justfile

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Run all CI checks locally (matches GitHub Actions)
2-
ci: test lint format
2+
ci: test lint format build
33
@echo "✅ All CI checks passed!"
44

55
# Run tests (matches: uv run pytest tests)
@@ -15,4 +15,9 @@ lint:
1515
# Run format check and fix (matches: uvx ruff format --check but also fixes)
1616
format:
1717
@echo "🎨 Checking and fixing formatting..."
18-
uvx ruff format
18+
uvx ruff format
19+
20+
# Build documentation (matches: pnpm build in docs/)
21+
build:
22+
@echo "📚 Building documentation..."
23+
cd docs && pnpm start

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Jupyter MCP Server
22

3+
> **⚠️ API Compatibility Notice**: This project is currently focused on MCP (Model Context Protocol) usage. There are **no API compatibility guarantees** between versions as the interface is actively evolving. Breaking changes may occur in any release.
4+
35
Jupyter MCP Server allows you to use tools like [Goose](https://block.github.io/goose/) or Cursor to pair with you in a JupyterLab notebook where the state of your variables, etc is preserved by the JupyterLab Kernel. The fact that state is preserved is the key to this because it allows to to pair with the Agent in a notebook, where for example if a package is not installed it will see the error and install it for you. You as the user can then do some data exploration and then hand off to the agent at any time to pick up where you left off.
46

57
## Key Features

docs/docs/intro.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ slug: /
55

66
# Introduction
77

8+
:::warning API Compatibility Notice
9+
This project is currently focused on MCP (Model Context Protocol) usage. There are **no API compatibility guarantees** between versions as the interface is actively evolving. Breaking changes may occur in any release.
10+
:::
11+
812
MCP Jupyter Server allows you to use AI assistants like [Goose](https://block.github.io/goose/) or Cursor to pair with you in JupyterLab notebooks where the state of your variables is preserved by the JupyterLab Kernel.
913

1014
## Why MCP Jupyter?

docs/package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,11 @@
4444
},
4545
"engines": {
4646
"node": ">=18.0"
47+
},
48+
"pnpm": {
49+
"overrides": {
50+
"undici": "5.28.4",
51+
"jiti": "1.20.0"
52+
}
4753
}
4854
}

docs/pnpm-lock.yaml

Lines changed: 0 additions & 11324 deletions
This file was deleted.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "mcp-jupyter"
3-
version = "1.2.0"
3+
version = "1.2.1"
44
description = "MCP Jupyter"
55
readme = "README.md"
66
requires-python = ">=3.10"

src/mcp_jupyter/notebook.py

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,12 @@ def check_notebook_exists(notebook_path: str, server_url: str, token: str) -> bo
5757
return False
5858

5959

60-
def create_new_notebook(
61-
notebook_path: str, cells: List[str], server_url: str, token: str
62-
) -> None:
63-
"""Create a new Jupyter notebook.
60+
def create_new_notebook(notebook_path: str, server_url: str, token: str) -> None:
61+
"""Create a new empty Jupyter notebook.
6462
6563
Args:
6664
notebook_path: Path where to create the notebook, relative to Jupyter server root.
6765
Intermediate directories will be created if they don't exist.
68-
cells: List of cell contents to add
6966
server_url: Jupyter server URL
7067
token: Authentication token
7168
@@ -135,18 +132,7 @@ def create_new_notebook(
135132
},
136133
}
137134

138-
# Add any specified cells
139-
if cells:
140-
for cell_content in cells:
141-
notebook_content["content"]["cells"].append(
142-
{
143-
"cell_type": "code",
144-
"metadata": {},
145-
"source": cell_content,
146-
"execution_count": None,
147-
"outputs": [],
148-
}
149-
)
135+
# Notebook starts empty - use modify_notebook_cells to add content
150136

151137
# Make the API request to create the notebook
152138
try:
@@ -307,15 +293,16 @@ def get_notebook_info(
307293

308294
def prepare_notebook(
309295
notebook_path: str,
310-
cells: Optional[List[str]] = None,
311296
server_url: str = "http://localhost:8888",
312297
token: str = None,
313298
) -> Dict[str, Any]:
314299
"""Prepare notebook for use and start kernel.
315300
301+
Creates an empty notebook if it doesn't exist. To add content, use the
302+
modify_notebook_cells operations after creation.
303+
316304
Args:
317305
notebook_path: Path to the notebook, relative to Jupyter server root
318-
cells: List of cell contents (optional)
319306
server_url: Jupyter server URL
320307
token: Authentication token (defaults to env var)
321308
@@ -338,7 +325,7 @@ def prepare_notebook(
338325

339326
# Create notebook if it doesn't exist
340327
if not notebook_exists:
341-
create_new_notebook(notebook_path, cells or [], server_url, token)
328+
create_new_notebook(notebook_path, server_url, token)
342329
notebook_created = True
343330
else:
344331
notebook_created = False

0 commit comments

Comments
 (0)