Skip to main content
Glama

Datalayer

Become a Sponsor

🪐🔧 Jupyter MCP Server

An MCP server developed for AI to connect and manage Jupyter Notebooks in real-time

Developed by Datalayer

PyPI - Version Total PyPI downloads Docker Pulls License

Jupyter MCP Server Demo

IMPORTANT

Breaking change in v1.0.0: You must configure MCP_TOKEN in your MCP client setup.

For setup details, see: https://jupyter-mcp-server.datalayer.tech/providers/jupyter-streamable-http-standalone/#3-configure-your-mcp-client

Update in v1.0.2: pycrdt is now supported, so installing datalayer_pycrdt is no longer required.

NOTE

We Need Your Feedback!

We're actively developing support for JupyterHub and Google Colab deployments. If you're using or planning to use Jupyter MCP Server with these platforms, we'd love to hear from you!

  • 🏢 JupyterHub users: Share your deployment setup and requirements

  • 🌐 Google Colab users: Help us understand your use cases and workflows

Join the conversation in our Community page - your feedback will help us prioritize features and ensure these integrations work seamlessly for your needs.

📖 Table of Contents

Related MCP server: mcp-server-jupyter

🚀 Key Features

  • ⚡ Real-time control: Instantly view notebook changes as they happen.

  • 🔁 Smart execution: Automatically adjusts when a cell run fails thanks to cell output feedback.

  • 🧠 Context-aware: Understands the entire notebook context for more relevant interactions.

  • 📊 Multimodal support: Support different output types, including images, plots, and text.

  • 📚 Multi-notebook support: Seamlessly switch between multiple notebooks.

  • 🎨 JupyterLab integration: Enhanced UI integration like automatic notebook opening.

  • 🤝 MCP-compatible: Works with any MCP client, such as Claude Desktop, Cursor, Windsurf, and more.

  • 🔍 Observability: Built-in hook system with OpenTelemetry integration for tracing tool calls and kernel executions.

Compatible with any Jupyter deployment (local, JupyterHub, ...) and with Datalayer hosted Notebooks.

🔧 MCP Overview

🔧 Tools Overview

The server provides a rich set of tools for interacting with Jupyter notebooks, categorized as follows. For more details on each tool, their parameters, and return values, please refer to the official Tools documentation.

Server Management Tools

Name

Description

list_files

List files and directories in the Jupyter server's file system.

list_kernels

List all available and running kernel sessions on the Jupyter server.

connect_to_jupyter

Connect to a Jupyter server dynamically without restarting the MCP server. Not available when running as Jupyter extension. Useful for switching servers dynamically or avoiding hardcoded configuration. Read more

Multi-Notebook Management Tools

Name

Description

use_notebook

Connect to a notebook file, create a new one, or switch between notebooks.

list_notebooks

List all notebooks available on the Jupyter server and their status

restart_notebook

Restart the kernel for a specific managed notebook.

unuse_notebook

Disconnect from a specific notebook and release its resources.

read_notebook

Read notebook cells source content with brief or detailed format options.

Cell Operations and Execution Tools

Name

Description

read_cell

Read the full content (Metadata, Source and Outputs) 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.

move_cell

Move a cell from one position to another within a notebook.

overwrite_cell_source

Overwrite the source code of an existing cell.

edit_cell_source

Apply surgical find-and-replace edits to a cell's source without full rewrite.

execute_cell

Execute a cell with timeout, supports multimodal output including images.

insert_execute_code_cell

Insert a new code cell and execute it in one step.

execute_code

Execute code directly in the kernel, supports magic commands and shell commands.

JupyterLab Integration

Available only when JupyterLab mode is enabled. It is enabled by default.

When running in JupyterLab mode, Jupyter MCP Server integrates with jupyter-mcp-tools to expose additional JupyterLab commands as MCP tools. By default, the following tools are enabled:

Name

Description

notebook_run-all-cells

Execute all cells in the current notebook sequentially

notebook_get-selected-cell

Get information about the currently selected cell

