Skip to main content

MCP Jupyter

Project description

Jupyter MCP Server

⚠️ 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.

Jupyter MCP Server allows you to use tools like Goose or Cursor to pair with you in a JupyterLab notebook where the state of your variables is preserved by the JupyterLab Kernel. This enables seamless collaboration where agents can install packages, fix errors, and hand off to you for data exploration at any time.

Architecture: Uses Jupyter's REST API for reliable agent operations while maintaining real-time user synchronization through RTC. See Architecture Documentation for detailed technical information.

Key Features

  • 4 Consolidated MCP Tools (reduced from 11):
    • query_notebook - All read-only operations (view source, check server, etc.)
    • modify_notebook_cells - All cell modifications (add, edit, delete cells)
    • execute_notebook_code - All execution operations (run cells, install packages)
    • setup_notebook - Notebook initialization and kernel connection
  • Workflow-oriented design optimized for AI agent collaboration
  • State preservation across notebook sessions
  • Automatic parameter validation with float-to-int conversion

This works with any client that supports MCP but will focus on using Goose for the examples.

Requirements

You will need UV is required to be installed.

Installation

This MCP server supports multiple transport modes and can be added to client with the command uvx mcp-jupyter.

Transport Modes

The server supports two transport protocols:

  • stdio (default) - Standard input/output communication, ideal for local IDE integrations
  • http - Streamable HTTP transport with session management, enabling serverless deployments and remote access

Use Cases for HTTP Transport

  • Serverless deployments: Host the MCP server in cloud environments (AWS Lambda, Google Cloud Functions, etc.)
  • Remote access: Connect to the server from different machines or networks
  • Web integrations: Build web-based AI assistants that connect to the MCP server
  • Stateless operations: Use --stateless-http for environments where session persistence isn't needed

To use a specific transport:

# Default stdio transport
uvx mcp-jupyter

# HTTP transport on custom port (stateful - maintains session)
uvx mcp-jupyter --transport http --port 8080

# HTTP transport in stateless mode (no session persistence)
uvx mcp-jupyter --transport http --port 8080 --stateless-http

Using HTTP Transport with Cursor

To connect Cursor to an HTTP MCP server:

  1. Start the server separately:
uvx mcp-jupyter --transport http --port 8090
  1. Configure Cursor's .cursor/mcp.json:
{
  "mcpServers": {
    "notebook-http": {
      "url": "http://localhost:8090/mcp/"  // ⚠️ Trailing slash is REQUIRED
    }
  }
}

Important: The trailing slash (/mcp/) is required for Cursor to connect properly to the HTTP endpoint.

Usage

Start Jupyter

The server expects that a server is already running on a port that is available to the client. If the environmental variable TOKEN is not set, it will default to "BLOCK". The server requires that jupyter-collaboration and ipykernel are installed.

Option 1: Using uv venv

# Create virtual environment
uv venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate

# Install Jupyter dependencies
uv pip install jupyterlab jupyter-collaboration ipykernel

# Start Jupyter
jupyter lab --port 8888 --IdentityProvider.token BLOCK --ip 0.0.0.0

Option 2: Using uv project

# Initialize project (if you don't have one)
uv init jupyter-workspace && cd jupyter-workspace

# Install Jupyter dependencies
uv add jupyterlab jupyter-collaboration ipykernel

# Start Jupyter
uv run jupyter lab --port 8888 --IdentityProvider.token BLOCK --ip 0.0.0.0

Goose Usage

Here's a demonstration of the tool in action:

MCP Jupyter Demo

You can view the Generated notebook here: View Demo Notebook

Development

Steps remain similar except you will need to clone this mcp-jupyter repository and use that for the server instead of the precompiled version.

MCP Server

  1. Clone and setup the repository:
mkdir ~/Development
cd ~/Development
git clone https://github.com/block/mcp-jupyter.git
cd mcp-jupyter

