IM

ihrpr/mcp-server-jupyter

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

34 stars 5 forks 质量 66 趋势 12MIT

Jupyter Notebooks 和 JupyterLab 的 MCP 服务器

概览

一个MCP服务器,用于程序化管理和交互Jupyter笔记本。 服务器提供六种笔记本操作工具: 1. read_notebook_with_outputs:读取笔记本的内容,包括单元输出 2. read_notebook_source_only:阅读笔记本内容,无需输出 - 必备:notebook_path(字符串)- 当大小限制导致无法带输出读取完整笔记本时使用 3. read_output_of_cell:读取特定单元的输出 - 必修:- notebook_path(字符串)- cell_id(字符串) - 必修:- notebook_path(字符串)- 源(字符串)- 可选:- cell_type(字符串):“代码”或“标记”- 位置(整数):插入索引(-1用于附加)

概述(AI 翻译)

一个MCP服务器,用于程序化管理和交互Jupyter笔记本。

组成部分

工具

服务器提供六种笔记本操作工具:

  1. read_notebook_with_outputs:读取笔记本内容,包括单元输出
  • 必备:notebook_path(字符串)
  1. read_notebook_source_only:读取笔记本内容,无需输出
  • 必修:notebook_path(字符串)
  • 当体积限制导致无法读取带输出的完整笔记本时使用
  1. read_output_of_cell:读取特定单元的输出
  • 必修:
  • notebook_path(字符串)
  • cell_id(字符串)
  1. add_cell:向笔记本添加新单元格
  • 必修:
  • notebook_path(字符串)
  • source(字符串)
  • 可选:
  • cell_type(字符串):“代码”或“标记”
  • position(整数):插入索引(-1 用于附加)
  1. edit_cell:修改现有细胞内容
  • 必修:
  • notebook_path(字符串)
  • cell_id(字符串):要编辑单元格的唯一ID
  • source(字符串)
  1. execute_cell:执行特定单元并返回其输出
  • 必修:
  • notebook_path(字符串)
  • cell_id(弦)
  • 用于验证单元的执行和输出

使用 Claude Desktop

本页由 AI 翻译,技术细节请以原文为准。

README

以下为原文 README 节选,完整内容请查看原文。

mcp-server-jupyter

An MCP server for managing and interacting with Jupyter notebooks programmatically.

Components

Tools

The server provides six tools for notebook manipulation:

  1. read_notebook_with_outputs: Read a notebook’s content including cell outputs

    • Required: notebook_path (string)
  2. read_notebook_source_only: Read notebook content without outputs

    • Required: notebook_path (string)
    • Use when size limitations prevent reading full notebook with outputs
  3. read_output_of_cell: Read output of a specific cell

    • Required:
      • notebook_path (string)
      • cell_id (string)
  4. add_cell: Add new cell to notebook

    • Required:
      • notebook_path (string)
      • source (string)
    • Optional:
      • cell_type (string): “code” or “markdown”
      • position (integer): insertion index (-1 to append)
  5. edit_cell: Modify existing cell content

    • Required:
      • notebook_path (string)
      • cell_id (string): Unique ID of the cell to edit
      • source (string)
  6. execute_cell: Execute a specific cell and return its output

    • Required:
      • notebook_path (string)
      • cell_id (string)
    • Useful for verifying cell execution and output

Usage with Claude Desktop

Step1: Start JupyterLab or Jupyter Notebook

By using uv to run Jupyter notebooks it’s much easier to manage venv and package installations.

Follow uv jupyter docummentation for more details.

uv venv --seed
source .venv/bin/activate
uv pip install jupyterlab
.venv/bin/jupyter lab

NOTE: this environment should be used as UV_PROJECT_ENVIRONMENT env variable in MCP server (next step). Run in the same folder where Jupyter started.

echo $(pwd)/.venv

Step2: Configure Claude Desctop Add this configuration to your Claude Desktop config file:

PyPi package:

// ~/Library/Application Support/Claude/claude_desktop_config.json
{
  "mcpServers": {
    "Jupyter-notebook-manager": {
      "command": "uv",
      "args": ["run", "--with", "mcp-server-jupyter", "mcp-server-jupyter"],
      "env": {
        "UV_PROJECT_ENVIRONMENT": "/path/to/venv_for_jupyter/.venv"
      }
    }
  }
}

Git repo fork

// ~/Library/Application Support/Claude/claude_desktop_config.json
{
  "mcpServers": {
    "Jupyter-notebook-manager": {
      "command": "uv",
      "args": [
        "run",
        "--directory",
        "/Users/inna/mcp-server-jupyter/src/mcp_server_jupyter",
        "mcp-server-jupyter"
      ],
      "env": {
        "UV_PROJECT_ENVIRONMENT": "/path/to/venv_for_jupyter/.venv"
      }
    }
  }
}

Step 3: Open Notebook & Claude Chat

Open or create a notebook in JupyterLab/Jupyter Notebook

Get the full path to your notebook:

在 GitHub 查看完整 README

安装

This server does not publish a one-line install command.

Open the repository installation guide 新手?先看 mcpskill.org 教程 →

配置

// ~/Library/Application Support/Claude/claude_desktop_config.json { "mcpServers": { "Jupyter-notebook-manager": { "command": "uv", "args": ["run", "--with", "mcp-server-jupyter", "mcp-server-jupyter"], "env": { "UV_PROJECT_ENVIRONMENT": "/path/to/venv_for_jupyter/.venv" } } } }