You can now customize which tools from jupyter-mcp-tools are available using the allowed_jupyter_mcp_tools configuration parameter. This allows you to enable additional notebook operations, console commands, file management tools, and more.

# Example: Enable additional tools via command-line
jupyter lab --port 4040 --IdentityProvider.token MY_TOKEN --JupyterMCPServerExtensionApp.allowed_jupyter_mcp_tools="notebook_run-all-cells,notebook_get-selected-cell,notebook_append-execute,console_create"

For the complete list of available tools and detailed configuration instructions, please refer to the Additional Tools documentation.

📝 Prompt Overview

The server also supports prompt feature of MCP, providing a easy way for user to interact with Jupyter notebooks.

Name

Description

jupyter-cite

Cite specific cells from specified notebook (like @ in Coding IDE or CLI)

For more details on each prompt, their input parameters, and return content, please refer to the official Prompt documentation.

🏁 Getting Started

For comprehensive setup instructions—including Streamable HTTP transport, running as a Jupyter Server extension and advanced configuration—check out our documentation. Or, get started quickly with JupyterLab and STDIO transport here below.

1. Set Up Your Environment

pip install jupyterlab==4.4.1 jupyter-collaboration==4.0.2 jupyter-mcp-tools>=0.1.4 ipykernel pycrdt
TIP

To confirm your environment is correctly configured:

  1. Open a notebook in JupyterLab

  2. Type some content in any cell (code or markdown)

  3. Observe the tab indicator: you should see an "×" appear next to the notebook name, indicating unsaved changes

  4. Wait a few seconds—the "×" should automatically change to a "●" without manually saving

This automatic saving behavior confirms that the real-time collaboration features are working properly, which is essential for MCP server integration.

2. Start JupyterLab

# Start JupyterLab on port 8888, allowing access from any IP and setting a token
jupyter lab --port 8888 --IdentityProvider.token MY_TOKEN --ip 0.0.0.0
NOTE

If you are running notebooks through JupyterHub instead of JupyterLab as above, refer to ourJupyterHub setup guide.

3. Configure Your Preferred MCP Client

Next, configure your MCP client to connect to the server. We offer two primary methods—choose the one that best fits your needs:

  • 📦 Using uvx (Recommended for Quick Start): A lightweight and fast method using uv. Ideal for local development and first-time users.

  • 🐳 Using Docker (Recommended for Production): A containerized approach that ensures a consistent and isolated environment, perfect for production or complex setups.

First, install uv:

pip install uv
uv --version
# should be 0.6.14 or higher

See more details on uv installation.

Then, configure your client:

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

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

On 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"
      }
    }
  }
}
TIP
  1. Port Configuration: Ensure the port in your Jupyter URLs matches the one used in the jupyter lab command. For simplified config, set this in JUPYTER_URL.

  2. Server Separation: Use JUPYTER_URL when both services are on the same server, or set individual variables for advanced deployments. The different URL variables exist because some deployments separate notebook storage (DOCUMENT_URL) from kernel execution (RUNTIME_URL).

  3. Authentication: In most cases, document and runtime services use the same authentication token. Use JUPYTER_TOKEN for simplified config or set DOCUMENT_TOKEN and RUNTIME_TOKEN individually for different credentials.

  4. Notebook Path: The DOCUMENT_ID parameter specifies the path to the notebook the MCP client default to connect. It should be relative to the directory where JupyterLab was started. If you omit DOCUMENT_ID, the MCP client can automatically list all available notebooks on the Jupyter server, allowing you to select one interactively via your prompts.

  5. Image Output: Set ALLOW_IMG_OUTPUT to false if your LLM does not support mutimodel understanding.

For detailed instructions on configuring various MCP clients—including Claude Desktop, VS Code, Cursor, Cline, and Windsurf — see the Clients documentation.

✅ Best Practices

  • Interact with LLMs that supports multimodal input (like Gemini 2.5 Pro) to fully utilize advanced multimodal understanding capabilities.

  • Use a MCP client that supports returning image data and can parse it (like Cursor, Gemini CLI, etc.), as some clients may not support this feature.

  • Break down complex task (like the whole data science workflow) into multiple sub-tasks (like data cleaning, feature engineering, model training, model evaluation, etc.) and execute them step-by-step.

  • Provide clearly structured prompts and rules (👉 Visit our Prompt Templates to get started)

  • Provide as much context as possible (like already installed packages, field explanations for existing datasets, current working directory, detailed task requirements, etc.).

