Jupyter Notebook MCP server

Integrates Jupyter notebooks with MCP to enable code execution, content manipulation, and interactive data exploration within notebook environments.
Back to servers
Setup instructions
Provider
Datalayer
Release date
Feb 14, 2025
Language
Python
Package
Stats
789 stars

The Jupyter MCP Server provides a bridge between AI assistants and Jupyter notebooks, allowing models to control and interact with notebooks in real-time using the Model Context Protocol (MCP). The server enables AI to read, modify, and execute notebook cells while understanding the full notebook context.

Installation

Setting Up Your Environment

First, install the required dependencies:

pip install jupyterlab==4.4.1 jupyter-collaboration==4.0.2 jupyter-mcp-tools>=0.1.4 ipykernel
pip uninstall -y pycrdt datalayer_pycrdt
pip install datalayer_pycrdt==0.12.17

You can verify your environment is correctly configured by:

  1. Opening a notebook in JupyterLab
  2. Typing content in any cell
  3. Confirming that an "×" appears next to the notebook name
  4. Verifying it automatically changes to a "●" without manual saving

Starting JupyterLab

Launch JupyterLab with:

jupyter lab --port 8888 --IdentityProvider.token MY_TOKEN --ip 0.0.0.0

If you're using JupyterHub instead, ensure:

  • JUPYTERHUB_ALLOW_TOKEN_IN_URL=1 is set in the single-user environment
  • Your API token includes the access:servers scope

Connecting MCP Clients

Configure your MCP client to connect to the server using one of these methods:

Using uvx (Quick Start)

Install uv:

pip install uv

Client configuration:

{
  "mcpServers": {
    "jupyter": {
      "command": "uvx",
      "args": ["jupyter-mcp-server@latest"],
      "env": {
        "JUPYTER_URL": "http://localhost:8888",
        "JUPYTER_TOKEN": "MY_TOKEN",
        "ALLOW_IMG_OUTPUT": "true"
      }
    }
  }
}

Using Docker (Production)

For macOS and Windows:

{
  "mcpServers": {
    "jupyter": {
      "command": "docker",
      "args": [
        "run", "-i", "--rm",
        "-e", "JUPYTER_URL",
        "-e", "JUPYTER_TOKEN",
        "-e", "ALLOW_IMG_OUTPUT",
        "datalayer/jupyter-mcp-server:latest"
      ],
      "env": {
        "JUPYTER_URL": "http://host.docker.internal:8888",
        "JUPYTER_TOKEN": "MY_TOKEN",
        "ALLOW_IMG_OUTPUT": "true"
      }
    }
  }
}

For Linux:

{
  "mcpServers": {
    "jupyter": {
      "command": "docker",
      "args": [
        "run", "-i", "--rm",
        "-e", "JUPYTER_URL",
        "-e", "JUPYTER_TOKEN",
        "-e", "ALLOW_IMG_OUTPUT",
        "--network=host",
        "datalayer/jupyter-mcp-server:latest"
      ],
      "env": {
        "JUPYTER_URL": "http://localhost:8888",
        "JUPYTER_TOKEN": "MY_TOKEN",
        "ALLOW_IMG_OUTPUT": "true"
      }
    }
  }
}

Available Tools

The server provides various tools for interacting with Jupyter notebooks:

Server Management Tools

  • list_files: List files and directories in the Jupyter server's file system
  • list_kernels: List all available and running kernel sessions

Multi-Notebook Management Tools

  • use_notebook: Connect to a notebook file, create a new one, or switch between notebooks
  • list_notebooks: List all notebooks available and their status
  • restart_notebook: Restart the kernel for a specific managed notebook
  • unuse_notebook: Disconnect from a notebook and release its resources
  • read_notebook: Read notebook cells source content with formatting options

Cell Operations and Execution Tools

  • read_cell: Read the full content of a single cell
  • insert_cell: Insert a new code or markdown cell at a specified position
  • delete_cell: Delete a cell at a specified index
  • overwrite_cell_source: Overwrite the source code of an existing cell
  • execute_cell: Execute a cell with timeout, supports multimodal output
  • insert_execute_code_cell: Insert and execute a new code cell in one step
  • execute_code: Execute code directly in the kernel

JupyterLab Integration

  • notebook_run-all-cells: Execute all cells in the current notebook sequentially

Prompt Features

The server also supports MCP prompt features:

  • jupyter-cite: Cite specific cells from a notebook

Best Practices

  • Use LLMs that support multimodal input for full capabilities
  • Choose MCP clients that can handle image data
  • Break complex tasks into manageable subtasks
  • Provide clearly structured prompts
  • Include as much context as possible in your requests

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "jupyter" '{"command":"docker","args":["run","-i","--rm","-e","SERVER_URL","-e","TOKEN","-e","NOTEBOOK_PATH","datalayer/jupyter-mcp-server:latest"],"env":{"SERVER_URL":"http://host.docker.internal:8888","TOKEN":"MY_TOKEN","NOTEBOOK_PATH":"notebook.ipynb"}}'

See the official Claude Code MCP documentation for more details.

For Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "jupyter": {
            "command": "docker",
            "args": [
                "run",
                "-i",
                "--rm",
                "-e",
                "SERVER_URL",
                "-e",
                "TOKEN",
                "-e",
                "NOTEBOOK_PATH",
                "datalayer/jupyter-mcp-server:latest"
            ],
            "env": {
                "SERVER_URL": "http://host.docker.internal:8888",
                "TOKEN": "MY_TOKEN",
                "NOTEBOOK_PATH": "notebook.ipynb"
            }
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

{
    "mcpServers": {
        "jupyter": {
            "command": "docker",
            "args": [
                "run",
                "-i",
                "--rm",
                "-e",
                "SERVER_URL",
                "-e",
                "TOKEN",
                "-e",
                "NOTEBOOK_PATH",
                "datalayer/jupyter-mcp-server:latest"
            ],
            "env": {
                "SERVER_URL": "http://host.docker.internal:8888",
                "TOKEN": "MY_TOKEN",
                "NOTEBOOK_PATH": "notebook.ipynb"
            }
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later