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
Provider
Datalayer
Release date
Feb 14, 2025
Language
Python
Package
Stats
255 stars

The Jupyter MCP Server enables AI assistants to interact with Jupyter notebooks through the Model Context Protocol (MCP). It allows tools like Claude to read from and make changes to notebooks running in any JupyterLab environment, including your local installation.

Prerequisites and Installation

Setting Up JupyterLab

Before using the MCP server, you need to ensure JupyterLab is properly configured:

pip install jupyterlab==4.4.1 jupyter-collaboration==4.0.2 ipykernel
pip uninstall -y pycrdt datalayer_pycrdt
pip install datalayer_pycrdt==0.12.15

Start JupyterLab with:

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

The --ip 0.0.0.0 parameter is crucial as it allows the Docker-based MCP server to access your local JupyterLab instance.

Connecting with Claude Desktop

Installing Claude Desktop

  • macOS/Windows: Download from claude.ai/download
  • Linux: An unofficial build is available using nix:
NIXPKGS_ALLOW_UNFREE=1 nix run github:k3d3/claude-desktop-linux-flake \
  --impure \
  --extra-experimental-features flakes \
  --extra-experimental-features nix-command

Configuring Claude Desktop

For macOS and Windows

Create or modify your claude_desktop_config.json with:

{
  "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"
      }
    }
  }
}

For Linux

Use this command to create the configuration file:

CLAUDE_CONFIG=${HOME}/.config/Claude/claude_desktop_config.json
cat <<EOF > $CLAUDE_CONFIG
{
  "mcpServers": {
    "jupyter": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "-e",
        "SERVER_URL",
        "-e",
        "TOKEN",
        "-e",
        "NOTEBOOK_PATH",
        "--network=host",
        "datalayer/jupyter-mcp-server:latest"
      ],
      "env": {
        "SERVER_URL": "http://localhost:8888",
        "TOKEN": "MY_TOKEN",
        "NOTEBOOK_PATH": "notebook.ipynb"
      }
    }
  }
}
EOF

Configuration Notes

When setting up your configuration:

  • Ensure SERVER_URL and TOKEN match your JupyterLab settings
  • Set NOTEBOOK_PATH to be relative to the directory where JupyterLab was started

Available Tools

The MCP server provides two primary tools that AI assistants can use:

1. add_execute_code_cell

This tool adds and executes a code cell in the Jupyter notebook.

Input parameters:

  • cell_content (string): The code to be executed

Returns: The output from cell execution

2. add_markdown_cell

This tool adds a markdown cell to the Jupyter notebook.

Input parameters:

  • cell_content (string): The markdown content

Returns: A success message

Alternative Installation Methods

Building the Docker Image

If you prefer to build the Docker image yourself:

make build-docker

Installing via Smithery

For automatic installation with Smithery:

npx -y @smithery/cli install @datalayer/jupyter-mcp-server --client claude

How to add this MCP server to 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 > MCP and click "Add new global MCP server".

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

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

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 explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

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