🤝 Contributing

We welcome contributions of all kinds! Here are some examples:

  • 🐛 Bug fixes

  • 📝 Improvements to existing features

  • 🔧 New feature development

  • 📚 Documentation improvements and prompt templates

For detailed instructions on how to get started with development and submit your contributions, please see our Contributing Guide.

Our Contributors

Contributors

📚 Resources

Looking for blog posts, videos, or other materials about Jupyter MCP Server?

👉 Visit the Resources section in our documentation for more!

Star History Chart


If this project is helpful to you, please give us a ⭐️

Made with ❤️ by Datalayer

Hosted deployment

A hosted deployment is available on Fronteir AI.

Available Tools

18 tools
clear_cell_outputA
Destructive

Clear the outputs and execution count of a single code cell in the currently activated notebook, without deleting the cell itself.

Inputs: cell_index (required). Returns: result

connect_to_jupyterA
Destructive

Connect to a Jupyter server dynamically with URL and token.

This tool allows you to connect to different Jupyter servers without needing to
restart the MCP server or modify configuration files. Particularly useful when:
- Working with multiple Jupyter servers with different ports/tokens
- Jupyter server token changes dynamically
- Need to switch between different Jupyter instances

Example usage:
- "Connect to http://localhost:8888 with token abc123"
- "Connect to http://localhost:8889 without authentication"

Inputs: jupyter_url (required), provider, jupyter_token. Returns: result

delete_cellA
Destructive

Delete specific cells from the currently activated notebook and return the cell source of deleted cells (if include_source=True).

Inputs: cell_indices (required), include_source. Returns: result

edit_cell_sourceA
Destructive

Perform a surgical find-and-replace within a cell's source (like an editor's Edit tool). Finds old_string in the cell and replaces it with new_string. Matching is literal (not regex) and may span multiple lines. By default, old_string must appear exactly once; set replace_all=True for multiple occurrences. Returns a diff of the changes made.

Prefer this over overwrite_cell_source for small, targeted edits — it is safer because
unchanged parts of the cell are left untouched. Use read_cell first to see the current
source and construct an accurate old_string.

Inputs: cell_index (required), new_string (required), old_string (required), replace_all. Returns: result

execute_cellC
Destructive

Execute a cell from the currently activated notebook with timeout and return it's outputs

Inputs: cell_index (required), stream, timeout, progress_interval.

execute_codeA
Destructive

Execute code directly in a kernel (not saved to notebook).

If `use_sandbox` selected an active sandbox, this tool executes on that
sandbox instead of a Jupyter kernel. This allows agents to switch between
kernel-backed and sandbox-backed execution using the same execute_code API.

Targets the current activated notebook's kernel by default. Pass kernel_id
to execute in a specific kernel directly — including raw kernels with no
notebook attached.

Recommended to use in following cases:
1. Execute Jupyter magic commands(e.g., `%timeit`, `%pip install xxx`)
2. Performance profiling and debugging.
3. View intermediate variable values(e.g., `print(xxx)`, `df.head()`)
4. Temporary calculations and quick tests(e.g., `np.mean(df['xxx'])`)
5. Execute Shell commands in Jupyter server(e.g., `!git xxx`)

Under no circumstances should you use this tool to:
1. Import new modules or perform variable assignments that affect subsequent Notebook execution
2. Execute dangerous code that may harm the Jupyter server or the user's data without permission

Inputs: code (required), timeout, kernel_id.

insert_cellB
Destructive

Insert a cell to specified position from the currently activated notebook.

Inputs: cell_type (required), cell_index (required), cell_source (required). Returns: result

insert_execute_code_cellA
Destructive

Insert a cell at specified index from the currently activated notebook and then execute it with timeout and return it's outputs It is a shortcut tool for insert_cell and execute_cell tools, recommended to use if you want to insert a cell and execute it at the same time

