Skip to main content

Configuration

Overview

The Jupyter MCP Server supports flexible configuration through environment variables and command-line options to accommodate different deployment scenarios from simple local setups to complex distributed environments.

Server Modes

The server automatically detects the appropriate mode based on deployment context:

ModeDescriptionWhen Used
MCP_SERVERStandalone server connecting via HTTPDocker, remote deployments
JUPYTER_SERVERRuns as Jupyter extension with direct API accessLocal deployments, high-performance

JupyterLab Mode

Environment Variable: JUPYTERLAB=true (default)

  • Enabled: Enhanced UI tools, notebook_run-all-cells tool
  • Disabled: Basic operations only, headless usage

Open Notebook in UI

Environment Variable: OPEN_NOTEBOOK_IN_UI=false (default)

When enabled together with JupyterLab mode, use_notebook also opens the notebook in the JupyterLab UI, which activates its tab. It is off by default so that notebooks used over MCP do not pull the focus away from the tab you are working in.

Transport & Providers

Transport Options

TransportUse CaseConfiguration
STDIO (default)Desktop apps, Docker--transport stdio
Streamable HTTPWeb apps, multiple clients--transport streamable-http --port 4040

Providers

ProviderDescriptionConfiguration
jupyter (default)Standard JupyterLab/Hub--provider jupyter
datalayerEnterprise hosting--provider datalayer

Environment Variables

The server supports both simplified and advanced configuration approaches:

For most users with standard JupyterLab setups:

VariableDescriptionExampleDefaultRequired
JUPYTER_URLURL of your Jupyter serverhttp://localhost:8888http://localhost:8888No
JUPYTER_TOKENAuthentication token for Jupyter servermy-secret-tokenNoneNo*
JUPYTER_PASSWORDPassword for Jupyter server authentication (alternative to token)my-passwordNoneNo*
DOCUMENT_IDDefault notebook path (relative to Jupyter root)notebook.ipynbNoneNo
ALLOWED_JUPYTER_MCP_TOOLSComma-separated list of jupyter-mcp-tools to enablenotebook_run-all-cells,notebook_get-selected-cellnotebook_run-all-cells,notebook_get-selected-cellNo
ALLOW_IMG_OUTPUTEnable multimodal image supporttrue / falsetrueNo

*At least one of JUPYTER_TOKEN or JUPYTER_PASSWORD is required when connecting to a secured Jupyter server. They are independent authentication mechanisms — a server may have both configured, and supplying either one is sufficient to connect. When both are provided to the MCP server, password authentication takes precedence. See Security for details on when to use each.

Advanced Configuration (Complex Deployments)

For deployments requiring granular control over document storage and code sandbox execution:

Document Storage Variables

VariableDescriptionExampleDefault
DOCUMENT_URLURL for notebook file operationshttp://notebook-storage:8888http://localhost:8888
DOCUMENT_TOKENAuthentication for document operationsstorage-access-tokenNone
DOCUMENT_PASSWORDPassword for document server authentication (alternative to token)storage-passwordNone
DOCUMENT_IDNotebook path/IDshared/analysis.ipynbNone

Code Sandbox Execution Variables

VariableDescriptionExampleDefault
CODE_SANDBOX_URLURL for kernel/execution operationshttp://compute-cluster:8888http://localhost:8888
CODE_SANDBOX_TOKENAuthentication for code sandbox operationscompute-access-tokenNone
CODE_SANDBOX_PASSWORDPassword for code sandbox server authentication (alternative to token)compute-passwordNone
CODE_SANDBOX_IDSpecific kernel ID to usekernel-abc123None

MCP Client Authentication

VariableDescriptionExampleDefault
MCP_TOKENToken for authenticating MCP clients (Bearer scheme). Required for streamable-http unless INSECURE_MCP_NOAUTH is set.mcp-client-secret
INSECURE_MCP_NOAUTHAllow streamable-http without MCP client authentication. Not recommended for production.truefalse

Additional Configuration Variables