# Sync all dependencies
uv sync

Using editable mode allows you to make changes to the server and only have you need to restart Goose, etc. goose session --with-extension "uv run --directory $(pwd) mcp-jupyter"

LLM Evaluation

This project includes a comprehensive testing infrastructure for validating how well different LLMs can generate MCP tool calls from natural language prompts.

Test Architecture

The LLM testing system uses a pluggable provider architecture:

  • LLMProvider: Abstract base class that all providers implement
  • LLMResponse: Standardized response format with success metrics and metadata
  • Parameterized tests: Same test runs against all available providers

Current Providers

  • ClaudeCodeProvider: Uses the Claude Code SDK (no API key required)

Running LLM Tests

# Run LLM tool call generation tests
uv run pytest -m llm -v

# See LLM working in real-time (shows detailed progress)
uv run pytest -m llm -v -s

# Run all tests except LLM tests (default behavior)
uv run pytest -v

What the Tests Validate

Each LLM provider is tested on its ability to:

  1. Understand natural language prompts about Jupyter notebook tasks
  2. Generate correct MCP tool calls (query_notebook, setup_notebook, modify_notebook_cells)
  3. Successfully execute the calls to create notebooks with expected content
  4. Handle errors gracefully when operations fail

Adding New Providers

To add a new LLM provider:

  1. Implement the interface:
# tests/llm_providers/my_llm.py
from .base import LLMProvider, LLMResponse

class MyLLMProvider(LLMProvider):
    @property
    def name(self) -> str:
        return "my-llm"

    async def send_task(self, prompt: str, server_url: str, verbose: bool = False):
        # Implement LLM interaction
        pass

    async def get_final_response(self) -> LLMResponse:
        # Return standardized response
        pass

    async def cleanup(self):
        # Clean up resources
        pass
  1. Update configuration:
# tests/llm_providers/config.py - add to get_available_providers()
if os.getenv("MY_LLM_API_KEY"):
    from .my_llm import MyLLMProvider
    providers.append(MyLLMProvider())
  1. Test automatically: Your provider will be included in parameterized tests when its environment variables are set.

This infrastructure makes it easy to validate and compare how different LLMs perform at generating MCP tool calls for Jupyter notebook automation.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mcp_jupyter-2.0.2.tar.gz (985.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mcp_jupyter-2.0.2-py3-none-any.whl (31.4 kB view details)

Uploaded Python 3

File details

Details for the file mcp_jupyter-2.0.2.tar.gz.

File metadata

  • Download URL: mcp_jupyter-2.0.2.tar.gz
  • Upload date:
  • Size: 985.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for mcp_jupyter-2.0.2.tar.gz
Algorithm Hash digest
SHA256 27b9c084273197cb24d8085f2aae87973132612f412656acc17ec0497b0c11a2
MD5 3754ae895f7995fc81bbb7043332ffb6
BLAKE2b-256 dd3c7ac70014490b6f11dd6e824249e30b194276c5c710128fa70a6109f55c73

See more details on using hashes here.

Provenance

The following attestation bundles were made for mcp_jupyter-2.0.2.tar.gz:

Publisher: publish.yml on block/mcp-jupyter

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mcp_jupyter-2.0.2-py3-none-any.whl.

File metadata

  • Download URL: mcp_jupyter-2.0.2-py3-none-any.whl
  • Upload date:
  • Size: 31.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for mcp_jupyter-2.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 77401017d78aaec183218ca865bdb13787889d1d520b88f5177642f6251554e9
MD5 e38ce511ee8f870eb1fb5eb09dfd65fa
BLAKE2b-256 b34a7bdb3ad1b7c1829c0646a0c7068338fcf520d0b0389287b26bdab964f2d4

See more details on using hashes here.

Provenance

The following attestation bundles were made for mcp_jupyter-2.0.2-py3-none-any.whl:

Publisher: publish.yml on block/mcp-jupyter

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page