Skip to main content

A Jupyter-based MCP server for code interpretation

Project description

Jupyter Interpreter MCP

A remote Jupyter-based MCP (Model Context Protocol) server for code interpretation. This server connects to a remote Jupyter server (e.g. running in a Docker container or cloud instance) and provides a persistent, sandboxed code execution environment similar to Jupyter notebooks. Supports both Python and bash command execution.

Architecture

MCP Server → RemoteJupyterClient → Jupyter REST API → Remote Kernel
                                          ↓
                              WebSocket Connection
                                          ↓
                           Jupyter server Filesystem

All code executes within the remote Jupyter server. Session history files are stored in the server's filesystem, not on the host. You can execute both Python code and bash commands (e.g., ls, pwd, cat file.txt). Requirements

Requirements

  • Python 3.10 or higher
  • uv package manager
  • Network access to a Jupyter server

Quick Start

1. (Optional) Start Jupyter Container

This is only necessary if you don't use any other remote instance of Jupyter. Run a Jupyter container with the required port mappings, e.g.:

docker run -d \
  --name jupyter-notebook \
  -p 8889:8888 \
  jupyter/minimal-notebook:latest

2. Get Authentication Token

Create a new token for accessing the Jupyter server or use an existing token.

3. Run the MCP server

Using uvx

Start the server using uvx:

uvx jupyter-interpreter-mcp --jupyter-base-url http://localhost:8889 --jupyter-token abc123def456... --notebooks-folder /home/jovyan/notebooks

or to add it to e.g. Claude Code:

{
  "mcpServers": {
    "jupyter-interpreter-mcp": {
      "command": "uvx",
      "args": [
        "jupyter-interpreter-mcp",
        "--jupyter-base-url",
        "http://localhost:8889",
        "--jupyter-token",
        "abc123def456...",
        "--notebooks-folder",
        "/home/jovyan/notebooks"
      ]
    }
  }
}

From source

Create a .env file in the project root:

JUPYTER_BASE_URL=http://localhost:8889
JUPYTER_TOKEN=abc123def456...
NOTEBOOKS_FOLDER=/home/jovyan/notebooks

See .env.example for full configuration options and Docker setup instructions.

You can then install and run the server using uv:

uv pip install .
uv run jupyter-interpreter-mcp

The server will validate the connection to Jupyter on startup and fail with a clear error message if the connection cannot be established.

Tools

execute_code

Executes code (Python or bash) within a persistent session, retaining past results (e.g., variables, imports). Similar to a Jupyter notebook.

Parameters:

  • code (string, required): The code to execute (Python or bash commands)
  • session_id (integer, optional): A unique identifier used to associate multiple code execution requests with the same logical session. If this is the first request, you may omit it or set it to 0. The system will generate and return a new session_id, which should be reused in follow-up requests to maintain continuity within the same session.

Returns: A dictionary containing:

  • result (list of strings): Output from the code execution
  • error (list of strings): Any errors that occurred during execution
  • session_id (integer): The session ID to use for subsequent requests

Example usage:

# First execution - creates a new session
result = execute_code(code="x = 42\nprint(x)")
# Returns: {"result": ["42"], "error": [], "session_id": 1704380400}

# Subsequent execution - reuses the session
result = execute_code(code="print(x * 2)", session_id=1704380400)
# Returns: {"result": ["84"], "error": [], "session_id": 1704380400}

# Bash commands
result = execute_code(code="ls -la", session_id=1704380400)

Development

Installing Development Dependencies

uv pip install -e ".[dev,test]"

Testing

Tests can be run using pytest. If you're using mcpo you can start the server using e.g. the following command:

uvx mcpo --port 8000 -- uv run --directory /path/to/jupyter-interpreter-mcp jupyter-interpreter-mcp

For this, a configured .env file is required. You can then test the MCP server endpoint at http://localhost:8000/docs.

License

MIT

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

jupyter_interpreter_mcp-0.2.1.tar.gz (22.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jupyter_interpreter_mcp-0.2.1-py3-none-any.whl (12.5 kB view details)

Uploaded Python 3

File details

Details for the file jupyter_interpreter_mcp-0.2.1.tar.gz.

File metadata

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

File hashes

Hashes for jupyter_interpreter_mcp-0.2.1.tar.gz
Algorithm Hash digest
SHA256 78efbf6ed2e4eb803abba9f2a0cca92bf9aed9df56612b06cf6fd267f380e678
MD5 6cf290d4fb43fc442aa6d08a49d2fed9
BLAKE2b-256 7e6bba3d55fc2ba294a4bf48f747abfe9a2dad61c6c3bd59dc764f4e86242783

See more details on using hashes here.

Provenance

The following attestation bundles were made for jupyter_interpreter_mcp-0.2.1.tar.gz:

Publisher: release.yml on lmseidler/jupyter-interpreter-mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file jupyter_interpreter_mcp-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for jupyter_interpreter_mcp-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 91195181a4911a01b4d117dac667eb44bc388a4051d3edf465d267ee0be9a148
MD5 9c87d7905a690c4d41e2cf0e0f70d889
BLAKE2b-256 7cc06906bcd64a0e8c0c9fd75f5d5ebe137a989820094b047924ea166beac440

See more details on using hashes here.

Provenance

The following attestation bundles were made for jupyter_interpreter_mcp-0.2.1-py3-none-any.whl:

Publisher: release.yml on lmseidler/jupyter-interpreter-mcp

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