Inputs: cell_index (required), cell_source (required), timeout.

list_filesA
Read-only

List all files and directories recursively in the Jupyter server's file system. Used to explore the file system structure of the Jupyter server or to find specific files or directories.

Inputs: path, limit, pattern, max_depth, +1 more. Returns: result

list_kernelsA
Read-only

List all available kernels in the Jupyter server.

This tool shows all running and available kernel sessions on the Jupyter server, including their IDs, names, states, connection information, and kernel specifications. Useful for monitoring kernel resources and identifying specific kernels for connection.

Inputs: no named parameters. Returns: result

list_notebooksA
Read-only

List all notebooks that have been used via use_notebook tool

Inputs: no named parameters. Returns: result

move_cellA
Destructive

Move a cell from source_index to target_index within the currently activated notebook.

The cell is removed from source_index and placed at target_index. Cells in between shift
to fill the gap. The cell's type, source, and outputs are preserved.
Example: in a notebook [A, B, C, D], move_cell(1, 3) produces [A, C, D, B].

Use this tool instead of manually deleting and re-inserting a cell — it is atomic and
preserves cell metadata. Use read_notebook first to see cell indices if needed.

Inputs: source_index (required), target_index (required). Returns: result

overwrite_cell_sourceA
Destructive

Replace the entire source of a cell in the currently activated notebook. Returns a diff showing the changes made.

Use this when rewriting a cell completely. For small, targeted changes,
prefer edit_cell_source instead — it is safer for partial edits.

Inputs: cell_index (required), cell_source (required). Returns: result

read_cellA
Read-only

Read a specific cell from the currently activated notebook and return it's metadata (index, type, execution count), source and outputs (for code cells)

Inputs: cell_index (required), include_outputs.

read_notebookA
Read-only

Read a notebook and return index, source content, type, execution count of each cell.

Using brief format to get a quick overview of the notebook structure and it's useful for locating specific cells for operations like delete or insert. Using detailed format to get detailed information of the notebook and it's useful for debugging and analysis.

It is recommended to use brief format with larger limit to get a overview of the notebook structure, then use detailed format with exact index and limit to get the detailed information of some specific cells.

Inputs: notebook_name (required), limit, start_index, response_format. Returns: result

restart_notebookB
Destructive

Restart the kernel for a specific notebook.

Inputs: notebook_name (required). Returns: result

unuse_notebookC
Destructive

Unuse from a specific notebook and release its resources.

Inputs: notebook_name (required). Returns: result

use_notebookA
Destructive

Use a notebook and activate it for following cell operations. All cell operations will be performed on the currently activated notebook. Activate new notebook will deactivate the previously activated notebook. Reactivate previously activated notebook using same notebook_name and notebook_path.

Inputs: notebook_name (required), notebook_path (required), mode, kernel_id. Returns: result

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.6/5.0

    Scored across 18 tools

    Disambiguation4/5

    Most tools have clear, distinct purposes, especially with explicit guidance distinguishing edit_cell_source from overwrite_cell_source. The three execution-related tools (execute_cell, insert_execute_code_cell, execute_code) could be confused at first glance, but their descriptions clarify the differences.

    Naming Consistency4/5

    The set largely follows a verb_noun pattern (read_cell, delete_cell, move_cell, restart_notebook). Minor inconsistencies like insert_execute_code_cell and unuse_notebook break the rhythm slightly, but the pattern remains predictable overall.

    Tool Count4/5

    18 tools is on the heavier side but reasonable for a Jupyter notebook server covering connection, notebook lifecycle, cell operations, execution, and file/kernel browsing. The count is justified by the breadth of operations rather than redundancy.

    Completeness4/5

    The set covers notebook activation, cell reading/writing/execution/movement/deletion, kernel restarts, and dynamic connection. Missing operations like creating/saving notebooks or managing kernels beyond restarting are notable but do not severely undermine the core workflow.

    Maintenance

    ActivityActive
    ResponsivenessUsually handled

    Related MCP Connectors

    Related MCP Servers