VariableDescriptionExampleDefault
START_NEW_CODE_SANDBOXCreate new code sandbox vs use existingtrue / falsefalse
PROVIDERProvider type for document and code sandboxjupyter / datalayerjupyter
TRANSPORTTransport method for MCPstdio / streamable-httpstdio
PORTPort for streamable HTTP transport40404040
RECONNECT_INTERVALSeconds before retrying a dropped kernel WebSocket connection. 0 disables auto-reconnect.50
JUPYTER_MCP_EXECUTION_TIMEOUTDefault timeout in seconds for code execution, used when a tool call does not pass its own timeout. Must be greater than 0.300120
JUPYTER_MCP_MAX_EXECUTION_TIMEOUTMaximum timeout in seconds a tool call may request for code execution. Must be greater than 0.72003600
JUPYTERLABEnable JupyterLab modetrue / falsetrue
OPEN_NOTEBOOK_IN_UIOpen the notebook in the JupyterLab UI on use_notebook, activating its tabtrue / falsefalse
JUPYTER_MCP_OTEL_FILEPath for OpenTelemetry span export (JSONL)/tmp/spans.jsonlNone
SANDBOX_VARIANTCode sandbox variant (see Sandbox Variants)jupyter / kaggle / monty / colab / modal / docker / eval / datalayerjupyter
CODE_SANDBOX_PROXY_TOKENProxy token used by the colab sandbox variant (colab-code-sandbox-proxy-token)ya29...None
CODE_SANDBOX_CHANNELS_URLFor the kaggle and colab engines, notebook session websocket channels URL used to derive CODE_SANDBOX_URL and CODE_SANDBOX_IDwss://.../api/kernels/.../channels?...None
SANDBOX_ENVIRONMENTEnvironment name for cloud sandboxes (Datalayer/Modal)python-cpu-envNone
SANDBOX_GPUGPU flavor / accelerator for supported variants. Modal/Datalayer examples: T4, A10G, A100, H100. Kaggle batch examples: NvidiaTeslaT4, NvidiaTeslaP100 (aliases T4, P100 also supported).T4None

Sandbox Variants

By default the server executes code through the code-sandboxes jupyter engine against a Jupyter Server (SANDBOX_VARIANT=jupyter). Setting SANDBOX_VARIANT to any other value routes execution through the code-sandboxes package via a sandbox-backed plain kernel client (when the selected variant exposes one), so the same notebook tools can run code on additional backends.

Sandbox functionality is provided by the optional jupyter_mcp_sandboxes extension. Install it (pip install jupyter_mcp_sandboxes) to expose the sandbox lifecycle tools and use any non-jupyter sandbox variant.

VariantDescriptionExtra installKey variables
jupyter (default)Jupyter Server via code-sandboxes (jupyter engine)JUPYTER_URL, JUPYTER_TOKEN (or CODE_SANDBOX_* + DOCUMENT_*)
kaggleKaggle notebook code sandboxjupyter-mcp-server[kaggle]Default batch mode: KAGGLE_API_TOKEN (or Kaggle credentials). Interactive mode: CODE_SANDBOX_URL (+ KAGGLE_API_TOKEN, or CODE_SANDBOX_ID). Optional accelerator: SANDBOX_GPU.
montyIn-process secure Python interpreter (Monty)jupyter-mcp-server[monty]
colabGoogle Colab code sandboxjupyter-mcp-server[colab]CODE_SANDBOX_URL, CODE_SANDBOX_ID, CODE_SANDBOX_PROXY_TOKEN
modalModal cloud sandboxjupyter-mcp-server[modal]Modal credentials
dockerLocal Docker container running Jupyterjupyter-mcp-server[sandboxes]
evalIn-process exec() (development only)jupyter-mcp-server[sandboxes]
datalayerDatalayer cloud code sandboxjupyter-mcp-server[sandboxes]CODE_SANDBOX_URL, CODE_SANDBOX_TOKEN, SANDBOX_ENVIRONMENT

Example: Google Colab engine

SANDBOX_VARIANT=colab
CODE_SANDBOX_URL=https://8080-m-s-kkb-...-d.us-east1-0.prod.colab.dev
CODE_SANDBOX_ID=a1b2c3d4-....
CODE_SANDBOX_PROXY_TOKEN=ya29....

Example: Kaggle engine

SANDBOX_VARIANT=kaggle
# Default batch mode (no code sandbox URL required):
KAGGLE_API_TOKEN=...
SANDBOX_GPU=T4
# Interactive mode (optional):
# CODE_SANDBOX_URL=https://kkb-production.jupyter-proxy.kaggle.net/k/12345678/eyJ.../proxy
# ...or connect to an existing kernel by also setting CODE_SANDBOX_ID:
# CODE_SANDBOX_ID=11e073f0-e82d-4029-be8d-3918f7ed1a9e

Kaggle accelerator values include NvidiaTeslaP100, NvidiaTeslaT4, NvidiaTeslaT4Highmem, NvidiaL4, NvidiaL4X1, NvidiaTeslaA100, NvidiaH100, and NvidiaRtxPro6000. Aliases like P100 and T4 are accepted.

