Skip to main content

An MCP server for AI agents to interact with Jupyter notebooks

Project description

MCP Jupyter Notebook Server

License

A Model Context Protocol (MCP) server that gives AI agents full control over a live Jupyter notebook session — run code, add markdown, manage packages, inspect variables, and more. Built on agent-jupyter-toolkit and the MCP Python SDK.

20 tools transports Python 3.11+

Features

  • 17 MCP tools — code execution, markdown, packages, kernel control, introspection, variables
  • Real-time sync — Yjs collaboration transport shows cell edits instantly in JupyterLab
  • Two session modes — connect to a remote Jupyter server or run a local kernel
  • Three transports — stdio (for editors), SSE, or streamable HTTP
  • Zero config defaults — sensible defaults with full override via CLI args or env vars

Quick Start

1. Start a Jupyter server

# With Docker (recommended — includes jupyter-collaboration)
cd quickstarts && docker compose up -d --build

# Or locally
pip install jupyterlab ipykernel jupyter-collaboration
jupyter lab --port 8888 --IdentityProvider.token=mcp-dev-token

2. Configure your editor

VS Code — create .vscode/mcp.json:

{
  "servers": {
    "jupyter": {
      "type": "stdio",
      "command": "uv",
      "args": ["run", "--directory", "${workspaceFolder}", "mcp-jupyter-notebook"],
      "env": {
        "MCP_JUPYTER_SESSION_MODE": "server",
        "MCP_JUPYTER_BASE_URL": "http://localhost:8888",
        "MCP_JUPYTER_TOKEN": "mcp-dev-token",
        "MCP_JUPYTER_NOTEBOOK_PATH": "agent_demo.ipynb"
      }
    }
  }
}

See the quickstart guide for Cursor, Claude Desktop, and published (uvx) vs local dev configs.

3. Use it

Ask your agent:

"Create a notebook that generates 100 random numbers, plots a histogram, and adds a markdown summary."


Tools

Code Execution

Tool Description
notebook_code_run Append a new code cell, execute it, and return outputs (stdout, stderr, rich displays)
notebook_code_run_existing Replace the source of an existing cell (by index) and re-execute it
notebook_code_execute Execute code in the kernel without creating a notebook cell (background work)
notebook_cells_run Execute multiple cells sequentially (code and/or markdown)

Notebook Document

Tool Description
notebook_markdown_add Append a markdown cell to the notebook
notebook_read Read all cells, sources, outputs, and metadata
notebook_cell_delete Delete a cell by its 0-based index

Packages

Tool Description
notebook_packages_install Install Python packages in the kernel (pip-style specifiers)
notebook_packages_check Check which packages are available without installing

Kernel Control

Tool Description
notebook_kernel_interrupt Interrupt a running computation (SIGINT)
notebook_kernel_info Get kernel metadata (protocol version, language info, banner)
notebook_session_info Get session info (kernel type, alive status, connections)

Introspection

Tool Description
notebook_inspect Inspect an object — returns docs, type info, docstrings
notebook_complete Get tab-completion suggestions at a cursor position
notebook_variables_list List user-defined variables in the kernel's global scope
notebook_variable_get Get the value of a specific variable
notebook_variable_set Set a variable in the kernel's global scope

Full tool reference with parameters and examples: docs/tools.md


Installation

# From PyPI (when published)
uvx mcp-jupyter-notebook

# From source
git clone https://github.com/Cyb3rWard0g/mcp-jupyter-notebook.git
cd mcp-jupyter-notebook
uv pip install -e ".[dev]"

Configuration

All settings can be passed as CLI arguments or environment variables. CLI arguments take precedence.

Variable CLI Flag Description Default
MCP_JUPYTER_SESSION_MODE --mode server (remote Jupyter) or local server
MCP_JUPYTER_BASE_URL --base-url Jupyter server URL
MCP_JUPYTER_TOKEN --token Jupyter API token
MCP_JUPYTER_KERNEL_NAME --kernel-name Kernel spec name python3
MCP_JUPYTER_NOTEBOOK_PATH --notebook-path Notebook file path (.ipynb) auto-generated
MCP_JUPYTER_TRANSPORT --transport stdio, sse, streamable-http stdio
MCP_JUPYTER_HOST --host Host for HTTP transports 127.0.0.1
MCP_JUPYTER_PORT --port Port for HTTP transports 8000
MCP_JUPYTER_LOG_LEVEL DEBUG, INFO, WARNING, ERROR INFO
MCP_JUPYTER_HEADERS_JSON Extra HTTP headers as JSON object
MCP_JUPYTER_PREFER_COLLAB Use Yjs real-time sync (true/false) true

Full configuration reference: docs/mcp-server/configuration.md


Project Structure

src/mcp_jupyter_notebook/
├── __init__.py     # CLI entry point (argparse)
├── server.py       # FastMCP server, lifespan, config processing
├── context.py      # AppContext dataclass (shared lifespan state)
└── tools.py        # All 17 MCP tool definitions

Development

git clone https://github.com/Cyb3rWard0g/mcp-jupyter-notebook.git
cd mcp-jupyter-notebook
uv pip install -e ".[dev]"

# Run tests
uv run pytest

# Lint
uv run ruff check src/ tests/
uv run ruff format src/ tests/

See docs/architecture.md for internals and CONTRIBUTING.md for the release process.


License

Apache License 2.0

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_notebook-0.3.0.tar.gz (24.4 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_notebook-0.3.0-py3-none-any.whl (22.5 kB view details)

Uploaded Python 3

File details

Details for the file mcp_jupyter_notebook-0.3.0.tar.gz.

File metadata

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

File hashes

Hashes for mcp_jupyter_notebook-0.3.0.tar.gz
Algorithm Hash digest
SHA256 421190ebc631c720d2ccdb7e085c9865f0f110793518e96a1bb5768a36754d8c
MD5 f1ac259e303ad9706e903d73e5f0fc26
BLAKE2b-256 a94bfad5aa82bb4a1f6887ff2e7a48566ebacb609c3773f6531a250fb4fd104f

See more details on using hashes here.

Provenance

The following attestation bundles were made for mcp_jupyter_notebook-0.3.0.tar.gz:

Publisher: release.yml on Cyb3rWard0g/agent-jupyter-toolkit

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_notebook-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for mcp_jupyter_notebook-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 086586a8c5a903ee32b24bef4f279ca35d9b7dcc889a48393cf26edd7a937670
MD5 d779f5c02ded0257a20602218aadbd82
BLAKE2b-256 e9ccbae7efe590db8193e8db7b3a4755ae33e96f1f354b074f216b36c53ad974

See more details on using hashes here.

Provenance

The following attestation bundles were made for mcp_jupyter_notebook-0.3.0-py3-none-any.whl:

Publisher: release.yml on Cyb3rWard0g/agent-jupyter-toolkit

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