MCPStack Jupyter MCP
Operate Jupyter Notebooks from your favourite LLM
\[!重要\] 如果您还没有访问MCPStack主编排器存储库,请开始 在那里: MCP堆栈
💡 关于MCPStack Jupyter工具
此存储库提供 封装官方Python Jupyter MCP服务器的MCPStack工具 --确实如此 不 一种新颖的MCP。
- 上游项目: 数据层/jupyter mcp服务器
- 我们 重用他们的MCP操作 并使它们浮出水面 MCP堆栈.
- 随着上游的演变, 某些操作/端点可能会被弃用。我们的包装器有意轻量级,因此更新到新的上游版本应该很简单。
如果你遇到不兼容, 请打开一个问题 我们将跟踪更新以与Jupyter MCP服务器保持一致。
用外行的话来说,什么是MCPStack?
这 模型上下文协议(MCP) 标准化工具与LLM的通信方式。 MCPStack 让你 将多个MCP工具堆叠在一起 并将它们暴露给LLM主机(例如Claude Desktop)。
思考 scikit学习管道,但用于LLM工具:
- 在scikit学习:你链
preprocessors→transformers→estimators. - 在MCPStack中:您可以链接多个MCP工具(Jupyter、MIMIC等),LLM可以在对话中使用所有这些工具。
______________________________________________________________________
安装
该工具作为标准Python包分发。由于有入口点,MCPStack将自动发现它。
经由 uv (推荐)
uv add mcpstack-jupyter经由 pip
pip install mcpstack-jupyter(Dev)预提交挂钩
uv run pre-commit install
# or: pre-commit install______________________________________________________________________
🔌 使用MCPStack
此工具声明了入口点,以便MCPStack可以自动看到它:
[project.entry-points."mcpstack.tools"]
jupyter = "mcpstack_jupyter.tools.jupyter.jupyter:Jupyter"
[project.entry-points."mcpstack.tool_clis"]
jupyter = "mcpstack_jupyter.tools.jupyter.cli:JupyterCLI.get_app"1) 使用令牌运行Jupyter
你 必须 运行Jupyter服务器/实验室 带有令牌 (文档和运行时API将使用相同的令牌)。
uv run jupyter lab \
--port 8888 \
--IdentityProvider.token MY_TOKEN \
--ip 0.0.0.0
# MY_TOKEN can for instance be: 1117bf468693444a5608e882ab3b55d511f354a175a0df02\[!注意\] 文档参考:https://jupyter-mcp-server.datalayer.tech/jupyter/
确保在Jupyter实验室中打开一个笔记本,例如。, notebook.ipynb 或者您在配置中定义的任何内容。
2) 配置Jupyter工具(设置令牌)
使用该工具的CLI创建一个小型 MCPStack ToolConfig JSON。 最低通行证 --token:
uv run mcpstack tools jupyter configure \
--token MY_TOKEN \
--output jupyter_config.json
# MY_TOKEN can for instance be: 1117bf468693444a5608e882ab3b55d511f354a1750df02 (must match the Jupyter server token)CLI有合理的默认值:
DOCUMENT_URL:http://127.0.0.1:8888DOCUMENT_ID:notebook.ipynb\ “附加一个代码单元格,打印Hello World.”
如果一切连接正确,您应该会看到新单元格出现并在Jupyter Lab中执行。
______________________________________________________________________
⚙️ 配置--YAML(开发人员)
此工具附带了YAML配置 src/mcpstack_jupyter/configuration/:
env_defaults.yaml--提供者/URL/IDs和a的默认值require_tokens标志(我们保留代币 必需的).tools.yaml--我们默认公开的上游操作列表。随着上游的发展,在此进行调整。cli_defaults.yaml--CLI的提示标签和默认输出文件名。
您可以调整这些YAML文件,在不接触代码的情况下全局更改默认值。 代币仍然存在 必需的 并且在构建工具时由MCPStack预先执行。
______________________________________________________________________
📖 程序化API
使用 Jupyter 工具类直接位于管道中。 令牌从环境(管道配置或进程环境)中获取:
import os
from mcpstack_jupyter.tools.jupyter.jupyter import Jupyter
from MCPStack.stack import MCPStackCore
# Provide tokens via environment (same token for both is fine)
# On the long term we could think passing a StackConfig to the Jupyter tool instance, with all the necessary env vars. Open An Issue.
os.environ["DOCUMENT_TOKEN"] = "1117bf468693444a5608e882ab3b55d511f354a175a0df02"
os.environ["RUNTIME_TOKEN"] = "1117bf468693444a5608e882ab3b55d511f354a175a0df02"
pipeline = (
MCPStackCore()
.with_tool(Jupyter(include=None)) # or provide a subset of actions of interest.
# Add more tools as needed, e.g., MIMIC, etc.
# .with_tool(MIMIC(...))
.build(type="fastmcp", save_path="my_jupyter_pipeline.json")
.run()
)\[!注意\] 您可以公开的常见上游操作(请参见configuration/tools.yaml): -append_markdown_cell, -insert_markdown_cell, -overwrite_cell_source, -delete_cell-append_execute_code_cell, -insert_execute_code_cell-execute_cell_with_progress, -execute_cell_simple_timeout, -execute_cell_streaming-read_cell, -read_all_cells, -get_notebook_info
______________________________________________________________________
🧰 故障排除
- 403禁止/
_xsrf缺少/无法创建内核
确保您使用令牌运行Jupyter,并且您的 ToolConfig 提供 两者 DOCUMENT_TOKEN 和 RUNTIME_TOKEN. 在大多数设置中,这是相同的。
- 404上
notebook.ipynb
更新 --document-id 相对于Jupyter工作目录的实际笔记本路径(例如。, Untitled.ipynb 或 notebooks/analysis.ipynb).
- 实验室里什么也没发生
更喜欢 http://127.0.0.1:8888 超过 http://localhost:8888. 确认您的管道正在运行,并且该工具列在 mcpstack list-tools.
______________________________________________________________________
🤝 上游兼容性和支持
如前所述,这是 轻质包装材料 通过上游Jupyter MCP服务器 (github.com/datalayer/jupyter-mcp-server).如果上游API改变, 我们很乐意追踪它-- 请打开一个问题 包含版本和失败操作的详细信息。
查看更多 Jupyter MCP Server官方文档.
______________________________________________________________________
📽️ 视频演示
🔐 许可证
麻省理工学院——见 许可证.