Example: Monty engine

SANDBOX_VARIANT=monty

Example: Modal engine

SANDBOX_VARIANT=modal
# Modal credentials via `modal token new` or MODAL_TOKEN_ID / MODAL_TOKEN_SECRET

Configuration Priority

Variables are resolved in this order:

  1. Individual variables (DOCUMENT_*, CODE_SANDBOX_*) - highest priority
  2. Simplified variables (JUPYTER_*) - fallback
  3. Default values - when no variables are set

This applies to tokens, passwords, and URLs alike. For example, CODE_SANDBOX_PASSWORD takes precedence over JUPYTER_PASSWORD for code sandbox server authentication.

When both a password and a token are configured for the same server, password authentication takes precedence and the token is ignored.

Configuration Examples

Standard JupyterLab Setup

JUPYTER_URL=http://localhost:8888
JUPYTER_TOKEN=my-token
DOCUMENT_ID=my-notebook.ipynb
ALLOWED_JUPYTER_MCP_TOOLS=notebook_run-all-cells,notebook_get-selected-cell
ALLOW_IMG_OUTPUT=true

JupyterHub with Separate Services

DOCUMENT_URL=http://hub.example.com:8000
DOCUMENT_TOKEN=hub-api-token
CODE_SANDBOX_URL=http://user-server:8888
CODE_SANDBOX_TOKEN=user-server-token
DOCUMENT_ID=shared/analysis.ipynb

Distributed Computing Setup

DOCUMENT_URL=http://file-server:8888
DOCUMENT_TOKEN=file-access-token
CODE_SANDBOX_URL=http://compute-node:8888
CODE_SANDBOX_TOKEN=compute-access-token
ALLOW_IMG_OUTPUT=false

Password-Protected Jupyter Server

JUPYTER_URL=http://localhost:8888
JUPYTER_PASSWORD=my-jupyter-password
DOCUMENT_ID=my-notebook.ipynb

Development Setup

JUPYTER_URL=http://localhost:8888
JUPYTER_TOKEN=dev-token
# DOCUMENT_ID omitted

Command Line Options

For advanced use cases, you can configure the server using command-line flags:

jupyter mcp start --help

Usage: jupyter mcp start [OPTIONS]

Options:
--transport [stdio|streamable-http] Transport type (default: stdio)
--provider [jupyter|datalayer] Provider type (default: jupyter)
--jupyterlab BOOLEAN Enable JupyterLab mode (default: true)
--code-sandbox-url TEXT Runtime URL for kernel operations (default: None)
--code-sandbox-token TEXT Runtime authentication token (default: None)
--code-sandbox-password TEXT Password for code sandbox Jupyter server authentication (default: None)
--mcp-token TEXT Token for authenticating MCP clients (required unless --insecure-mcp-noauth)
--insecure-mcp-noauth Allow streamable-http without MCP client auth (not recommended)
--code-sandbox-id TEXT Specific kernel ID to use (default: None)
--start-new-code-sandbox BOOLEAN Create new code sandbox vs use existing (default: true)
--document-url TEXT Document URL for notebook operations (default: None)
--document-id TEXT Notebook path/ID (default: None)
--document-token TEXT Document authentication token (default: None)
--document-password TEXT Password for document Jupyter server authentication (default: None)
--jupyter-url TEXT Jupyter URL as default for both document and code sandbox URLs (default: None)
--jupyter-token TEXT Jupyter token as default for both document and code sandbox tokens (default: None)
--jupyter-password TEXT Shared password for both code sandbox and document servers (default: None)
--allowed-jupyter-mcp-tools TEXT Comma-separated list of jupyter-mcp-tools to enable (default: notebook_run-all-cells,notebook_get-selected-cell)
--reconnect-interval INTEGER Seconds before retrying a dropped kernel WebSocket connection (default: 0)
--execution-timeout INTEGER RANGE Default timeout in seconds for code execution when a tool call passes no timeout (default: 120)
--max-execution-timeout INTEGER RANGE
Maximum timeout in seconds a tool call may request (default: 3600)
--otel-file TEXT Path for OpenTelemetry span export as JSONL (default: None)
--sandbox-variant TEXT Code sandbox variant: jupyter (default), kaggle, colab, monty, modal, docker, eval, datalayer
--code-sandbox-proxy-token TEXT Proxy token for the colab sandbox variant (default: None)
--code-sandbox-channels-url TEXT WebSocket channels URL for the kaggle or colab sandbox variants (default: None)
--sandbox-environment TEXT Environment name for cloud sandboxes (default: None)
--sandbox-gpu TEXT GPU flavor / accelerator for supported sandbox variants (default: None)
--port INTEGER Port for streamable-http transport (default: 4040)

