Jupyter-notebook-mcp Quickstart

发布于:2025-06-28 ⋅ 阅读:(11) ⋅ 点赞:(0)

设置

  1. 克隆或下载此仓库到你的电脑:

    git clone https://github.com/jjsantos01/jupyter-notebook-mcp.git
    
  2. 创建包含所需软件包的虚拟环境并安装jupyter-mcp内核,以便它可以被你的jupyter安装识别(如果你之前有一个的话)。

    uv run python -m ipykernel install --name jupyter-mcp
    uv pip install ipywidgets
    
  3. (可选)为你的分析安装额外的Python包:

    uv pip install seaborn
    
  4. 配置IDE桌面集成:

       {
            "mcpServers": {
                "jupyter": {
                    "command": "uv",
                    "args": [
                        "--directory",
                        "/ABSOLUTE/PATH/TO/PARENT/REPO/FOLDER/src",
                        "run",
                        "jupyter_mcp_server.py"
                    ]
                }
            }
        }
    

    /ABSOLUTE/PATH/TO/替换为你系统上src文件夹的实际路径。例如:

    • Windows: "C:\\Users\\MyUser\\GitHub\\jupyter-notebook-mcp\\src\\"
    • Mac: /Users/MyUser/GitHub/jupyter-notebook-mcp/src/

    例如:

    {
       "mcpServers": {
           "jupyter": {
           "command": "uv",
           "args": [
               "--directory",
               "D:/agent-llm/mcp_ser/jupyter-notebook-mcp/src",
               "run",
               "jupyter_mcp_server.py"
           ]
           }
       }
    }
    

使用方法

1. 启动你的Jupyter Notebook(6.x版本)服务器:

uv run jupyter nbclassic

2. 创建一个新的Jupyter笔记本,并确保选择jupyter-mcp内核:kernel -> change kernel -> jupyter-mcp,并设置trusted

在这里插入图片描述

3. 在一个笔记本单元格中运行以下代码以初始化WebSocket服务器:

import sys
sys.path.append('/path/to/jupyter-notebook-mcp/src')  # 添加脚本所在位置的路径

from jupyter_ws_server import setup_jupyter_mcp_integration

# 在Jupyter中启动WebSocket服务器
server, port = setup_jupyter_mcp_integration()

不要忘记在这里将'/path/to/jupyter-notebook-mcp/src'替换为你系统上的src文件夹。例如:

  • Windows: "C:\\Users\\MyUser\\GitHub\\jupyter-notebook-mcp\\src\\"
  • Mac: /Users/MyUser/GitHub/jupyter-notebook-mcp/src/
    在这里插入图片描述

4. 使用支持MCP的IDE桌面启动。

例如trae:
设置好参数并连接,成功后显示下面参数

在这里插入图片描述

问题:

You have access to a Jupyter Notebook server.

I need to create a presentation about Python's Seaborn library.  
The content is as follows:

- What is Seaborn?
- Long vs. Wide data format
- Advantages of Seaborn over Matplotlib
- Commonly used Seaborn functions
- Live demonstration (comparison of Seaborn vs. Matplotlib)
  - Bar plot
  - Line plot
  - Scatter plot

For each concept, I want the main explanations provided in markdown cells, followed by one or more Python code cells demonstrating its usage. Keep the text concise—the cells shouldn't exceed 10 lines each.

Use appropriate slideshow types for each cell to make the presentation visually appealing.

回答:
在这里插入图片描述

在这里插入图片描述

参考链接:
https://github.com/jjsantos01/jupyter-notebook-mcp/blob/main/README.md


网站公告

今日签到

点亮在社区的每一天
去签到