Additional Commands

The server also supports additional commands for advanced workflows:

Connect Command

jupyter mcp connect --help

Usage: jupyter mcp connect [OPTIONS]

Connect a Jupyter MCP Server to a document and a code sandbox.

Options:
--provider [jupyter|datalayer] Provider type (default: jupyter)
--jupyterlab BOOLEAN Enable JupyterLab mode (default: true)
--code-sandbox-url TEXT Runtime URL for kernel operations (default: None)
--code-sandbox-token TEXT Runtime authentication token (default: None)
--mcp-token TEXT MCP token used to authenticate to /api/connect (Bearer)
--code-sandbox-id TEXT Specific kernel ID to use (default: None)
--document-url TEXT Document URL for notebook operations (default: None)
--document-id TEXT Notebook path/ID (default: None)
--document-token TEXT Document authentication token (default: None)
--jupyter-url TEXT Jupyter URL as default for both document and code sandbox URLs (default: None)
--jupyter-token TEXT Jupyter token as default for both document and code sandbox tokens (default: None)
--reconnect-interval INTEGER Seconds before retrying a dropped kernel WebSocket connection (default: 0)
--execution-timeout INTEGER RANGE Default timeout in seconds for code execution when a tool call passes no timeout (default: 120)
--max-execution-timeout INTEGER RANGE
Maximum timeout in seconds a tool call may request (default: 3600)
--jupyter-mcp-server-url TEXT URL of the Jupyter MCP Server to connect to (default: http://localhost:4040)

Stop Command

jupyter mcp stop --help

Usage: jupyter mcp stop [OPTIONS]

Stop a running Jupyter MCP Server.

Options:
--jupyter-mcp-server-url TEXT URL of the Jupyter MCP Server to stop (default: http://localhost:4040)
--mcp-token TEXT MCP token used to authenticate to /api/stop (Bearer)

Usage Examples

jupyter mcp start \
--transport streamable-http \
--jupyter-url http://localhost:8888 \
--jupyter-token MY_TOKEN \
--allowed-jupyter-mcp-tools "notebook_run-all-cells,notebook_get-selected-cell" \
--port 4040

Advanced Usage

Connecting to Existing Runtime

Start server without creating new code sandbox:

jupyter mcp start \
--transport streamable-http \
--code-sandbox-url http://localhost:8888 \
--code-sandbox-token MY_TOKEN \
--start-new-code-sandbox false

Then connect via endpoint:

jupyter mcp connect \
--provider datalayer \
--document-url <url> \
--document-id <document> \
--document-token <token> \
--code-sandbox-url <url> \
--code-sandbox-id <code-sandbox-id> \
--code-sandbox-token <token> \
--jupyter-mcp-server-url http://localhost:4040

Multimodal Output Support

The server supports multimodal output, allowing AI agents to directly receive and analyze visual content such as images and charts generated by code execution.

Supported Output Types

  • Text Output: Standard text output from code execution
  • Image Output: PNG images generated by matplotlib, seaborn, plotly, and other visualization libraries
  • Error Output: Error messages and tracebacks

Environment Variable Configuration

Control multimodal output behavior using environment variables:

ALLOW_IMG_OUTPUT

Controls whether to return actual image content or text placeholders.

  • Default: true
  • Values: true, false, 1, 0, yes, no, on, off, enable, disable, enabled, disabled

Output Behavior

When ALLOW_IMG_OUTPUT=true (Default)

  • Images are returned as ImageContent objects with actual PNG data
  • AI agents can directly analyze visual content
  • Supports advanced multimodal reasoning

When ALLOW_IMG_OUTPUT=false

  • Images are returned as text placeholders: "[Image Output (PNG) - Image display disabled]"
  • Maintains backward compatibility with text-only LLMs
  • Reduces bandwidth and token usage

Use Cases

Data Visualization Analysis:

import matplotlib.pyplot as plt
import pandas as pd

df = pd.read_csv('sales_data.csv')
df.plot(kind='bar', x='month', y='revenue')
plt.title('Monthly Revenue')
plt.show()
# AI can now "see" and analyze the chart content

Machine Learning Model Visualization:

import matplotlib.pyplot as plt

# Plot training curves
plt.plot(epochs, train_loss, label='Training Loss')
plt.plot(epochs, val_loss, label='Validation Loss')
plt.legend()
plt.show()
# AI can evaluate training effectiveness from the visual curves